selftests-mm-compaction_test-use-hugetlb-helpers.patch removed from -mm tree
The quilt patch titled
Subject: selftests/mm: compaction_test: use HugeTLB helpers ...
has been removed from the -mm tree. Its filename was
selftests-mm-compaction_test-use-hugetlb-helpers.patch
This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: "Mike Rapoport (Microsoft)" <[email protected]>
Subject: selftests/mm: compaction_test: use HugeTLB helpers ...
Date: Mon, 11 May 2026 19:28:15 +0300
... instead of open coded access of HugeTLB parameters via /proc.
Signed-off-by Mike Rapoport (Microsoft) <[email protected]>
Tested-by Luiz Capitulino <[email protected]>
Tested-by Sarthak Sharma <[email protected]>
Cc Baolin Wang <[email protected]>
Cc Barry Song <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Dev Jain <[email protected]>
Cc Donet Tom <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Cc John Hubbard <[email protected]>
Cc Lance Yang <[email protected]>
Cc Leon Romanovsky <[email protected]>
Cc Liam Howlett <[email protected]>
Cc Li Wang <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc Mark Brown <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Nico Pache <[email protected]>
Cc Peter Xu <[email protected]>
Cc Ryan Roberts <[email protected]>
Cc Shuah Khan <[email protected]>
Cc Suren Baghdasaryan <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Zi Yan <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
tools/testing/selftests/mm/compaction_test.c | 115 ++--------------- 1 file changed, 17 insertions(+), 98 deletions(-)
tools/testing/selftests/mm/compaction_test.c renamed from tools/testing/selftests/mm/compaction_test.c~selftests-mm-compaction_test-use-hugetlb-helpers +17 -98
@@ -17,6 +17,7 @@#include <string.h> #include "kselftest.h" +#include "hugepage_settings.h" #define MAP_SIZE_MB 100#define MAP_SIZE (MAP_SIZE_MB * 1024 * 1024)
@@ -82,124 +83,44 @@ int prereq(void)return -1 ; } -int check_compaction (unsigned long mem_free,unsigned long hugepage_size, -unsigned long initial_nr_hugepages) +int check_compaction (unsigned long mem_free,unsigned long hugepage_size) { -unsigned long nr_hugepages_ul; -int fd, ret =-1 ; +unsigned long nr_hugepages;int compaction_index =0 ; -char nr_hugepages[20 ] = {0 }; -char init_nr_hugepages[24 ] = {0 }; -char target_nr_hugepages[24 ] = {0 }; -int slen; - -snprintf (init_nr_hugepages,sizeof (init_nr_hugepages), -"%lu" , initial_nr_hugepages); +int ret =-1 ;/* We want to test with 80% of available memory. Else, OOM killer comes in to play */ mem_free = mem_free *0.8 ; - fd =open ("/proc/sys/vm/nr_hugepages" ,O_RDWR |O_NONBLOCK ); -if (fd <0 ) { -ksft_print_msg ("Failed to open /proc/sys/vm/nr_hugepages: %s\n" , -strerror (errno)); - ret =-1 ; - goto out; - } -/* * Request huge pages for about half of the free memory. The Kernel * will allocate as much as it can, and we expect it will get at least 1/3 */ - nr_hugepages_ul = mem_free / hugepage_size /2 ; -snprintf (target_nr_hugepages,sizeof (target_nr_hugepages), -"%lu" , nr_hugepages_ul); - - slen =strlen (target_nr_hugepages); -if (write (fd, target_nr_hugepages, slen) != slen) { -ksft_print_msg ("Failed to write %lu to /proc/sys/vm/nr_hugepages: %s\n" , - nr_hugepages_ul,strerror (errno)); - goto close_fd; - } - -lseek (fd,0 ,SEEK_SET ); - -if (read (fd, nr_hugepages,sizeof (nr_hugepages)) <=0 ) { -ksft_print_msg ("Failed to re-read from /proc/sys/vm/nr_hugepages: %s\n" , -strerror (errno)); - goto close_fd; - } + nr_hugepages = mem_free / hugepage_size /2 ; +hugetlb_set_nr_default_pages (nr_hugepages);/* We should have been able to request at least 1/3 rd of the memory in huge pages */ - nr_hugepages_ul =strtoul (nr_hugepages,NULL ,10 ); -if (!nr_hugepages_ul) { + nr_hugepages =hugetlb_nr_default_pages (); +if (!nr_hugepages) {ksft_print_msg ("ERROR: No memory is available as huge pages\n" ); - goto close_fd; - } - compaction_index = mem_free/(nr_hugepages_ul * hugepage_size); - -lseek (fd,0 ,SEEK_SET ); - -if (write (fd, init_nr_hugepages,strlen (init_nr_hugepages)) - !=strlen (init_nr_hugepages)) { -ksft_print_msg ("Failed to write value to /proc/sys/vm/nr_hugepages: %s\n" , -strerror (errno)); - goto close_fd; + goto out; } + compaction_index = mem_free/(nr_hugepages * hugepage_size); -ksft_print_msg ("Number of huge pages allocated = %lu\n" , - nr_hugepages_ul); +ksft_print_msg ("Number of huge pages allocated = %lu\n" , nr_hugepages);if (compaction_index >3 ) {ksft_print_msg ("ERROR: Less than 1/%d of memory is available\n" "as huge pages\n" , compaction_index); - goto close_fd; - } - - ret =0 ; - - close_fd: -close (fd); - out: -ksft_test_result (ret ==0 ,"check_compaction\n" ); -return ret; -} - -int set_zero_hugepages (unsigned long *initial_nr_hugepages) -{ -int fd, ret =-1 ; -char nr_hugepages[20 ] = {0 }; - - fd =open ("/proc/sys/vm/nr_hugepages" ,O_RDWR |O_NONBLOCK ); -if (fd <0 ) { -ksft_print_msg ("Failed to open /proc/sys/vm/nr_hugepages: %s\n" , -strerror (errno)); goto out; } -if (read (fd, nr_hugepages,sizeof (nr_hugepages)) <=0 ) { -ksft_print_msg ("Failed to read from /proc/sys/vm/nr_hugepages: %s\n" , -strerror (errno)); - goto close_fd; - } - -lseek (fd,0 ,SEEK_SET ); -/* Start with the initial condition of 0 huge pages */ -if (write (fd,"0" ,sizeof (char )) !=sizeof (char )) { -ksft_print_msg ("Failed to write 0 to /proc/sys/vm/nr_hugepages: %s\n" , -strerror (errno)); - goto close_fd; - } - - *initial_nr_hugepages =strtoul (nr_hugepages,NULL ,10 ); ret =0 ; - close_fd: -close (fd); - out: +ksft_test_result (ret ==0 ,"check_compaction\n" );return ret; }
@@ -212,18 +133,17 @@ int main(int argc, char **argv)unsigned long mem_free =0 ;unsigned long hugepage_size =0 ;long mem_fragmentable_MB =0 ; -unsigned long initial_nr_hugepages;ksft_print_header ();if (prereq () ||geteuid ())ksft_exit_skip ("Prerequisites unsatisfied\n" ); -ksft_set_plan (1 ); -/* Start the test without hugepages reducing mem_free */ -if (set_zero_hugepages (&initial_nr_hugepages)) -ksft_exit_fail (); +if (!hugetlb_setup_default_exact (0 )) +ksft_exit_skip ("Could not reset nr_hugepages\n" ); + +ksft_set_plan (1 ); lim.rlim_cur =RLIM_INFINITY ; lim.rlim_max =RLIM_INFINITY ;
@@ -268,8 +188,7 @@ int main(int argc, char **argv) entry = entry->next; } -if (check_compaction (mem_free, hugepage_size, - initial_nr_hugepages) ==0 ) +if (check_compaction (mem_free, hugepage_size) ==0 )ksft_exit_pass ();ksft_exit_fail ();
_
Patches currently in -mm which might be from [email protected] are