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

selftests: mincore: fix tmpfs mincore test failure

When running mincore test cases, I encountered the following failures:

"
mincore_selftest.c:359:check_tmpfs_mmap:Expected ra_pages (511) == 0 (0)
mincore_selftest.c:360:check_tmpfs_mmap:Read-ahead pages found in memory
check_tmpfs_mmap: Test terminated by assertion
FAIL global.check_tmpfs_mmap
not ok 5 global.check_tmpfs_mmap
FAILED: 4 / 5 tests passed
"

The reason for the test case failure is that my system automatically enabled
tmpfs large folio allocation by adding the 'transparent_hugepage_tmpfs=always'
cmdline. However, the test case still expects the tmpfs mounted on /dev/shm to
allocate small folios, which leads to assertion failures when verifying readahead
pages.

As discussed with David, there's no reason to continue checking the readahead
logic for tmpfs. Drop it to fix this issue.

Link: https://lkml.kernel.org/r/9a00856cc6a8b4e46f4ab8b1af11ce5fc1a31851.1744025467.git.baolin.wang@linux.alibaba.com
Fixes: d635ccdb435c ("mm: shmem: add a kernel command line to change the default huge policy for tmpfs")
Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Acked-by: Zi Yan <ziy@nvidia.com>
Acked-by: David Hildenbrand <david@redhat.com>
Cc: Barry Song <21cnbao@gmail.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Baolin Wang and committed by
Andrew Morton
8c583e53 aabf58bf

+2 -14
+2 -14
tools/testing/selftests/mincore/mincore_selftest.c
··· 286 286 287 287 /* 288 288 * Test mincore() behavior on a page backed by a tmpfs file. This test 289 - * performs the same steps as the previous one. However, we don't expect 290 - * any readahead in this case. 289 + * performs the same steps as the previous one. 291 290 */ 292 291 TEST(check_tmpfs_mmap) 293 292 { ··· 297 298 int page_size; 298 299 int fd; 299 300 int i; 300 - int ra_pages = 0; 301 301 302 302 page_size = sysconf(_SC_PAGESIZE); 303 303 vec_size = FILE_SIZE / page_size; ··· 339 341 } 340 342 341 343 /* 342 - * Touch a page in the middle of the mapping. We expect only 343 - * that page to be fetched into memory. 344 + * Touch a page in the middle of the mapping. 344 345 */ 345 346 addr[FILE_SIZE / 2] = 1; 346 347 retval = mincore(addr, FILE_SIZE, vec); 347 348 ASSERT_EQ(0, retval); 348 349 ASSERT_EQ(1, vec[FILE_SIZE / 2 / page_size]) { 349 350 TH_LOG("Page not found in memory after use"); 350 - } 351 - 352 - i = FILE_SIZE / 2 / page_size + 1; 353 - while (i < vec_size && vec[i]) { 354 - ra_pages++; 355 - i++; 356 - } 357 - ASSERT_EQ(ra_pages, 0) { 358 - TH_LOG("Read-ahead pages found in memory"); 359 351 } 360 352 361 353 munmap(addr, FILE_SIZE);