aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/testing/selftests/cachestat (follow)
AgeCommit message (Collapse)AuthorFilesLines
2023-10-13selftests/cachestat: Fix print_cachestat formatMaciej Wieczor-Retman1-1/+1
Compiling cachestat selftest after adding a __printf() attribute to ksft_print_msg() exposes a -Wformat warning in print_cachestat(). The format specifier in printf() call expects long int variables and received long long int. Change format specifiers to long long int so they match passed variables. Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com> Acked-by: Nhat Pham <nphamcs@gmail.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2023-08-28Merge tag 'linux-kselftest-next-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftestLinus Torvalds2-5/+4
Pull Kselftest updates from Shuah Khan: "A mix of fixes, enhancements, and new tests. Bulk of the changes enhance and fix rseq and resctrl tests. In addition, user_events, dmabuf-heaps and perf_events are added to default kselftest build and test coverage. A futex test fix, enhance prctl test coverage, and minor fixes are included in this update" * tag 'linux-kselftest-next-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: (32 commits) selftests: cachestat: use proper syscall number macro selftests: cachestat: properly link in librt selftests/futex: Order calls to futex_lock_pi selftests: Hook more tests into the build infrastructure selftests/user_events: Reenable build selftests/filesystems: Add six consecutive 'x' characters to mktemp selftests/rseq: Use rseq_unqual_scalar_typeof in macros selftests/rseq: Fix arm64 buggy load-acquire/store-release macros selftests/rseq: Implement rseq_unqual_scalar_typeof selftests/rseq: Fix CID_ID typo in Makefile selftests:prctl: add set-process-name to .gitignore selftests:prctl: Fix make clean override warning selftests/resctrl: Remove test type checks from cat_val() selftests/resctrl: Pass the real number of tests to show_cache_info() selftests/resctrl: Move CAT/CMT test global vars to function they are used in selftests/resctrl: Don't use variable argument list for ->setup() selftests/resctrl: Don't pass test name to fill_buf selftests/resctrl: Improve parameter consistency in fill_buf selftests/resctrl: Remove unnecessary startptr global from fill_buf selftests/resctrl: Remove "malloc_and_init_memory" param from run_fill_buf() ...
2023-08-24selftests: cachestat: catch failing fsync test on tmpfsAndre Przywara1-15/+47
The cachestat kselftest runs a test on a normal file, which is created temporarily in the current directory. Among the tests it runs there is a call to fsync(), which is expected to clean all dirty pages used by the file. However the tmpfs filesystem implements fsync() as noop_fsync(), so the call will not even attempt to clean anything when this test file happens to live on a tmpfs instance. This happens in an initramfs, or when the current directory is in /dev/shm or sometimes /tmp. To avoid this test failing wrongly, use statfs() to check which filesystem the test file lives on. If that is "tmpfs", we skip the fsync() test. Since the fsync test is only one part of the "normal file" test, we now execute this twice, skipping the fsync part on the first call. This way only the second test, including the fsync part, would be skipped. Link: https://lkml.kernel.org/r/20230821160534.3414911-3-andre.przywara@arm.com Signed-off-by: Andre Przywara <andre.przywara@arm.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Nhat Pham <nphamcs@gmail.com> Cc: Shuah Khan <shuah@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2023-08-24selftests: cachestat: test for cachestat availabilityAndre Przywara1-1/+19
Patch series "selftests: cachestat: fix run on older kernels", v2. I ran all kernel selftests on some test machine, and stumbled upon cachestat failing (among others). These patches fix the run on older kernels and when the current directory is on a tmpfs instance. This patch (of 2): As cachestat is a new syscall, it won't be available on older kernels, for instance those running on a development machine. At the moment the test reports all tests as "not ok" in this case. Test for the cachestat syscall availability first, before doing further tests, and bail out early with a TAP SKIP comment. This also uses the opportunity to add the proper TAP headers, and add one check for proper error handling (illegal file descriptor). Link: https://lkml.kernel.org/r/20230821160534.3414911-1-andre.przywara@arm.com Link: https://lkml.kernel.org/r/20230821160534.3414911-2-andre.przywara@arm.com Signed-off-by: Andre Przywara <andre.przywara@arm.com> Acked-by: Nhat Pham <nphamcs@gmail.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Shuah Khan <shuah@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2023-08-16selftests: cachestat: use proper syscall number macroAndre Przywara1-4/+3
At the moment the cachestat syscall number is hard coded into the test source code. Remove that and replace it with the proper __NR_cachestat macro. That ensures compatibility should other architectures pick a different number. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Reviewed-by: Nhat Pham <nphamcs@gmail.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2023-08-16selftests: cachestat: properly link in librtAndre Przywara1-1/+1
Libraries should be listed last on the compiler's command line, so that the linker can look for and find still unresolved symbols. The librt library, required for the shm_* functions, was announced using CFLAGS, which puts the library *before* the source files, and fails compilation on my system: ====================== gcc -isystem /src/linux-selftests/usr/include -Wall -lrt test_cachestat.c -o /src/linux-selftests/kselftest/cachestat/test_cachestat /usr/bin/ld: /tmp/cceQWO3u.o: in function `test_cachestat_shmem': test_cachestat.c:(.text+0x890): undefined reference to `shm_open' /usr/bin/ld: test_cachestat.c:(.text+0x99c): undefined reference to `shm_unlink' collect2: error: ld returned 1 exit status make[4]: *** [../lib.mk:181: /src/linux-selftests/kselftest/cachestat/test_cachestat] Error 1 ====================== Announce the library using the LDLIBS variable, which ensures the proper ordering on the command line. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2023-06-09selftests: add selftests for cachestatNhat Pham3-0/+279
Test cachestat on a newly created file, /dev/ files, /proc/ files and a directory. Also test on a shmem file (which can also be tested with huge pages since tmpfs supports huge pages). [colin.i.king@gmail.com: fix spelling mistake "trucate" -> "truncate"] Link: https://lkml.kernel.org/r/20230505110855.2493457-1-colin.i.king@gmail.com [mpe@ellerman.id.au: avoid excessive stack allocation] Link: https://lkml.kernel.org/r/877ctfa6yv.fsf@mail.lhotse Link: https://lkml.kernel.org/r/20230503013608.2431726-4-nphamcs@gmail.com Signed-off-by: Nhat Pham <nphamcs@gmail.com> Signed-off-by: Colin Ian King <colin.i.king@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Cc: Brian Foster <bfoster@redhat.com> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Michael Kerrisk <mtk.manpages@gmail.com> Cc: Colin Ian King <colin.i.king@gmail.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>