Re: [PATCH v5 6/7] selftests: prctl: introduce tests for disabling THPs completely

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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 to disable all THPs and skip if it fails.
> 
> This tests if the process can:
> - successfully get the policy to disable THPs completely.
> - never get a hugepage when the THPs are completely disabled
>   with the prctl, including with MADV_HUGE and MADV_COLLAPSE.
> - 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.
> 
> Signed-off-by: Usama Arif <usamaarif642@xxxxxxxxx>
> Acked-by: David Hildenbrand <david@xxxxxxxxxx>
> Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@xxxxxxxxxx>
> ---
>  tools/testing/selftests/mm/.gitignore         |   1 +
>  tools/testing/selftests/mm/Makefile           |   1 +
>  .../testing/selftests/mm/prctl_thp_disable.c  | 175 ++++++++++++++++++
>  tools/testing/selftests/mm/thp_settings.c     |   9 +-
>  tools/testing/selftests/mm/thp_settings.h     |   1 +
>  5 files changed, 186 insertions(+), 1 deletion(-)
>  create mode 100644 tools/testing/selftests/mm/prctl_thp_disable.c
>

Andrew, could you please apply the below fixlet on top of this patch as suggested
by David in https://lore.kernel.org/all/a385e09f-f582-4ede-9e60-1d85cee02a3c@xxxxxxxxxx/?

Thanks!

>From db9306c06cbd6057c2a8839e5d4c1d2559b58b70 Mon Sep 17 00:00:00 2001
From: Usama Arif <usamaarif642@xxxxxxxxx>
Date: Mon, 18 Aug 2025 11:27:04 +0100
Subject: [PATCH 2/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 e9e519c85224c..df3cce278e10a 100644
--- a/tools/testing/selftests/mm/prctl_thp_disable.c
+++ b/tools/testing/selftests/mm/prctl_thp_disable.c
@@ -161,8 +161,10 @@ TEST_F(prctl_thp_disable_completely, fork)
 	pid = fork();
 	ASSERT_GE(pid, 0);
 
-	if (!pid)
+	if (!pid) {
 		prctl_thp_disable_completely_test(_metadata, self->pmdsize, variant->thp_policy);
+		return;
+	}
 
 	wait(&ret);
 	if (WIFEXITED(ret))
-- 
2.47.3






[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux