From patchwork Mon Jul 15 12:18:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1960635 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=BvZT+3r7; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=7bj0srRn; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=BvZT+3r7; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=7bj0srRn; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WN1Vm0bGcz1xqc for ; Mon, 15 Jul 2024 22:20:16 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id CD0463D1A27 for ; Mon, 15 Jul 2024 14:20:13 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [217.194.8.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 782FF3D1A2D for ; Mon, 15 Jul 2024 14:19:00 +0200 (CEST) Authentication-Results: in-5.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=195.135.223.131; helo=smtp-out2.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id 98B6F600F27 for ; Mon, 15 Jul 2024 14:18:56 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id AE0F71F812; Mon, 15 Jul 2024 12:18:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1721045935; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0hglHsjkXTMTxCM2mDFYEW/BeBCveLRO99csbWHIVPM=; b=BvZT+3r7GGHMGxRXVrr43xJ7CmrrcjE3Z7lB3/vOqp9mg50+KwrA45Wnn5hsD71sDOmdvP sy93lZUWmr/MRk8iOd+iv6bYg0DHu9fNAI4RoXE02U6aMbmWoVzcyFP6X1KlCVhAlTwDSj hrlrRx+nSlnHJdgwKtpIaPzywOB12TY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1721045935; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0hglHsjkXTMTxCM2mDFYEW/BeBCveLRO99csbWHIVPM=; b=7bj0srRnorpvIbuhu7Hb2n7TQmO/a/+bOtl9MG6VLVhlnxozFtc3NIOVoBSIAyHStVoqv5 YdVti4uU4wV/C3Cg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1721045935; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0hglHsjkXTMTxCM2mDFYEW/BeBCveLRO99csbWHIVPM=; b=BvZT+3r7GGHMGxRXVrr43xJ7CmrrcjE3Z7lB3/vOqp9mg50+KwrA45Wnn5hsD71sDOmdvP sy93lZUWmr/MRk8iOd+iv6bYg0DHu9fNAI4RoXE02U6aMbmWoVzcyFP6X1KlCVhAlTwDSj hrlrRx+nSlnHJdgwKtpIaPzywOB12TY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1721045935; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0hglHsjkXTMTxCM2mDFYEW/BeBCveLRO99csbWHIVPM=; b=7bj0srRnorpvIbuhu7Hb2n7TQmO/a/+bOtl9MG6VLVhlnxozFtc3NIOVoBSIAyHStVoqv5 YdVti4uU4wV/C3Cg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 90C011395F; Mon, 15 Jul 2024 12:18:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id mPX6Ia8TlWbpQAAAD6G6ig (envelope-from ); Mon, 15 Jul 2024 12:18:55 +0000 From: Andrea Cervesato Date: Mon, 15 Jul 2024 14:18:32 +0200 MIME-Version: 1.0 Message-Id: <20240715-cachestat-v2-1-55817ad1a408@suse.com> References: <20240715-cachestat-v2-0-55817ad1a408@suse.com> In-Reply-To: <20240715-cachestat-v2-0-55817ad1a408@suse.com> To: ltp@lists.linux.it X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=8837; i=andrea.cervesato@suse.com; h=from:subject:message-id; bh=WNwA8kzJq2jKIaz7O4NBI3BpxhOOY1R8ZYipZCzbrms=; b=owEB7QES/pANAwAIAcvMGrIgs+ZGAcsmYgBmlROgU2zyrYE7PnlbTdJqmwmqGov9o+fhpRh4v dUGjvUMSz+JAbMEAAEIAB0WIQT1ysFzUKRW0sIb39jLzBqyILPmRgUCZpUToAAKCRDLzBqyILPm RqSKDACYdDOMTyz/Xuz1+zzRNHsVvYcvwHoziY3X8B0RzasU3OmWHMZCszXnoPM0tkpZcjYmpbQ na6rMJS2twm+jUxSDLJ4GRKfv4HXPn/5AxRiA3Ep05coaG8RZsnwubRJstCueQ4D37xC7IZZS4s WRUTIC4NFho1NWfPTiW/t5UcKIxUdbklTz/1SwrKYW8TwYb3GxuC40OhaTGIl4lKbrZqj4Q1Gpc 0W29QAiFW3gT0Cs+QOMTaNzGQit2NT3WdmBa5RnSvMElNvrh2kcycjoWvAEX+Q1vfWXWx33gCcz k+Oi8XU7HKvnjm656tU1toiwqalGnHC+frbSg3qZzCBnMreIaAQfTlwycM2MXwr/k1OIVb9v5iB iO1JbLgi0oAXJnmXdr7dnMusCO+9+0HBPKsXGqGPYteFQ2Y/G2oxan+jnQFXmhgXmx3eAoInwXJ TKI/mLIGXN40kHegm+RTSHJ5yuyeK3eBV8yO+tfktGFkbidxn2ecYpfv7WDlFH3pzAmoQ= X-Developer-Key: i=andrea.cervesato@suse.com; a=openpgp; fpr=F5CAC17350A456D2C21BDFD8CBCC1AB220B3E646 X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-0.998]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,imap1.dmz-prg2.suse.org:helo] X-Spam-Score: -4.30 X-Spam-Level: X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-5.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-5.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v2 1/4] Add cachestat fallback definitions X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato Signed-off-by: Andrea Cervesato --- 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(+) diff --git a/configure.ac b/configure.ac index 1f8796c87..cbcf308e5 100644 --- a/configure.ac +++ b/configure.ac @@ -91,6 +91,7 @@ AC_SUBST(HAVE_FTS_H, $have_fts) AC_CHECK_HEADERS(linux/vm_sockets.h, [], [], [#include ]) 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 ]) +AC_CHECK_TYPES([struct cachestat],,,[#include ]) + # Tools knobs # Bash diff --git a/include/lapi/mman.h b/include/lapi/mman.h new file mode 100644 index 000000000..244ad9f31 --- /dev/null +++ b/include/lapi/mman.h @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2024 SUSE LLC Andrea Cervesato + */ + +#ifndef LAPI_MMAN_H__ +#define LAPI_MMAN_H__ + +#include +#include +#include "config.h" +#include "syscalls.h" + +#ifndef HAVE_STRUCT_CACHESTAT_RANGE +struct cachestat_range { + uint64_t off; + uint64_t len; +}; +#endif + +#ifndef HAVE_STRUCT_CACHESTAT +struct cachestat { + uint64_t nr_cache; + uint64_t nr_dirty; + uint64_t nr_writeback; + uint64_t nr_evicted; + uint64_t nr_recently_evicted; +}; +#endif + +#ifndef HAVE_CACHESTAT +/* + * cachestat: wrapper function of cachestat + * + * Returns: It returns status of cachestat syscall + */ +static inline int cachestat(int fd, struct cachestat_range *cstat_range, + struct cachestat *cstat, unsigned int flags) +{ + return tst_syscall(__NR_cachestat, fd, cstat_range, cstat, flags); +} +#endif + +#endif /* LAPI_MMAN_H__ */ diff --git a/include/lapi/syscalls/aarch64.in b/include/lapi/syscalls/aarch64.in index 3e7797718..ef0aa04a3 100644 --- a/include/lapi/syscalls/aarch64.in +++ b/include/lapi/syscalls/aarch64.in @@ -300,4 +300,5 @@ landlock_create_ruleset 444 landlock_add_rule 445 landlock_restrict_self 446 futex_waitv 449 +cachestat 451 _sysctl 1078 diff --git a/include/lapi/syscalls/arc.in b/include/lapi/syscalls/arc.in index 7fde1d263..3eaa6a8f1 100644 --- a/include/lapi/syscalls/arc.in +++ b/include/lapi/syscalls/arc.in @@ -320,3 +320,4 @@ landlock_create_ruleset 444 landlock_add_rule 445 landlock_restrict_self 446 futex_waitv 449 +cachestat 451 diff --git a/include/lapi/syscalls/arm.in b/include/lapi/syscalls/arm.in index 8e76ad164..b52a32b6b 100644 --- a/include/lapi/syscalls/arm.in +++ b/include/lapi/syscalls/arm.in @@ -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) diff --git a/include/lapi/syscalls/hppa.in b/include/lapi/syscalls/hppa.in index 60c02aff2..4919ee65d 100644 --- a/include/lapi/syscalls/hppa.in +++ b/include/lapi/syscalls/hppa.in @@ -47,3 +47,4 @@ landlock_create_ruleset 444 landlock_add_rule 445 landlock_restrict_self 446 futex_waitv 449 +cachestat 451 diff --git a/include/lapi/syscalls/i386.in b/include/lapi/syscalls/i386.in index 31ec1ecb2..cff40957a 100644 --- a/include/lapi/syscalls/i386.in +++ b/include/lapi/syscalls/i386.in @@ -434,3 +434,4 @@ landlock_create_ruleset 444 landlock_add_rule 445 landlock_restrict_self 446 futex_waitv 449 +cachestat 451 diff --git a/include/lapi/syscalls/ia64.in b/include/lapi/syscalls/ia64.in index 2e56da7f9..11d4b46f4 100644 --- a/include/lapi/syscalls/ia64.in +++ b/include/lapi/syscalls/ia64.in @@ -347,3 +347,4 @@ landlock_create_ruleset 1468 landlock_add_rule 1469 landlock_restrict_self 1470 futex_waitv 1473 +cachestat 1475 diff --git a/include/lapi/syscalls/loongarch.in b/include/lapi/syscalls/loongarch.in index 301f611f6..9bf6a7deb 100644 --- a/include/lapi/syscalls/loongarch.in +++ b/include/lapi/syscalls/loongarch.in @@ -305,3 +305,4 @@ memfd_secret 447 process_mrelease 448 futex_waitv 449 set_mempolicy_home_node 450 +cachestat 451 diff --git a/include/lapi/syscalls/mips_n32.in b/include/lapi/syscalls/mips_n32.in index 5f0fe65eb..a76c82593 100644 --- a/include/lapi/syscalls/mips_n32.in +++ b/include/lapi/syscalls/mips_n32.in @@ -374,3 +374,4 @@ landlock_create_ruleset 6444 landlock_add_rule 6445 landlock_restrict_self 6446 futex_waitv 6449 +cachestat 6451 diff --git a/include/lapi/syscalls/mips_n64.in b/include/lapi/syscalls/mips_n64.in index f81c60e66..df991efd5 100644 --- a/include/lapi/syscalls/mips_n64.in +++ b/include/lapi/syscalls/mips_n64.in @@ -350,3 +350,4 @@ landlock_create_ruleset 5444 landlock_add_rule 5445 landlock_restrict_self 5446 futex_waitv 5449 +cachestat 5451 diff --git a/include/lapi/syscalls/mips_o32.in b/include/lapi/syscalls/mips_o32.in index c2beffb75..826b7d66e 100644 --- a/include/lapi/syscalls/mips_o32.in +++ b/include/lapi/syscalls/mips_o32.in @@ -420,3 +420,4 @@ landlock_create_ruleset 4444 landlock_add_rule 4445 landlock_restrict_self 4446 futex_waitv 4449 +cachestat 4451 diff --git a/include/lapi/syscalls/powerpc.in b/include/lapi/syscalls/powerpc.in index 5460e4197..798ed9050 100644 --- a/include/lapi/syscalls/powerpc.in +++ b/include/lapi/syscalls/powerpc.in @@ -427,3 +427,4 @@ landlock_create_ruleset 444 landlock_add_rule 445 landlock_restrict_self 446 futex_waitv 449 +cachestat 451 diff --git a/include/lapi/syscalls/powerpc64.in b/include/lapi/syscalls/powerpc64.in index 5460e4197..798ed9050 100644 --- a/include/lapi/syscalls/powerpc64.in +++ b/include/lapi/syscalls/powerpc64.in @@ -427,3 +427,4 @@ landlock_create_ruleset 444 landlock_add_rule 445 landlock_restrict_self 446 futex_waitv 449 +cachestat 451 diff --git a/include/lapi/syscalls/s390.in b/include/lapi/syscalls/s390.in index 275b27f47..126938095 100644 --- a/include/lapi/syscalls/s390.in +++ b/include/lapi/syscalls/s390.in @@ -414,3 +414,4 @@ landlock_create_ruleset 444 landlock_add_rule 445 landlock_restrict_self 446 futex_waitv 449 +cachestat 451 diff --git a/include/lapi/syscalls/s390x.in b/include/lapi/syscalls/s390x.in index c200d02b2..18f2496a0 100644 --- a/include/lapi/syscalls/s390x.in +++ b/include/lapi/syscalls/s390x.in @@ -362,3 +362,4 @@ landlock_create_ruleset 444 landlock_add_rule 445 landlock_restrict_self 446 futex_waitv 449 +cachestat 451 diff --git a/include/lapi/syscalls/sh.in b/include/lapi/syscalls/sh.in index 6f482a77b..ae6f26050 100644 --- a/include/lapi/syscalls/sh.in +++ b/include/lapi/syscalls/sh.in @@ -408,3 +408,4 @@ landlock_create_ruleset 444 landlock_add_rule 445 landlock_restrict_self 446 futex_waitv 449 +cachestat 451 diff --git a/include/lapi/syscalls/sparc.in b/include/lapi/syscalls/sparc.in index 7181e80a0..409fa2729 100644 --- a/include/lapi/syscalls/sparc.in +++ b/include/lapi/syscalls/sparc.in @@ -413,3 +413,4 @@ landlock_create_ruleset 444 landlock_add_rule 445 landlock_restrict_self 446 futex_waitv 449 +cachestat 451 diff --git a/include/lapi/syscalls/sparc64.in b/include/lapi/syscalls/sparc64.in index c96ab2021..e13cf163e 100644 --- a/include/lapi/syscalls/sparc64.in +++ b/include/lapi/syscalls/sparc64.in @@ -378,3 +378,4 @@ landlock_create_ruleset 444 landlock_add_rule 445 landlock_restrict_self 446 futex_waitv 449 +cachestat 451 diff --git a/include/lapi/syscalls/x86_64.in b/include/lapi/syscalls/x86_64.in index 3082ca110..05b1bee55 100644 --- a/include/lapi/syscalls/x86_64.in +++ b/include/lapi/syscalls/x86_64.in @@ -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 From patchwork Mon Jul 15 12:18:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1960633 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=UeHP1BAI; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=jUHJCM0o; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=UeHP1BAI; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=jUHJCM0o; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WN1Tz6p7Zz1xr4 for ; Mon, 15 Jul 2024 22:19:35 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id BA23B3D1A34 for ; Mon, 15 Jul 2024 14:19:33 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [217.194.8.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 669BB3D1A1A for ; Mon, 15 Jul 2024 14:18:57 +0200 (CEST) Authentication-Results: in-6.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=195.135.223.130; helo=smtp-out1.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 9B1FB1400F53 for ; Mon, 15 Jul 2024 14:18:56 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id C645B21BAC; Mon, 15 Jul 2024 12:18:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1721045935; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6noSyKEmLlKMtB5lz0RpacqF7sOAOZZNw/gLPdVk4+8=; b=UeHP1BAIJwG/5Et80Tok1c9JZci71k2QzHZzFRUwb4WX72nX09kZ7pVvKttoVlPAPUPRdQ BhKoCUPi5+yXQ8Wo1TtzOPRjiEo3gQmTo/tdjq57Ca3HmBJ0a0+lL5rFw+izAoTSy3EsMD cr3nhun9ZXbWfV4t0Etq8YIrv2rwJoA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1721045935; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6noSyKEmLlKMtB5lz0RpacqF7sOAOZZNw/gLPdVk4+8=; b=jUHJCM0ogAn3FnBg33Sy7pHQCOsx19U95/SZCKI2SPDst4J+Ner8VbViWEU7s1JTUw4XVr UUFUcqIMmB68wIAA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=UeHP1BAI; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=jUHJCM0o DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1721045935; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6noSyKEmLlKMtB5lz0RpacqF7sOAOZZNw/gLPdVk4+8=; b=UeHP1BAIJwG/5Et80Tok1c9JZci71k2QzHZzFRUwb4WX72nX09kZ7pVvKttoVlPAPUPRdQ BhKoCUPi5+yXQ8Wo1TtzOPRjiEo3gQmTo/tdjq57Ca3HmBJ0a0+lL5rFw+izAoTSy3EsMD cr3nhun9ZXbWfV4t0Etq8YIrv2rwJoA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1721045935; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6noSyKEmLlKMtB5lz0RpacqF7sOAOZZNw/gLPdVk4+8=; b=jUHJCM0ogAn3FnBg33Sy7pHQCOsx19U95/SZCKI2SPDst4J+Ner8VbViWEU7s1JTUw4XVr UUFUcqIMmB68wIAA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id ADEF51396E; Mon, 15 Jul 2024 12:18:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 4EUVKa8TlWbpQAAAD6G6ig (envelope-from ); Mon, 15 Jul 2024 12:18:55 +0000 From: Andrea Cervesato Date: Mon, 15 Jul 2024 14:18:33 +0200 MIME-Version: 1.0 Message-Id: <20240715-cachestat-v2-2-55817ad1a408@suse.com> References: <20240715-cachestat-v2-0-55817ad1a408@suse.com> In-Reply-To: <20240715-cachestat-v2-0-55817ad1a408@suse.com> To: ltp@lists.linux.it X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5371; i=andrea.cervesato@suse.com; h=from:subject:message-id; bh=YAIU2MG2YQlXMwj3T9mJqXxru//ySlRPGssw2JOLGgQ=; b=owEB7QES/pANAwAIAcvMGrIgs+ZGAcsmYgBmlROggzdjGmBlz7MQTw1vEGo4hBuV7++7NdTxc gaU/OboqzqJAbMEAAEIAB0WIQT1ysFzUKRW0sIb39jLzBqyILPmRgUCZpUToAAKCRDLzBqyILPm RrXVC/9Qkv/lmYBBI/FibXEdSJNyp1woMmm+T0dG8L41xFQJ8CiZ+SKfKjt5T4L9Qo4e70nJyeB DZcpYRNo6mRVHmiM6kDrRagG+CHDR7BBe/FS84iQp33uDJ9SDnV9JsCXlb+nAZDGu91cZfFAjyf uKroPJqUScdPNwtFpQq8RFbdavf3KX8SGp4EgdOdKJ113SZsUOOkkti0E3fMksvJmznyC/Qrvoo QovQkIl0SEQEKtIGNbvqQPLTxkhmtRxIM4XBOIU4Ne6X4IDOR7BH6qbFfKIRyZ7eaBYn5mMFR/l 3Tgw+u4B6NwEL2RCc2NPZdoRtJS07OS2SlODcI+Qxznk50S/luIfGnPvkTL/QVhRDRWwrUOd8X0 mL2RTneJNh86zsOU/+ClgzkRhxQdHQAQmglBF0Yzr7xSF1PZ55TQZ4vPWc3Yf4lAX0TlDy0gyTf ZhuBDYeNMm4PbKEUMxc9EemJttlO8SOJzzxTtHTdLr8n4x7G3icA1iEBdzXRSnHOdlP/A= X-Developer-Key: i=andrea.cervesato@suse.com; a=openpgp; fpr=F5CAC17350A456D2C21BDFD8CBCC1AB220B3E646 X-Rspamd-Queue-Id: C645B21BAC X-Spamd-Result: default: False [-1.51 / 50.00]; DWL_DNSWL_LOW(-1.00)[suse.de:dkim]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCPT_COUNT_TWO(0.00)[2]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.com:email]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:106:10:150:64:167:received]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Spam-Score: -1.51 X-Spam-Level: X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-6.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-6.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v2 2/4] Add cachestat01 test X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato 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. Signed-off-by: Andrea Cervesato --- 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(+) diff --git a/runtest/syscalls b/runtest/syscalls index 136fd03fa..9a1827e88 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -62,6 +62,8 @@ capset04 capset04 cacheflush01 cacheflush01 +cachestat01 cachestat01 + chdir01 chdir01 chdir01A symlink01 -T chdir01 chdir04 chdir04 diff --git a/testcases/kernel/syscalls/cachestat/.gitignore b/testcases/kernel/syscalls/cachestat/.gitignore new file mode 100644 index 000000000..daea1f4be --- /dev/null +++ b/testcases/kernel/syscalls/cachestat/.gitignore @@ -0,0 +1 @@ +cachestat01 diff --git a/testcases/kernel/syscalls/cachestat/Makefile b/testcases/kernel/syscalls/cachestat/Makefile new file mode 100644 index 000000000..62b00d2f4 --- /dev/null +++ b/testcases/kernel/syscalls/cachestat/Makefile @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2024 SUSE LLC Andrea Cervesato + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk + +LDLIBS += -lrt + +include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/kernel/syscalls/cachestat/cachestat.h b/testcases/kernel/syscalls/cachestat/cachestat.h new file mode 100644 index 000000000..efce6dc7f --- /dev/null +++ b/testcases/kernel/syscalls/cachestat/cachestat.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2024 SUSE LLC Andrea Cervesato + */ + +#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 diff --git a/testcases/kernel/syscalls/cachestat/cachestat01.c b/testcases/kernel/syscalls/cachestat/cachestat01.c new file mode 100644 index 000000000..2e44b2507 --- /dev/null +++ b/testcases/kernel/syscalls/cachestat/cachestat01.c @@ -0,0 +1,105 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2024 SUSE LLC Andrea Cervesato + */ + +/*\ + * [Description] + * + * 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. + * + * [Algorithm] + * + * - create a file with specific amount of pages + * - synchronize storage device, if needed + * - monitor file with cachestat() + * - check if the right amount of pages have been moved into cache + * - if storage device synchronization is requested, check that dirty pages is + * zero + */ + +#include "cachestat.h" + +#define MNTPOINT "mntpoint" +#define FILENAME MNTPOINT "/myfile.bin" + +static int page_size; +static char *page_data; +static struct cachestat *cs; +static struct cachestat_range *cs_range; + +static void test_cached_pages(const unsigned int use_sync, const int num_pages) +{ + int fd; + + tst_res(TINFO, "%s file synchronization", use_sync ? "Enable" : "Disable"); + tst_res(TINFO, "Number of pages: %d", num_pages); + + memset(cs, 0, sizeof(struct cachestat)); + + fd = SAFE_OPEN(FILENAME, O_RDWR | O_CREAT, 0600); + + for (int i = 0; i < num_pages; i++) + SAFE_WRITE(0, fd, page_data, page_size); + + if (use_sync) + fsync(fd); + + cs_range->off = 0; + cs_range->len = page_size * num_pages; + + TST_EXP_PASS(cachestat(fd, cs_range, cs, 0)); + print_cachestat(cs); + + TST_EXP_EQ_LI(cs->nr_cache + cs->nr_evicted, num_pages); + + if (use_sync) + TST_EXP_EQ_LI(cs->nr_dirty, 0); + + SAFE_CLOSE(fd); + SAFE_UNLINK(FILENAME); +} + +static void run(unsigned int use_sync) +{ + for (int i = 0; i < 15; i++) + test_cached_pages(use_sync, 1 << i); +} + +static void setup(void) +{ + page_size = (int)sysconf(_SC_PAGESIZE); + + page_data = SAFE_MALLOC(page_size); + memset(page_data, 'a', page_size); +} + +static void cleanup(void) +{ + if (page_data) + free(page_data); +} + +static struct tst_test test = { + .test = run, + .tcnt = 2, + .setup = setup, + .cleanup = cleanup, + .needs_tmpdir = 1, + .min_kver = "6.5", + .mount_device = 1, + .mntpoint = MNTPOINT, + .all_filesystems = 1, + .skip_filesystems = (const char *const []) { + "fuse", + "tmpfs", + NULL + }, + .bufs = (struct tst_buffers []) { + {&cs, .size = sizeof(struct cachestat)}, + {&cs_range, .size = sizeof(struct cachestat_range)}, + {} + }, +}; From patchwork Mon Jul 15 12:18:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1960631 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=s99TAFoa; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=BMGL+PGw; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=s99TAFoa; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=BMGL+PGw; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WN1TM3SDtz1xr4 for ; Mon, 15 Jul 2024 22:19:03 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 80ED83D1A2E for ; Mon, 15 Jul 2024 14:19:00 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [217.194.8.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 524F53D1A0C for ; Mon, 15 Jul 2024 14:18:57 +0200 (CEST) Authentication-Results: in-4.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=195.135.223.131; helo=smtp-out2.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id 972661000F38 for ; Mon, 15 Jul 2024 14:18:56 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id DFAC21F813; Mon, 15 Jul 2024 12:18:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1721045935; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4WOJW7LuJ52jJkZF4C5+XgTQmsxjSdfaLqVyHU6Vhto=; b=s99TAFoaj6Xst6qtvwajLoiaTUqzslVltKyl7nnK4oW5ZrVnKiMNKk3nhJWpt7GW8hYHfj MDBQcMjpAemmCi+N1cggOUQbk8ZAWs4eHFZp4YQ+we87HowPMEIVXOlaN2cFfEre3gQVnA LJpVHqe6CA9uoOpuq6lxP//FKt+t5mo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1721045935; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4WOJW7LuJ52jJkZF4C5+XgTQmsxjSdfaLqVyHU6Vhto=; b=BMGL+PGwH7a9rFQPzlGUF+T7xqpPJdutM+DNyBG2f1tcQR+2JsrICrtwkO9ooB8+jvk2LB biTSxAbl0JcTtADg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1721045935; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4WOJW7LuJ52jJkZF4C5+XgTQmsxjSdfaLqVyHU6Vhto=; b=s99TAFoaj6Xst6qtvwajLoiaTUqzslVltKyl7nnK4oW5ZrVnKiMNKk3nhJWpt7GW8hYHfj MDBQcMjpAemmCi+N1cggOUQbk8ZAWs4eHFZp4YQ+we87HowPMEIVXOlaN2cFfEre3gQVnA LJpVHqe6CA9uoOpuq6lxP//FKt+t5mo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1721045935; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4WOJW7LuJ52jJkZF4C5+XgTQmsxjSdfaLqVyHU6Vhto=; b=BMGL+PGwH7a9rFQPzlGUF+T7xqpPJdutM+DNyBG2f1tcQR+2JsrICrtwkO9ooB8+jvk2LB biTSxAbl0JcTtADg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id C99B8137EB; Mon, 15 Jul 2024 12:18:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id OEPwL68TlWbpQAAAD6G6ig (envelope-from ); Mon, 15 Jul 2024 12:18:55 +0000 From: Andrea Cervesato Date: Mon, 15 Jul 2024 14:18:34 +0200 MIME-Version: 1.0 Message-Id: <20240715-cachestat-v2-3-55817ad1a408@suse.com> References: <20240715-cachestat-v2-0-55817ad1a408@suse.com> In-Reply-To: <20240715-cachestat-v2-0-55817ad1a408@suse.com> To: ltp@lists.linux.it X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3315; i=andrea.cervesato@suse.com; h=from:subject:message-id; bh=cHojzUTc1f1nP7NN2CScfhWqNz3Yq3zuwvGcNHKXrrg=; b=owEB7QES/pANAwAIAcvMGrIgs+ZGAcsmYgBmlROheEeWRDjLj9V4R5GTXr7EEROLo1tmxKSZt sXg69RF1BiJAbMEAAEIAB0WIQT1ysFzUKRW0sIb39jLzBqyILPmRgUCZpUToQAKCRDLzBqyILPm RlZnC/99y2qx39E535D4TLPbFWUgn8+kQ6x4/J9w6Omo1boRSRMzkwml5Uk4wVHzG764GB3Nyy3 +8Dh6QfiwGXJE2WjwARcpa1WFI6tTkv7kjfMVvBjDI5lfWXEv36p/mXxN1MWTrlJ6CVwPJDk1zh 3Chuk2nZ31v2gayMzlenCFX8dbetVea4ikUcOdgo6f/23l0xU+SKValga7NUPmZkY5n424Ou0m5 97Dl3VVgUcf7swNIIGkDpQ4fe2kaRF42RQAtuyHYTLUlHslRyeL6LtG0vPuAXg+WgH+sPC29mU0 qVZ10TmsWYWw6Rc+zzWbVRZVXZ65ZQTKw8tERoPKDMBza4+QfqXv8gG77XjnOTg2lp1Oo7srGzg 6JTXXz0GBEYLLYcWjGuuE7SvbnsAsTNFmapAWnxy3FEVDdcbrSEWHO4NpoWu1jkHuAv6dMSwilR JWOED040oal19Y94mgM+vJnzW6CmiW+P9a+deY68BgayVDHV+YbodDC64p7AFS+7DXo0w= X-Developer-Key: i=andrea.cervesato@suse.com; a=openpgp; fpr=F5CAC17350A456D2C21BDFD8CBCC1AB220B3E646 X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-0.998]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,imap1.dmz-prg2.suse.org:helo] X-Spam-Score: -4.30 X-Spam-Level: X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-4.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-4.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v2 3/4] Add cachestat02 test X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato This test verifies that cachestat() syscall is properly counting cached pages written inside a shared memory. Signed-off-by: Andrea Cervesato --- runtest/syscalls | 1 + testcases/kernel/syscalls/cachestat/.gitignore | 1 + testcases/kernel/syscalls/cachestat/cachestat02.c | 89 +++++++++++++++++++++++ 3 files changed, 91 insertions(+) diff --git a/runtest/syscalls b/runtest/syscalls index 9a1827e88..887ac217b 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -63,6 +63,7 @@ capset04 capset04 cacheflush01 cacheflush01 cachestat01 cachestat01 +cachestat02 cachestat02 chdir01 chdir01 chdir01A symlink01 -T chdir01 diff --git a/testcases/kernel/syscalls/cachestat/.gitignore b/testcases/kernel/syscalls/cachestat/.gitignore index daea1f4be..0f70fb801 100644 --- a/testcases/kernel/syscalls/cachestat/.gitignore +++ b/testcases/kernel/syscalls/cachestat/.gitignore @@ -1 +1,2 @@ cachestat01 +cachestat02 diff --git a/testcases/kernel/syscalls/cachestat/cachestat02.c b/testcases/kernel/syscalls/cachestat/cachestat02.c new file mode 100644 index 000000000..d71f5dab5 --- /dev/null +++ b/testcases/kernel/syscalls/cachestat/cachestat02.c @@ -0,0 +1,89 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2024 SUSE LLC Andrea Cervesato + */ + +/*\ + * [Description] + * + * This test verifies that cachestat() syscall is properly counting cached pages + * written inside a shared memory. + * + * [Algorithm] + * + * - create a shared memory with a specific amount of pages + * - monitor file with cachestat() + * - check if the right amount of pages have been moved into cache + */ + +#include "cachestat.h" + +#define FILENAME "myfile.bin" + +static int page_size; +static char *page_data; +static struct cachestat *cs; +static struct cachestat_range *cs_range; + +static void test_cached_pages(const int num_pages) +{ + int fd, file_size; + + tst_res(TINFO, "Number of pages: %d", num_pages); + + memset(cs, 0, sizeof(struct cachestat)); + + fd = shm_open(FILENAME, O_RDWR | O_CREAT, 0600); + if (fd < 0) + tst_brk(TBROK | TERRNO, "shm_open error"); + + file_size = page_size * num_pages; + + cs_range->off = 0; + cs_range->len = file_size; + + SAFE_FTRUNCATE(fd, file_size); + for (int i = 0; i < num_pages; i++) + SAFE_WRITE(0, fd, page_data, page_size); + + TST_EXP_PASS(cachestat(fd, cs_range, cs, 0)); + print_cachestat(cs); + + TST_EXP_EQ_LI(cs->nr_cache + cs->nr_evicted, num_pages); + + SAFE_CLOSE(fd); + shm_unlink(FILENAME); +} + +static void run(void) +{ + for (int i = 0; i < 10; i++) + test_cached_pages(1 << i); +} + +static void setup(void) +{ + page_size = (int)sysconf(_SC_PAGESIZE); + + page_data = SAFE_MALLOC(page_size); + memset(page_data, 'a', page_size); +} + +static void cleanup(void) +{ + if (page_data) + free(page_data); +} + +static struct tst_test test = { + .test_all = run, + .setup = setup, + .cleanup = cleanup, + .needs_tmpdir = 1, + .min_kver = "6.5", + .bufs = (struct tst_buffers []) { + {&cs, .size = sizeof(struct cachestat)}, + {&cs_range, .size = sizeof(struct cachestat_range)}, + {} + }, +}; From patchwork Mon Jul 15 12:18:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1960632 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=FvqUpZvV; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=yQEAVLom; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=FvqUpZvV; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=yQEAVLom; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WN1Tg08DSz1xr4 for ; Mon, 15 Jul 2024 22:19:19 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id B544E3D1A36 for ; Mon, 15 Jul 2024 14:19:16 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [IPv6:2001:4b78:1:20::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 5B7F23D1A0E for ; Mon, 15 Jul 2024 14:18:57 +0200 (CEST) Authentication-Results: in-2.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=195.135.223.130; helo=smtp-out1.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 9D6FB60045F for ; Mon, 15 Jul 2024 14:18:56 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 07BF021BAE; Mon, 15 Jul 2024 12:18:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1721045936; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4K0nEUyEmtTt+/JvQVlIhkJwVXBIDzK2IBU2Ewqwx2E=; b=FvqUpZvV9XJ1IcK/ls4zQZXJCfWceIKI5noSEiTFRlsKcSq7eyyPk2A+MfLeM+usGhcfe+ e9W9KhvmVkBcVfPHv5h+TzvecdzHKxXUtVGFwEDRZaCMjYEb3PWE0TQAY5LhRR7dclH/4J VLaaY6kvHOMbuLZ3pgIcecyXhY/6rA4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1721045936; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4K0nEUyEmtTt+/JvQVlIhkJwVXBIDzK2IBU2Ewqwx2E=; b=yQEAVLomjwCfqibHDZRXMRNxDGe8yNOXDyHS25rtI9L3z1Hhpt15pYm9JR75AkjPt/5Y44 GDZKcIcxTel2LpCw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1721045936; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4K0nEUyEmtTt+/JvQVlIhkJwVXBIDzK2IBU2Ewqwx2E=; b=FvqUpZvV9XJ1IcK/ls4zQZXJCfWceIKI5noSEiTFRlsKcSq7eyyPk2A+MfLeM+usGhcfe+ e9W9KhvmVkBcVfPHv5h+TzvecdzHKxXUtVGFwEDRZaCMjYEb3PWE0TQAY5LhRR7dclH/4J VLaaY6kvHOMbuLZ3pgIcecyXhY/6rA4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1721045936; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4K0nEUyEmtTt+/JvQVlIhkJwVXBIDzK2IBU2Ewqwx2E=; b=yQEAVLomjwCfqibHDZRXMRNxDGe8yNOXDyHS25rtI9L3z1Hhpt15pYm9JR75AkjPt/5Y44 GDZKcIcxTel2LpCw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id E69811395F; Mon, 15 Jul 2024 12:18:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id cHnzNq8TlWbpQAAAD6G6ig (envelope-from ); Mon, 15 Jul 2024 12:18:55 +0000 From: Andrea Cervesato Date: Mon, 15 Jul 2024 14:18:35 +0200 MIME-Version: 1.0 Message-Id: <20240715-cachestat-v2-4-55817ad1a408@suse.com> References: <20240715-cachestat-v2-0-55817ad1a408@suse.com> In-Reply-To: <20240715-cachestat-v2-0-55817ad1a408@suse.com> To: ltp@lists.linux.it X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3627; i=andrea.cervesato@suse.com; h=from:subject:message-id; bh=uWyT0tGPyEZgkpMYto9J2ify1VaBQunLO5B2qOFv8cg=; b=owEB7QES/pANAwAIAcvMGrIgs+ZGAcsmYgBmlROhEc61M2Z3+fFq4f/oRYytX5eY7MlkSMiPv Oc6t3/sqGWJAbMEAAEIAB0WIQT1ysFzUKRW0sIb39jLzBqyILPmRgUCZpUToQAKCRDLzBqyILPm RiHwDAC1vDh0rVmHZVONLEdrXavrCwUX6svODy4F1qAqGHJ/FEeJU5Xm6Y4jWpZ81vkpRwDjtdC /cTBYPAeCgEFpRfLFt6vJwAHbXuPjHMJ+foBCc8bm7j8qAstoIiYMW0DUi2vVbv7cRdybSQSjvF DlWMLuPEF1JQV45IFLX2TPX5uXa38QnX+tEOHV3iR8sjbJbnThAxUeFMa1TJFmPUgdo4pZzlM86 a2Z5pgwdfWNcwnedsFotkidU320+lf55DGH/AARb3qR/V+uXNoHIbMUMAHp8h7hwnS6KIZTXwEL QKyVQkjJEAXS5XHLiDgKfOnq3bpHxgDF9StmCEj3UXk91r4oTkSxn6zAUvd3O2VwKh2Ut2nr50D hb1eKayFNQZV1TPOUdSB+B9WqjlavX78Z01t4FUmJFKkHF1i+Sc3lHlMIc0zElO70yhQHcGZcCH pPBDrWUbpID6IiwpcapFY9ho30Y95WcptzMPsPq0GzLofXfDs0wr9vaAXm9uMT4rSIKi8= X-Developer-Key: i=andrea.cervesato@suse.com; a=openpgp; fpr=F5CAC17350A456D2C21BDFD8CBCC1AB220B3E646 X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-0.998]; MIME_GOOD(-0.10)[text/plain]; FUZZY_BLOCKED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,imap1.dmz-prg2.suse.org:helo] X-Spam-Score: -4.30 X-Spam-Level: X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-2.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-2.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v2 4/4] Add cachestat03 test X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato 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 Signed-off-by: Andrea Cervesato --- runtest/syscalls | 1 + testcases/kernel/syscalls/cachestat/.gitignore | 1 + testcases/kernel/syscalls/cachestat/cachestat03.c | 80 +++++++++++++++++++++++ 3 files changed, 82 insertions(+) diff --git a/runtest/syscalls b/runtest/syscalls index 887ac217b..de5a21749 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -64,6 +64,7 @@ cacheflush01 cacheflush01 cachestat01 cachestat01 cachestat02 cachestat02 +cachestat03 cachestat03 chdir01 chdir01 chdir01A symlink01 -T chdir01 diff --git a/testcases/kernel/syscalls/cachestat/.gitignore b/testcases/kernel/syscalls/cachestat/.gitignore index 0f70fb801..6cfa3fa10 100644 --- a/testcases/kernel/syscalls/cachestat/.gitignore +++ b/testcases/kernel/syscalls/cachestat/.gitignore @@ -1,2 +1,3 @@ cachestat01 cachestat02 +cachestat03 diff --git a/testcases/kernel/syscalls/cachestat/cachestat03.c b/testcases/kernel/syscalls/cachestat/cachestat03.c new file mode 100644 index 000000000..35f6bdfb3 --- /dev/null +++ b/testcases/kernel/syscalls/cachestat/cachestat03.c @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2024 SUSE LLC Andrea Cervesato + */ + +/*\ + * [Description] + * + * 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 + */ + +#define MNTPOINT "mnt" + +#include "cachestat.h" + +static int fd; +static int fd_hugepage; +static int invalid_fd = -1; +static struct cachestat *cs; +static struct cachestat *cs_null; +static struct cachestat_range *cs_range; +static struct cachestat_range *cs_range_null; + +static struct tcase { + int *fd; + struct cachestat_range **range; + struct cachestat **data; + int flags; + int exp_errno; + char *msg; +} tcases[] = { + {&invalid_fd, &cs_range, &cs, 0, EBADF, "Invalid fd (-1)"}, + {&fd, &cs_range_null, &cs, 0, EFAULT, "Invalid range (NULL)"}, + {&fd, &cs_range, &cs_null, 0, EFAULT, "Invalid data (NULL)"}, + {&fd, &cs_range, &cs, -1, EINVAL, "Invalid args (-1)"}, + {&fd_hugepage, &cs_range, &cs, 0, EOPNOTSUPP, "Unsupported hugetlbfs"}, +}; + +static void run(unsigned int i) +{ + struct tcase *tc = &tcases[i]; + + TST_EXP_FAIL(cachestat(*tc->fd, *tc->range, *tc->data, tc->flags), + tc->exp_errno, "%s", tc->msg); +} + +static void setup(void) +{ + fd = SAFE_OPEN("test", O_CREAT | O_RDWR, 0700); + fd_hugepage = SAFE_OPEN(MNTPOINT"/test", O_CREAT | O_RDWR, 0700); +} + +static void cleanup(void) +{ + SAFE_CLOSE(fd); + SAFE_CLOSE(fd_hugepage); +} + +static struct tst_test test = { + .test = run, + .setup = setup, + .cleanup = cleanup, + .mntpoint = MNTPOINT, + .needs_hugetlbfs = 1, + .hugepages = {1, TST_NEEDS}, + .tcnt = ARRAY_SIZE(tcases), + .min_kver = "6.5", + .needs_tmpdir = 1, + .bufs = (struct tst_buffers []) { + {&cs, .size = sizeof(struct cachestat)}, + {&cs_range, .size = sizeof(struct cachestat_range)}, + {} + }, +};