cachestat testing suite
v2 cover cachestat testing suite
This suite is adding covergae for the cachestat() syscall which is providing support for reading the file cache status and it has been added in the kernel 6.5.
There's not a man page yet, so please consider the following link as documentation:
https://lwn.net/Articles/917059/
---
Changes in v2:
- cachestat01: run test on multiple test pages
- remove cachestat01A
- cachestat02: run test on multiple test pages
- add new cachestat03 test
---
Andrea Cervesato (4):
Add cachestat fallback definitions
Add cachestat01 test
Add cachestat02 test
Add cachestat03 test
configure.ac | 4 + include/lapi/mman.h | 44 +++++++++ include/lapi/syscalls/aarch64.in | 1 + include/lapi/syscalls/arc.in | 1 + include/lapi/syscalls/arm.in | 1 + include/lapi/syscalls/hppa.in | 1 + include/lapi/syscalls/i386.in | 1 + include/lapi/syscalls/ia64.in | 1 + include/lapi/syscalls/loongarch.in | 1 + include/lapi/syscalls/mips_n32.in | 1 + include/lapi/syscalls/mips_n64.in | 1 + include/lapi/syscalls/mips_o32.in | 1 + include/lapi/syscalls/powerpc.in | 1 + include/lapi/syscalls/powerpc64.in | 1 + include/lapi/syscalls/s390.in | 1 + include/lapi/syscalls/s390x.in | 1 + include/lapi/syscalls/sh.in | 1 + include/lapi/syscalls/sparc.in | 1 + include/lapi/syscalls/sparc64.in | 1 + include/lapi/syscalls/x86_64.in | 1 + runtest/syscalls | 4 + testcases/kernel/syscalls/cachestat/.gitignore | 3 + testcases/kernel/syscalls/cachestat/Makefile | 10 +++ testcases/kernel/syscalls/cachestat/cachestat.h | 27 ++++++ testcases/kernel/syscalls/cachestat/cachestat01.c | 105 ++++++++++++++++++++++ testcases/kernel/syscalls/cachestat/cachestat02.c | 89 ++++++++++++++++++ testcases/kernel/syscalls/cachestat/cachestat03.c | 80 +++++++++++++++++ 27 files changed, 384 insertions(+)
---
base-commit: 87c632c8bfbb772efde047e83e72c215bfeb1aba
change-id: 20240515-cachestat-11fc82af07ec
Best regards,
Signature · 5 lines
Andrea Cervesato <[email protected]> -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 1/4 Add cachestat fallback definitions
From: Andrea Cervesato <[email protected]>
--- configure.ac | 4 ++++ include/lapi/mman.h | 44 ++++++++++++++++++++++++++++++++++++++ include/lapi/syscalls/aarch64.in | 1 + include/lapi/syscalls/arc.in | 1 + include/lapi/syscalls/arm.in | 1 + include/lapi/syscalls/hppa.in | 1 + include/lapi/syscalls/i386.in | 1 + include/lapi/syscalls/ia64.in | 1 + include/lapi/syscalls/loongarch.in | 1 + include/lapi/syscalls/mips_n32.in | 1 + include/lapi/syscalls/mips_n64.in | 1 + include/lapi/syscalls/mips_o32.in | 1 + include/lapi/syscalls/powerpc.in | 1 + include/lapi/syscalls/powerpc64.in | 1 + include/lapi/syscalls/s390.in | 1 + include/lapi/syscalls/s390x.in | 1 + include/lapi/syscalls/sh.in | 1 + include/lapi/syscalls/sparc.in | 1 + include/lapi/syscalls/sparc64.in | 1 + include/lapi/syscalls/x86_64.in | 1 + 20 files changed, 66 insertions(+)
configure.ac +4 -0
@@ -91,6 +91,7 @@ AC_SUBST(HAVE_FTS_H, $have_fts) AC_CHECK_HEADERS(linux/vm_sockets.h, [], [], [#include <sys/socket.h>]) AC_CHECK_FUNCS_ONCE([ \ + cachestat \ clone3 \ close_range \ copy_file_range \
@@ -243,6 +244,9 @@ AC_CHECK_TYPES([struct mount_attr],,,[ #endif ]) +AC_CHECK_TYPES([struct cachestat_range],,,[#include <sys/mman.h>]) +AC_CHECK_TYPES([struct cachestat],,,[#include <sys/mman.h>]) + # Tools knobs # Bash
include/lapi/mman.h new file +44 -0
44 lines not on this page · raw message
include/lapi/syscalls/aarch64.in +1 -0
@@ -300,4 +300,5 @@ landlock_create_ruleset 444 landlock_add_rule 445 landlock_restrict_self 446 futex_waitv 449 +cachestat 451 _sysctl 1078
include/lapi/syscalls/arc.in +1 -0
@@ -320,3 +320,4 @@ landlock_create_ruleset 444 landlock_add_rule 445 landlock_restrict_self 446 futex_waitv 449 +cachestat 451
include/lapi/syscalls/arm.in +1 -0
@@ -399,3 +399,4 @@ landlock_add_rule (__NR_SYSCALL_BASE+445) landlock_restrict_self (__NR_SYSCALL_BASE+446) memfd_secret (__NR_SYSCALL_BASE+447) futex_waitv (__NR_SYSCALL_BASE+449) +cachestat (__NR_SYSCALL_BASE+451)
include/lapi/syscalls/hppa.in +1 -0
@@ -47,3 +47,4 @@ landlock_create_ruleset 444 landlock_add_rule 445 landlock_restrict_self 446 futex_waitv 449 +cachestat 451
include/lapi/syscalls/i386.in +1 -0
@@ -434,3 +434,4 @@ landlock_create_ruleset 444 landlock_add_rule 445 landlock_restrict_self 446 futex_waitv 449 +cachestat 451
include/lapi/syscalls/ia64.in +1 -0
@@ -347,3 +347,4 @@ landlock_create_ruleset 1468 landlock_add_rule 1469 landlock_restrict_self 1470 futex_waitv 1473 +cachestat 1475
include/lapi/syscalls/loongarch.in +1 -0
@@ -305,3 +305,4 @@ memfd_secret 447 process_mrelease 448 futex_waitv 449 set_mempolicy_home_node 450 +cachestat 451
include/lapi/syscalls/mips_n32.in +1 -0
@@ -374,3 +374,4 @@ landlock_create_ruleset 6444 landlock_add_rule 6445 landlock_restrict_self 6446 futex_waitv 6449 +cachestat 6451
include/lapi/syscalls/mips_n64.in +1 -0
@@ -350,3 +350,4 @@ landlock_create_ruleset 5444 landlock_add_rule 5445 landlock_restrict_self 5446 futex_waitv 5449 +cachestat 5451
include/lapi/syscalls/mips_o32.in +1 -0
@@ -420,3 +420,4 @@ landlock_create_ruleset 4444 landlock_add_rule 4445 landlock_restrict_self 4446 futex_waitv 4449 +cachestat 4451
include/lapi/syscalls/powerpc.in +1 -0
@@ -427,3 +427,4 @@ landlock_create_ruleset 444 landlock_add_rule 445 landlock_restrict_self 446 futex_waitv 449 +cachestat 451
include/lapi/syscalls/powerpc64.in +1 -0
@@ -427,3 +427,4 @@ landlock_create_ruleset 444 landlock_add_rule 445 landlock_restrict_self 446 futex_waitv 449 +cachestat 451
include/lapi/syscalls/s390.in +1 -0
@@ -414,3 +414,4 @@ landlock_create_ruleset 444 landlock_add_rule 445 landlock_restrict_self 446 futex_waitv 449 +cachestat 451
include/lapi/syscalls/s390x.in +1 -0
@@ -362,3 +362,4 @@ landlock_create_ruleset 444 landlock_add_rule 445 landlock_restrict_self 446 futex_waitv 449 +cachestat 451
include/lapi/syscalls/sh.in +1 -0
@@ -408,3 +408,4 @@ landlock_create_ruleset 444 landlock_add_rule 445 landlock_restrict_self 446 futex_waitv 449 +cachestat 451
include/lapi/syscalls/sparc.in +1 -0
@@ -413,3 +413,4 @@ landlock_create_ruleset 444 landlock_add_rule 445 landlock_restrict_self 446 futex_waitv 449 +cachestat 451
include/lapi/syscalls/sparc64.in +1 -0
@@ -378,3 +378,4 @@ landlock_create_ruleset 444 landlock_add_rule 445 landlock_restrict_self 446 futex_waitv 449 +cachestat 451
include/lapi/syscalls/x86_64.in +1 -0
@@ -355,6 +355,7 @@ landlock_create_ruleset 444 landlock_add_rule 445 landlock_restrict_self 446 futex_waitv 449 +cachestat 451 rt_sigaction 512 rt_sigreturn 513 ioctl 514
Signature · 5 lines
2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 2/4 Add cachestat01 test
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
This test verifies that cachestat() syscall is properly counting cached pages written inside a file. If storage device synchronization is requested, test will check if the number of dirty pages is zero.
--- runtest/syscalls | 2 + testcases/kernel/syscalls/cachestat/.gitignore | 1 + testcases/kernel/syscalls/cachestat/Makefile | 10 +++ testcases/kernel/syscalls/cachestat/cachestat.h | 27 ++++++ testcases/kernel/syscalls/cachestat/cachestat01.c | 105 ++++++++++++++++++++++ 5 files changed, 145 insertions(+)
runtest/syscalls +2 -0
@@ -62,6 +62,8 @@ capset04 capset04 cacheflush01 cacheflush01 +cachestat01 cachestat01 + chdir01 chdir01 chdir01A symlink01 -T chdir01 chdir04 chdir04
testcases/kernel/syscalls/cachestat/.gitignore new file +1 -0
@@ -0,0 +1 @@ +cachestat01
testcases/kernel/syscalls/cachestat/Makefile new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2024 SUSE LLC Andrea Cervesato <[email protected]> + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk + +LDLIBS += -lrt + +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/cachestat/cachestat.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Copyright (C) 2024 SUSE LLC Andrea Cervesato <[email protected]> +*/ + +#ifndef CACHESTAT_H__ +#define CACHESTAT_H__ + +#include "tst_test.h" +#include "lapi/mman.h" + +static inline void print_cachestat (struct cachestat *cs) +{ +tst_res (TDEBUG , +"nr_cache=%lu " +"nr_dirty=%lu " +"nr_writeback=%lu " +"nr_evicted=%lu " +"nr_recently_evicted=%lu" , + cs->nr_cache, + cs->nr_dirty, + cs->nr_writeback, + cs->nr_evicted, + cs->nr_recently_evicted); +} + +#endif
testcases/kernel/syscalls/cachestat/cachestat01.c new file +105 -0
105 lines not on this page · raw message
Signature · 5 lines
2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 3/4 Add cachestat02 test
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
This test verifies that cachestat() syscall is properly counting cached pages written inside a shared memory.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/cachestat/.gitignore | 1 + testcases/kernel/syscalls/cachestat/cachestat02.c | 89 +++++++++++++++++++++++ 3 files changed, 91 insertions(+)
runtest/syscalls +1 -0
@@ -63,6 +63,7 @@ capset04 capset04 cacheflush01 cacheflush01 cachestat01 cachestat01 +cachestat02 cachestat02 chdir01 chdir01 chdir01A symlink01 -T chdir01
testcases/kernel/syscalls/cachestat/.gitignore +1 -0
@@ -1 +1,2 @@ cachestat01 +cachestat02
testcases/kernel/syscalls/cachestat/cachestat02.c new file +89 -0
89 lines not on this page · raw message
Signature · 5 lines
2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 4/4 Add cachestat03 test
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
This test verifies that cachestat() syscall is properly failing with relative error codes according to input parameters.
- EFAULT: cstat or cstat_range points to an illegal address
- EINVAL: invalid flags
- EBADF: invalid file descriptor
- EOPNOTSUPP: file descriptor is of a hugetlbfs file
--- runtest/syscalls | 1 + testcases/kernel/syscalls/cachestat/.gitignore | 1 + testcases/kernel/syscalls/cachestat/cachestat03.c | 80 +++++++++++++++++++++++ 3 files changed, 82 insertions(+)
runtest/syscalls +1 -0
@@ -64,6 +64,7 @@ cacheflush01 cacheflush01 cachestat01 cachestat01 cachestat02 cachestat02 +cachestat03 cachestat03 chdir01 chdir01 chdir01A symlink01 -T chdir01
testcases/kernel/syscalls/cachestat/.gitignore +1 -0
@@ -1,2 +1,3 @@ cachestat01 cachestat02 +cachestat03
testcases/kernel/syscalls/cachestat/cachestat03.c new file +80 -0
80 lines not on this page · raw message
Signature · 5 lines
2.43.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp