mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
kselftest: mm: remove check_huge_shmem()
check_huge_shmem() was required to distinguish shmem huge pages because /proc/self/smaps reports them using a dedicated “ShmemPmdMapped” entry, as opposed to “FilePmdMapped” for file-backed huge pages. Now that /proc/self/smaps is no longer used to detect huge pages and /proc/kpageflags is used instead, it is sufficient to distinguish between file-backed and anonymous pages since the ShmemPmdMapped is also kind of file-backed. Therefore, remove check_huge_shmem() and use check_huge_file() instead and cleanup khugepaged's check_huge operation in mem_ops. Link: https://lore.kernel.org/20261001-fix_split-v9-4-0f4ba8bbdbdf@arm.com Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Suggested-by: David Hildenbrand (Arm) <david@kernel.org> Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com> Reviewed-by: Sarthak Sharma <sarthak.sharma@arm.com> Acked-by: Zi Yan <ziy@nvidia.com> Acked-by: Lorenzo Stoakes (ARM) <ljs@kernel.org> Acked-by: David Hildenbrand (Arm) <david@kernel.org> Cc: Liam R. Howlett <liam@infradead.org> Cc: Nico Pache <nico.pache@linux.dev> Cc: Ryan Roberts <ryan.roberts@arm.com> Cc: Dev Jain <dev.jain@arm.com> Cc: Barry Song <baohua@kernel.org> Cc: Lance Yang <lance.yang@linux.dev> Cc: Usama Arif <usama.arif@linux.dev> Cc: Vlastimil Babka <vbabka@kernel.org> Cc: Mike Rapoport <rppt@kernel.org> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Michal Hocko <mhocko@suse.com> Cc: Shuah Khan <shuah@kernel.org> Cc: Kevin Brodsky <kevin.brodsky@arm.com>
This commit is contained in:
parent
f47d99c9be
commit
49c77c5de3
|
|
@ -181,7 +181,7 @@ static uint64_t run_iteration(void)
|
|||
for (i = 0; i < TOTAL_PAGES; i++)
|
||||
fill_page(mmap_base, i);
|
||||
|
||||
if (!check_huge_shmem(mmap_base, FILE_SIZE, NR_PMD_PAGE, pmd_pagesize))
|
||||
if (!check_huge_file(mmap_base, FILE_SIZE, NR_PMD_PAGE, pmd_pagesize))
|
||||
ksft_exit_fail_msg("No shmem THP is allocated\n");
|
||||
|
||||
if (pthread_barrier_init(&ctl.barrier, NULL, NUM_READER_THREADS + 1) != 0)
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ struct mem_ops {
|
|||
void *(*setup_area)(int nr_hpages);
|
||||
void (*cleanup_area)(void *p, unsigned long size);
|
||||
void (*fault)(void *p, unsigned long start, unsigned long end);
|
||||
bool (*check_huge)(void *addr, size_t len, int nr_hpages, unsigned long hpage_size);
|
||||
bool (*check_huge)(void *addr, size_t len, int nr_hpages, uint64_t hpage_size);
|
||||
const char *name;
|
||||
};
|
||||
|
||||
|
|
@ -343,12 +343,6 @@ static void anon_fault(void *p, unsigned long start, unsigned long end)
|
|||
fill_memory(p, start, end);
|
||||
}
|
||||
|
||||
static bool anon_check_huge(void *addr, size_t len, int nr_hpages,
|
||||
unsigned long hpage_size)
|
||||
{
|
||||
return check_huge_anon(addr, len, nr_hpages, hpage_size);
|
||||
}
|
||||
|
||||
static void *file_setup_area_common(int nr_hpages, enum file_setup_ops setup)
|
||||
{
|
||||
const int open_opt = setup == FILE_SETUP_READ_ONLY_FS ? O_RDONLY : O_RDWR;
|
||||
|
|
@ -444,20 +438,6 @@ static void file_fault_write(void *p, unsigned long start, unsigned long end)
|
|||
ksft_exit_fail_perror("madvise(MADV_POPULATE_WRITE)");
|
||||
}
|
||||
|
||||
static bool file_check_huge(void *addr, size_t len, int nr_hpages,
|
||||
unsigned long hpage_size)
|
||||
{
|
||||
switch (finfo.type) {
|
||||
case VMA_FILE:
|
||||
return check_huge_file(addr, len, nr_hpages, hpage_size);
|
||||
case VMA_SHMEM:
|
||||
return check_huge_shmem(addr, len, nr_hpages, hpage_size);
|
||||
default:
|
||||
ksft_exit_fail_msg("Unknown VMA type\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static void *shmem_setup_area(int nr_hpages)
|
||||
{
|
||||
void *p;
|
||||
|
|
@ -481,17 +461,11 @@ static void shmem_cleanup_area(void *p, unsigned long size)
|
|||
close(finfo.fd);
|
||||
}
|
||||
|
||||
static bool shmem_check_huge(void *addr, size_t len, int nr_hpages,
|
||||
unsigned long hpage_size)
|
||||
{
|
||||
return check_huge_shmem(addr, len, nr_hpages, hpage_size);
|
||||
}
|
||||
|
||||
static struct mem_ops __anon_ops = {
|
||||
.setup_area = &anon_setup_area,
|
||||
.cleanup_area = &anon_cleanup_area,
|
||||
.fault = &anon_fault,
|
||||
.check_huge = &anon_check_huge,
|
||||
.check_huge = &check_huge_anon,
|
||||
.name = "anon",
|
||||
};
|
||||
|
||||
|
|
@ -499,7 +473,7 @@ static struct mem_ops __read_only_file_ops = {
|
|||
.setup_area = &file_setup_read_only_area,
|
||||
.cleanup_area = &file_cleanup_area,
|
||||
.fault = &file_fault_read,
|
||||
.check_huge = &file_check_huge,
|
||||
.check_huge = &check_huge_file,
|
||||
.name = "file",
|
||||
};
|
||||
|
||||
|
|
@ -507,7 +481,7 @@ static struct mem_ops __read_write_file_read_ops = {
|
|||
.setup_area = &file_setup_read_write_fs_read_area,
|
||||
.cleanup_area = &file_cleanup_area,
|
||||
.fault = &file_fault_read_and_flush,
|
||||
.check_huge = &file_check_huge,
|
||||
.check_huge = &check_huge_file,
|
||||
.name = "file",
|
||||
};
|
||||
|
||||
|
|
@ -515,7 +489,7 @@ static struct mem_ops __read_write_file_write_ops = {
|
|||
.setup_area = &file_setup_read_write_fs_write_area,
|
||||
.cleanup_area = &file_cleanup_area,
|
||||
.fault = &file_fault_write,
|
||||
.check_huge = &file_check_huge,
|
||||
.check_huge = &check_huge_file,
|
||||
.name = "file",
|
||||
};
|
||||
|
||||
|
|
@ -523,7 +497,7 @@ static struct mem_ops __shmem_ops = {
|
|||
.setup_area = &shmem_setup_area,
|
||||
.cleanup_area = &shmem_cleanup_area,
|
||||
.fault = &anon_fault,
|
||||
.check_huge = &shmem_check_huge,
|
||||
.check_huge = &check_huge_file,
|
||||
.name = "shmem",
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -196,8 +196,8 @@ static void shmem_check_pmd_mapping(uffd_global_test_opts_t *gopts, void *p, int
|
|||
{
|
||||
size_t len = expect_nr_hpages * read_pmd_pagesize();
|
||||
|
||||
if (!check_huge_shmem(gopts->area_dst_alias, len, expect_nr_hpages,
|
||||
read_pmd_pagesize()))
|
||||
if (!check_huge_file(gopts->area_dst_alias, len, expect_nr_hpages,
|
||||
read_pmd_pagesize()))
|
||||
err("Did not find expected %d number of hugepages",
|
||||
expect_nr_hpages);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -486,11 +486,6 @@ bool check_huge_file(void *addr, size_t len, int nr_hpages, uint64_t hpage_size)
|
|||
return __check_type(addr, len, scan_mapping_size, CHECK_TYPE_FILE);
|
||||
}
|
||||
|
||||
bool check_huge_shmem(void *addr, size_t len, int nr_hpages, uint64_t hpage_size)
|
||||
{
|
||||
return check_huge_file(addr, len, nr_hpages, hpage_size);
|
||||
}
|
||||
|
||||
int64_t allocate_transhuge(void *ptr, int pagemap_fd)
|
||||
{
|
||||
uint64_t ent[2];
|
||||
|
|
|
|||
|
|
@ -96,7 +96,6 @@ uint64_t read_pmd_pagesize(void);
|
|||
unsigned long rss_anon(void);
|
||||
bool check_huge_anon(void *addr, size_t len, int nr_hpages, uint64_t hpage_size);
|
||||
bool check_huge_file(void *addr, size_t len, int nr_hpages, uint64_t hpage_size);
|
||||
bool check_huge_shmem(void *addr, size_t len, int nr_hpages, uint64_t hpage_size);
|
||||
int64_t allocate_transhuge(void *ptr, int pagemap_fd);
|
||||
int pageflags_get(unsigned long pfn, int kpageflags_fd, uint64_t *flags);
|
||||
int gather_folio_orders(char *vaddr_start, size_t len,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user