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!