Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftest/mm: extract sz2ord function into vm_util.h

The function already has 2 uses and will have a 3rd one in prctl
selftests. The pagesize argument is added into the function, as it's not
a global variable anymore. No functional change intended with this patch.

Link: https://lkml.kernel.org/r/20250815135549.130506-6-usamaarif642@gmail.com
Suggested-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Usama Arif <usamaarif642@gmail.com>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Jann Horn <jannh@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Mariano Pache <npache@redhat.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Rik van Riel <riel@surriel.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: SeongJae Park <sj@kernel.org>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Yafang <laoar.shao@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Usama Arif and committed by
Andrew Morton
49850bd0 7de85491

+9 -9
+4 -4
tools/testing/selftests/mm/cow.c
··· 52 52 if (!pmdsize) 53 53 return 0; 54 54 55 - orders = 1UL << sz2ord(pmdsize); 55 + orders = 1UL << sz2ord(pmdsize, pagesize); 56 56 orders |= thp_supported_orders(); 57 57 58 58 for (i = 0; orders && count < max; i++) { ··· 1211 1211 size_t size = thpsizes[i]; 1212 1212 struct thp_settings settings = *thp_current_settings(); 1213 1213 1214 - settings.hugepages[sz2ord(pmdsize)].enabled = THP_NEVER; 1215 - settings.hugepages[sz2ord(size)].enabled = THP_ALWAYS; 1214 + settings.hugepages[sz2ord(pmdsize, pagesize)].enabled = THP_NEVER; 1215 + settings.hugepages[sz2ord(size, pagesize)].enabled = THP_ALWAYS; 1216 1216 thp_push_settings(&settings); 1217 1217 1218 1218 if (size == pmdsize) { ··· 1863 1863 if (pmdsize) { 1864 1864 /* Only if THP is supported. */ 1865 1865 thp_read_settings(&default_settings); 1866 - default_settings.hugepages[sz2ord(pmdsize)].enabled = THP_INHERIT; 1866 + default_settings.hugepages[sz2ord(pmdsize, pagesize)].enabled = THP_INHERIT; 1867 1867 thp_save_settings(); 1868 1868 thp_push_settings(&default_settings); 1869 1869
+1 -1
tools/testing/selftests/mm/split_huge_page_test.c
··· 546 546 ksft_exit_fail_msg("Reading PMD pagesize failed\n"); 547 547 548 548 nr_pages = pmd_pagesize / pagesize; 549 - max_order = sz2ord(pmd_pagesize); 549 + max_order = sz2ord(pmd_pagesize, pagesize); 550 550 tests = 2 + (max_order - 1) + (2 * max_order) + (max_order - 1) * 4 + 2; 551 551 ksft_set_plan(tests); 552 552
+2 -2
tools/testing/selftests/mm/uffd-wp-mremap.c
··· 82 82 struct thp_settings settings = *thp_current_settings(); 83 83 84 84 if (private) 85 - settings.hugepages[sz2ord(size)].enabled = THP_ALWAYS; 85 + settings.hugepages[sz2ord(size, pagesize)].enabled = THP_ALWAYS; 86 86 else 87 - settings.shmem_hugepages[sz2ord(size)].enabled = SHMEM_ALWAYS; 87 + settings.shmem_hugepages[sz2ord(size, pagesize)].enabled = SHMEM_ALWAYS; 88 88 89 89 thp_push_settings(&settings); 90 90
+2 -2
tools/testing/selftests/mm/vm_util.h
··· 127 127 ksft_test_result_report(result, "%s\n", test_name); 128 128 } 129 129 130 - static inline int sz2ord(size_t size) 130 + static inline int sz2ord(size_t size, size_t pagesize) 131 131 { 132 - return __builtin_ctzll(size / getpagesize()); 132 + return __builtin_ctzll(size / pagesize); 133 133 } 134 134 135 135 void *sys_mremap(void *old_address, unsigned long old_size,