mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
selftests/mm: migration: don't assume huge page is TWOMEG
migration tests presume that both THP and HugeTLB huge pages are 2MB. Add dynamic detection of huge page size with read_pmd_pagesize() for THP and with default_huge_page_size() for HugeTLB. Link: https://lore.kernel.org/20260511162840.375890-3-rppt@kernel.org Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Reviewed-by: Donet Tom <donettom@linux.ibm.com> Reviewed-by: Luiz Capitulino <luizcap@redhat.com> Tested-by: Luiz Capitulino <luizcap@redhat.com> Cc: Baolin Wang <baolin.wang@linux.alibaba.com> Cc: Barry Song <baohua@kernel.org> Cc: David Hildenbrand <david@kernel.org> Cc: Dev Jain <dev.jain@arm.com> Cc: Jason Gunthorpe <jgg@ziepe.ca> Cc: John Hubbard <jhubbard@nvidia.com> Cc: Lance Yang <lance.yang@linux.dev> Cc: Leon Romanovsky <leon@kernel.org> Cc: Liam Howlett <liam@infradead.org> Cc: Li Wang <li.wang@linux.dev> Cc: Lorenzo Stoakes <ljs@kernel.org> Cc: Mark Brown <broonie@kernel.org> Cc: Michal Hocko <mhocko@suse.com> Cc: Nico Pache <npache@redhat.com> Cc: Peter Xu <peterx@redhat.com> Cc: Ryan Roberts <ryan.roberts@arm.com> Cc: Sarthak Sharma <sarthak.sharma@arm.com> Cc: Shuah Khan <shuah@kernel.org> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Vlastimil Babka <vbabka@kernel.org> Cc: Zi Yan <ziy@nvidia.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
79f33d19fc
commit
4d7f4bf510
|
|
@ -184,22 +184,27 @@ TEST_F_TIMEOUT(migration, shared_anon, 2*RUNTIME)
|
|||
*/
|
||||
TEST_F_TIMEOUT(migration, private_anon_thp, 2*RUNTIME)
|
||||
{
|
||||
uint64_t pmdsize;
|
||||
uint64_t *ptr;
|
||||
int i;
|
||||
|
||||
if (!thp_is_enabled())
|
||||
SKIP(return, "Transparent Hugepages not available");
|
||||
|
||||
pmdsize = read_pmd_pagesize();
|
||||
if (!pmdsize)
|
||||
SKIP(return, "Reading PMD pagesize failed");
|
||||
|
||||
if (self->nthreads < 2 || self->n1 < 0 || self->n2 < 0)
|
||||
SKIP(return, "Not enough threads or NUMA nodes available");
|
||||
|
||||
ptr = mmap(NULL, 2*TWOMEG, PROT_READ | PROT_WRITE,
|
||||
ptr = mmap(NULL, 2 * pmdsize, PROT_READ | PROT_WRITE,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||
ASSERT_NE(ptr, MAP_FAILED);
|
||||
|
||||
ptr = (uint64_t *) ALIGN((uintptr_t) ptr, TWOMEG);
|
||||
ASSERT_EQ(madvise(ptr, TWOMEG, MADV_HUGEPAGE), 0);
|
||||
memset(ptr, 0xde, TWOMEG);
|
||||
ptr = (uint64_t *) ALIGN((uintptr_t) ptr, pmdsize);
|
||||
ASSERT_EQ(madvise(ptr, pmdsize, MADV_HUGEPAGE), 0);
|
||||
memset(ptr, 0xde, pmdsize);
|
||||
for (i = 0; i < self->nthreads - 1; i++)
|
||||
if (pthread_create(&self->threads[i], NULL, access_mem, ptr))
|
||||
perror("Couldn't create thread");
|
||||
|
|
@ -215,6 +220,7 @@ TEST_F_TIMEOUT(migration, private_anon_thp, 2*RUNTIME)
|
|||
|
||||
TEST_F_TIMEOUT(migration, shared_anon_thp, 2*RUNTIME)
|
||||
{
|
||||
uint64_t pmdsize;
|
||||
pid_t pid;
|
||||
uint64_t *ptr;
|
||||
int i;
|
||||
|
|
@ -222,17 +228,21 @@ TEST_F_TIMEOUT(migration, shared_anon_thp, 2*RUNTIME)
|
|||
if (!thp_is_enabled())
|
||||
SKIP(return, "Transparent Hugepages not available");
|
||||
|
||||
pmdsize = read_pmd_pagesize();
|
||||
if (!pmdsize)
|
||||
SKIP(return, "Reading PMD pagesize failed");
|
||||
|
||||
if (self->nthreads < 2 || self->n1 < 0 || self->n2 < 0)
|
||||
SKIP(return, "Not enough threads or NUMA nodes available");
|
||||
|
||||
ptr = mmap(NULL, 2 * TWOMEG, PROT_READ | PROT_WRITE,
|
||||
ptr = mmap(NULL, 2 * pmdsize, PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED | MAP_ANONYMOUS, -1, 0);
|
||||
ASSERT_NE(ptr, MAP_FAILED);
|
||||
|
||||
ptr = (uint64_t *) ALIGN((uintptr_t) ptr, TWOMEG);
|
||||
ASSERT_EQ(madvise(ptr, TWOMEG, MADV_HUGEPAGE), 0);
|
||||
ptr = (uint64_t *) ALIGN((uintptr_t) ptr, pmdsize);
|
||||
ASSERT_EQ(madvise(ptr, pmdsize, MADV_HUGEPAGE), 0);
|
||||
|
||||
memset(ptr, 0xde, TWOMEG);
|
||||
memset(ptr, 0xde, pmdsize);
|
||||
for (i = 0; i < self->nthreads - 1; i++) {
|
||||
pid = fork();
|
||||
if (!pid) {
|
||||
|
|
@ -256,17 +266,22 @@ TEST_F_TIMEOUT(migration, shared_anon_thp, 2*RUNTIME)
|
|||
*/
|
||||
TEST_F_TIMEOUT(migration, private_anon_htlb, 2*RUNTIME)
|
||||
{
|
||||
unsigned long hugepage_size;
|
||||
uint64_t *ptr;
|
||||
int i;
|
||||
|
||||
if (self->nthreads < 2 || self->n1 < 0 || self->n2 < 0)
|
||||
SKIP(return, "Not enough threads or NUMA nodes available");
|
||||
|
||||
ptr = mmap(NULL, TWOMEG, PROT_READ | PROT_WRITE,
|
||||
hugepage_size = default_huge_page_size();
|
||||
if (!hugepage_size)
|
||||
SKIP(return, "Reading HugeTLB pagesize failed");
|
||||
|
||||
ptr = mmap(NULL, hugepage_size, PROT_READ | PROT_WRITE,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, -1, 0);
|
||||
ASSERT_NE(ptr, MAP_FAILED);
|
||||
|
||||
memset(ptr, 0xde, TWOMEG);
|
||||
memset(ptr, 0xde, hugepage_size);
|
||||
for (i = 0; i < self->nthreads - 1; i++)
|
||||
if (pthread_create(&self->threads[i], NULL, access_mem, ptr))
|
||||
perror("Couldn't create thread");
|
||||
|
|
@ -281,6 +296,7 @@ TEST_F_TIMEOUT(migration, private_anon_htlb, 2*RUNTIME)
|
|||
*/
|
||||
TEST_F_TIMEOUT(migration, shared_anon_htlb, 2*RUNTIME)
|
||||
{
|
||||
unsigned long hugepage_size;
|
||||
pid_t pid;
|
||||
uint64_t *ptr;
|
||||
int i;
|
||||
|
|
@ -288,11 +304,15 @@ TEST_F_TIMEOUT(migration, shared_anon_htlb, 2*RUNTIME)
|
|||
if (self->nthreads < 2 || self->n1 < 0 || self->n2 < 0)
|
||||
SKIP(return, "Not enough threads or NUMA nodes available");
|
||||
|
||||
ptr = mmap(NULL, TWOMEG, PROT_READ | PROT_WRITE,
|
||||
hugepage_size = default_huge_page_size();
|
||||
if (!hugepage_size)
|
||||
SKIP(return, "Reading HugeTLB pagesize failed");
|
||||
|
||||
ptr = mmap(NULL, hugepage_size, PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED | MAP_ANONYMOUS | MAP_HUGETLB, -1, 0);
|
||||
ASSERT_NE(ptr, MAP_FAILED);
|
||||
|
||||
memset(ptr, 0xde, TWOMEG);
|
||||
memset(ptr, 0xde, hugepage_size);
|
||||
for (i = 0; i < self->nthreads - 1; i++) {
|
||||
pid = fork();
|
||||
if (!pid) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user