[PATCH] hugepages: ensure CONFIG_COMPACTION is defined

Andrea Cervesato <[email protected]>
Newsgroups gmane.linux.ltp
Message-ID <[email protected]>
From: Andrea Cervesato <andrea.cervesato-IBi9RG/[email protected]>

Add check to ensure CONFIG_COMPACTION=y when we need to use hugepages
inside tests. The kernel configuration is used to enable usage of
`/proc/sys/vm/compact_memory` inside the LTP core library.

Signed-off-by: Andrea Cervesato <andrea.cervesato-IBi9RG/[email protected]>
---
The issue was raised by https://github.com/linux-test-project/ltp/pull/1335
that is trying to solve a problem with cachestat03.
---
 lib/tst_hugepage.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/tst_hugepage.c b/lib/tst_hugepage.c
index 40ecfa162a236a8674628f8ffe7a8fd2ccd52712..8fba466b0ebb04d43542d686d6bb9173f1a14cb8 100644
--- a/lib/tst_hugepage.c
+++ b/lib/tst_hugepage.c
@@ -46,6 +46,11 @@ unsigned long tst_reserve_hugepages(struct tst_hugepage *hp)
 		goto set_hugepages;
 	}
 
+	if (access(PATH_VM_COMPACT_MEMORY, F_OK)) {
+		if (hp->policy == TST_NEEDS || hp->policy == TST_REQUEST)
+			tst_brk(TCONF, "CONFIG_COMPACTION not enabled in kernel");
+	}
+
 	SAFE_FILE_PRINTF(PATH_VM_DROP_CACHES, "3");
 	SAFE_FILE_PRINTF(PATH_VM_COMPACT_MEMORY, "1");
 	if (hp->policy == TST_NEEDS) {

---
base-commit: d6fe8d8e7a58c83b6a192fb27cd2ecf5249182f7
change-id: 20260717-fix_tst_test_hugepages-fb3c88e9716c

Best regards,
-- 
Andrea Cervesato <andrea.cervesato-IBi9RG/[email protected]>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.