Skip to content

Commit 8c583e5

Browse files
Baolin Wangakpm00
authored andcommitted
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: d635ccd ("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>
1 parent aabf58b commit 8c583e5

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

tools/testing/selftests/mincore/mincore_selftest.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,7 @@ TEST(check_file_mmap)
286286

287287
/*
288288
* 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.
291290
*/
292291
TEST(check_tmpfs_mmap)
293292
{
@@ -298,7 +297,6 @@ TEST(check_tmpfs_mmap)
298297
int page_size;
299298
int fd;
300299
int i;
301-
int ra_pages = 0;
302300

303301
page_size = sysconf(_SC_PAGESIZE);
304302
vec_size = FILE_SIZE / page_size;
@@ -341,8 +339,7 @@ TEST(check_tmpfs_mmap)
341339
}
342340

343341
/*
344-
* Touch a page in the middle of the mapping. We expect only
345-
* that page to be fetched into memory.
342+
* Touch a page in the middle of the mapping.
346343
*/
347344
addr[FILE_SIZE / 2] = 1;
348345
retval = mincore(addr, FILE_SIZE, vec);
@@ -351,15 +348,6 @@ TEST(check_tmpfs_mmap)
351348
TH_LOG("Page not found in memory after use");
352349
}
353350

354-
i = FILE_SIZE / 2 / page_size + 1;
355-
while (i < vec_size && vec[i]) {
356-
ra_pages++;
357-
i++;
358-
}
359-
ASSERT_EQ(ra_pages, 0) {
360-
TH_LOG("Read-ahead pages found in memory");
361-
}
362-
363351
munmap(addr, FILE_SIZE);
364352
close(fd);
365353
free(vec);

0 commit comments

Comments
 (0)