On 15/08/2025 14:54, Usama Arif wrote: > The test will set the global system THP setting to never, madvise > or always depending on the fixture variant and the 2M setting to > inherit before it starts (and reset to original at teardown). > The fixture setup will also test if PR_SET_THP_DISABLE prctl call can > be made with PR_THP_DISABLE_EXCEPT_ADVISED and skip if it fails. > > This tests if the process can: > - successfully get the policy to disable THPs expect for madvise. > - get hugepages only on MADV_HUGE and MADV_COLLAPSE if the global policy > is madvise/always and only with MADV_COLLAPSE if the global policy is > never. > - successfully reset the policy of the process. > - after reset, only get hugepages with: > - MADV_COLLAPSE when policy is set to never. > - MADV_HUGE and MADV_COLLAPSE when policy is set to madvise. > - always when policy is set to "always". > - never get a THP with MADV_NOHUGEPAGE. > - repeat the above tests in a forked process to make sure the policy is > carried across forks. > > Test results: > ./prctl_thp_disable > TAP version 13 > 1..12 > ok 1 prctl_thp_disable_completely.never.nofork > ok 2 prctl_thp_disable_completely.never.fork > ok 3 prctl_thp_disable_completely.madvise.nofork > ok 4 prctl_thp_disable_completely.madvise.fork > ok 5 prctl_thp_disable_completely.always.nofork > ok 6 prctl_thp_disable_completely.always.fork > ok 7 prctl_thp_disable_except_madvise.never.nofork > ok 8 prctl_thp_disable_except_madvise.never.fork > ok 9 prctl_thp_disable_except_madvise.madvise.nofork > ok 10 prctl_thp_disable_except_madvise.madvise.fork > ok 11 prctl_thp_disable_except_madvise.always.nofork > ok 12 prctl_thp_disable_except_madvise.always.fork > > Signed-off-by: Usama Arif <usamaarif642@xxxxxxxxx> > --- Andrew could you please help apply the below fixlet on top of this patch? Thanks! >From 85908068c15fee0b9e5796fbc552e38239c2765a Mon Sep 17 00:00:00 2001 From: Usama Arif <usamaarif642@xxxxxxxxx> Date: Mon, 18 Aug 2025 11:37:10 +0100 Subject: [PATCH 4/4] [fixlet] selftests: prctl: return after executing test in child process The next step after executing the test is a wait, but there is nothing to wait for in the child, so just return. Signed-off-by: Usama Arif <usamaarif642@xxxxxxxxx> --- tools/testing/selftests/mm/prctl_thp_disable.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/mm/prctl_thp_disable.c b/tools/testing/selftests/mm/prctl_thp_disable.c index 21d181ab599a2..feb711dca3a1d 100644 --- a/tools/testing/selftests/mm/prctl_thp_disable.c +++ b/tools/testing/selftests/mm/prctl_thp_disable.c @@ -273,9 +273,11 @@ TEST_F(prctl_thp_disable_except_madvise, fork) pid = fork(); ASSERT_GE(pid, 0); - if (!pid) + if (!pid) { prctl_thp_disable_except_madvise_test(_metadata, self->pmdsize, variant->thp_policy); + return; + } wait(&ret); if (WIFEXITED(ret)) -- 2.47.3