Re: [PATCH v3 1/2] mm: huge_memory: disallow hugepages if the system-wide THP sysfs settings are disabled

From: Baolin Wang
Date: Tue Jun 24 2025 - 05:21:10 EST




On 2025/6/24 16:29, David Hildenbrand wrote:
On 24.06.25 03:48, Baolin Wang wrote:


On 2025/6/23 21:54, David Hildenbrand wrote:

diff --git a/tools/testing/selftests/mm/khugepaged.c b/tools/testing/
selftests/mm/khugepaged.c
index 4341ce6b3b38..85bfff53dba6 100644
--- a/tools/testing/selftests/mm/khugepaged.c
+++ b/tools/testing/selftests/mm/khugepaged.c
@@ -501,11 +501,7 @@ static void __madvise_collapse(const char *msg,
char *p, int nr_hpages,
       printf("%s...", msg);
-    /*
-     * Prevent khugepaged interference and tests that MADV_COLLAPSE
-     * ignores /sys/kernel/mm/transparent_hugepage/enabled
-     */
-    settings.thp_enabled = THP_NEVER;
+    settings.thp_enabled = THP_ALWAYS;


Would MADVISE mode also work here? If we don't set MADV_HUGEPAGE, then
khugepaged should be excluded, correct?

I tried this, but some test cases failed. As I replied to Barry, it's
because some tests previously set MADV_NOHUGEPAGE, and now there is no
way to clear the MADV_NOHUGEPAGE flag except by setting MADV_HUGEPAGE.

Okay, can you add that detail to the patch description.

Sure. Will do.

I suspect we really want a way to undo what MADV_NOHUGEPAGE/MADV_NOHUGEPAGE did (if only naming wouldn't be complicated: MADV_DEFAULT_HUGEPAGE, hmmmm).