Skip to content

Commit a32bf5b

Browse files
Ryan Robertsakpm00
authored andcommitted
selftests/mm: set allocated memory to non-zero content in cow test
After commit b1f2020 ("mm: remap unused subpages to shared zeropage when splitting isolated thp"), cow test cases involving swapping out THPs via madvise(MADV_PAGEOUT) started to be skipped due to the subsequent check via pagemap determining that the memory was not actually swapped out. Logs similar to this were emitted: ... # [RUN] Basic COW after fork() ... with swapped-out, PTE-mapped THP (16 kB) ok 2 # SKIP MADV_PAGEOUT did not work, is swap enabled? # [RUN] Basic COW after fork() ... with single PTE of swapped-out THP (16 kB) ok 3 # SKIP MADV_PAGEOUT did not work, is swap enabled? # [RUN] Basic COW after fork() ... with swapped-out, PTE-mapped THP (32 kB) ok 4 # SKIP MADV_PAGEOUT did not work, is swap enabled? ... The commit in question introduces the behaviour of scanning THPs and if their content is predominantly zero, it splits them and replaces the pages which are wholly zero with the zero page. These cow test cases were getting caught up in this. So let's avoid that by filling the contents of all allocated memory with a non-zero value. With this in place, the tests are passing again. Link: https://lkml.kernel.org/r/[email protected] Fixes: b1f2020 ("mm: remap unused subpages to shared zeropage when splitting isolated thp") Signed-off-by: Ryan Roberts <[email protected]> Acked-by: David Hildenbrand <[email protected]> Cc: Usama Arif <[email protected]> Cc: Yu Zhao <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 0cef0bb commit a32bf5b

File tree

1 file changed

+4
-4
lines changed
  • tools/testing/selftests/mm

1 file changed

+4
-4
lines changed

tools/testing/selftests/mm/cow.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ static void do_run_with_base_page(test_fn fn, bool swapout)
758758
}
759759

760760
/* Populate a base page. */
761-
memset(mem, 0, pagesize);
761+
memset(mem, 1, pagesize);
762762

763763
if (swapout) {
764764
madvise(mem, pagesize, MADV_PAGEOUT);
@@ -824,12 +824,12 @@ static void do_run_with_thp(test_fn fn, enum thp_run thp_run, size_t thpsize)
824824
* Try to populate a THP. Touch the first sub-page and test if
825825
* we get the last sub-page populated automatically.
826826
*/
827-
mem[0] = 0;
827+
mem[0] = 1;
828828
if (!pagemap_is_populated(pagemap_fd, mem + thpsize - pagesize)) {
829829
ksft_test_result_skip("Did not get a THP populated\n");
830830
goto munmap;
831831
}
832-
memset(mem, 0, thpsize);
832+
memset(mem, 1, thpsize);
833833

834834
size = thpsize;
835835
switch (thp_run) {
@@ -1012,7 +1012,7 @@ static void run_with_hugetlb(test_fn fn, const char *desc, size_t hugetlbsize)
10121012
}
10131013

10141014
/* Populate an huge page. */
1015-
memset(mem, 0, hugetlbsize);
1015+
memset(mem, 1, hugetlbsize);
10161016

10171017
/*
10181018
* We need a total of two hugetlb pages to handle COW/unsharing

0 commit comments

Comments
 (0)