Skip to content

Commit d021b44

Browse files
Ryan Robertsakpm00
Ryan Roberts
authored andcommitted
selftests/mm: ksm_tests should only MADV_HUGEPAGE valid memory
ksm_tests was previously mmapping a region of memory, aligning the returned pointer to a PMD boundary, then setting MADV_HUGEPAGE, but was setting it past the end of the mmapped area due to not taking the pointer alignment into consideration. Fix this behaviour. Up until commit efa7df3 ("mm: align larger anonymous mappings on THP boundaries"), this buggy behavior was (usually) masked because the alignment difference was always less than PMD-size. But since the mentioned commit, `ksm_tests -H -s 100` started failing. Link: https://lkml.kernel.org/r/[email protected] Fixes: 3252548 ("selftests: vm: add KSM huge pages merging time test") Signed-off-by: Ryan Roberts <[email protected]> Cc: Pedro Demarchi Gomes <[email protected]> Cc: Shuah Khan <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 6f9dc68 commit d021b44

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/testing/selftests/mm/ksm_tests.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ static int ksm_merge_hugepages_time(int merge_type, int mapping, int prot,
566566
if (map_ptr_orig == MAP_FAILED)
567567
err(2, "initial mmap");
568568

569-
if (madvise(map_ptr, len + HPAGE_SIZE, MADV_HUGEPAGE))
569+
if (madvise(map_ptr, len, MADV_HUGEPAGE))
570570
err(2, "MADV_HUGEPAGE");
571571

572572
pagemap_fd = open("/proc/self/pagemap", O_RDONLY);

0 commit comments

Comments
 (0)