Commit graph

8 commits

Author SHA1 Message Date
Michael Ellerman bc4d5f5d2d selftests: cachestat: Fix build warnings on ppc64
Fix warnings like:
  test_cachestat.c: In function ‘print_cachestat’:
  test_cachestat.c:30:38: warning: format ‘%llu’ expects argument of
  type ‘long long unsigned int’, but argument 2 has type ‘__u64’ {aka
  ‘long unsigned int’} [-Wformat=]

By switching to unsigned long long for u64 for ppc64 builds.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-05-29 12:24:44 -06:00
Maciej Wieczor-Retman 3aa779a9d1 selftests/cachestat: Fix print_cachestat format
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-10-13 14:08:10 -06:00
Linus Torvalds 5a31cc7297 linux-kselftest-next-6.6-rc1
This Kselftest update for Linux 6.6-rc1 consists of 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.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEPZKym/RZuOCGeA/kCwJExA0NQxwFAmTstk4ACgkQCwJExA0N
 QxxMWBAAlV9Ai38VFU/rGzCEIhgiXuLpHsonGqvKEGjZDWPxN004gMPEjyPyruPp
 YHMJUXsm3sqZRQimoPGB9vFXcdL2m3wYbUjaeRoqpFDjstmA0X1kGMshh+hteQxn
 PPF8Y8ZkTgzNU+ypt/1xF/Xdwyu+0xYEkKMHX2zkI87blVxUUt9CA84S8PjbKSXt
 JEQPGVlHAM4u881bGamUty/jbEbJpkuWXc7tMZfT2I5MT6gNwyOSs6bQwX2+XtBb
 IY+WdRbkl1/iz8BoFzfiIlMRobvsKyGIMBzPjM3GkypXKpqZfAjkw50ESOkErR2s
 MxHM6OjIRFnpvVmDQe+ZqfAWTysEeSrc1C01arn6voW7gdaPZaHhKgfS1egAVAbJ
 EY7R+eJsdLj9g0O3B6weC8PM//k+OPeyr8QMnn6npLpAAkit2oToO1SJx17c9ZpB
 6j1YaG9tgxETaGJEcS7OC21BQTgBH/MF7ALdMyxZFsHTAP3THJde4vEWpl5hojWD
 y/24bx3ZdSr+rgyXqNd8Ewk/e/+2zsJF3g2HmaTwBTBERhA7/qGgmpodCjG+byIy
 koKua1qEcPCp7I+so23bQF8Wcf3EFzCT6ADid0P0/rVymjdPBQJl5GLbKTrUIo32
 ZwDfIxL8Bu7XQBb3fJJzdLdkLUNAzFrR+y7FW7++TRI4Mr9oitg=
 =6fP4
 -----END PGP SIGNATURE-----

Merge tag 'linux-kselftest-next-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest

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-28 18:46:47 -07:00
Andre Przywara f84f62e699 selftests: cachestat: catch failing fsync test on tmpfs
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-24 14:59:47 -07:00
Andre Przywara 5e56982dd0 selftests: cachestat: test for cachestat availability
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-24 14:59:47 -07:00
Andre Przywara 9b1db73286 selftests: cachestat: use proper syscall number macro
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-16 11:12:44 -06:00
Andre Przywara 7fb10233e0 selftests: cachestat: properly link in librt
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-08-16 11:12:39 -06:00
Nhat Pham 88537aac0b selftests: add selftests for cachestat
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>
2023-06-09 16:25:17 -07:00