From patchwork Mon Jul 22 14:28:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1963271 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=0GJVvpIf; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=adEbrOuG; 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=0GJVvpIf; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=adEbrOuG; 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 4WSN2h6lfjz1yYm for ; Tue, 23 Jul 2024 00:29:32 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 6D6E83D1BD9 for ; Mon, 22 Jul 2024 16:29:29 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [IPv6:2001:4b78:1:20::3]) (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 3D5423D0BC9 for ; Mon, 22 Jul 2024 16:29:26 +0200 (CEST) Authentication-Results: in-3.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-3.smtp.seeweb.it (Postfix) with ESMTPS id 7774C1A01936 for ; Mon, 22 Jul 2024 16:29:25 +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-out2.suse.de (Postfix) with ESMTPS id 8B5321F8D4; Mon, 22 Jul 2024 14:29:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1721658564; 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=0GJVvpIfCTrOjwMo5Z+TyNQEhnaOR3tFFIWWIW4EEx1FPj9UIJ/BtXg5ILSqZu9iEMHjAG I4tiSLcINan/3ELUAPDaPXVyRUceG7aPMlt7RLxJAKrkpM646RJY4tYGepDOKvI7sy6gA4 nFcYZNVNFDqBzJlXkLbT49mLbQRoJJk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1721658564; 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=adEbrOuGn7E7UgfeO3faY5++97sc5c8dDZGLZNybXSkw+feWwfkEKbYPN89ujct1QUz66I c5047ojEItwHpQBw== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=0GJVvpIf; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=adEbrOuG DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1721658564; 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=0GJVvpIfCTrOjwMo5Z+TyNQEhnaOR3tFFIWWIW4EEx1FPj9UIJ/BtXg5ILSqZu9iEMHjAG I4tiSLcINan/3ELUAPDaPXVyRUceG7aPMlt7RLxJAKrkpM646RJY4tYGepDOKvI7sy6gA4 nFcYZNVNFDqBzJlXkLbT49mLbQRoJJk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1721658564; 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=adEbrOuGn7E7UgfeO3faY5++97sc5c8dDZGLZNybXSkw+feWwfkEKbYPN89ujct1QUz66I c5047ojEItwHpQBw== 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 69D491398E; Mon, 22 Jul 2024 14:29:24 +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 wG/qF8RsnmazSwAAD6G6ig (envelope-from ); Mon, 22 Jul 2024 14:29:24 +0000 From: Andrea Cervesato Date: Mon, 22 Jul 2024 16:28:40 +0200 MIME-Version: 1.0 Message-Id: <20240722-cachestat-v3-1-a0386f7cdaaa@suse.com> References: <20240722-cachestat-v3-0-a0386f7cdaaa@suse.com> In-Reply-To: <20240722-cachestat-v3-0-a0386f7cdaaa@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+ZGAcsmYgBmnmyvJPft5CJdCZU8CggDT7Ub5ocYxuQ+2p6Ql d7oxuNt+dyJAbMEAAEIAB0WIQT1ysFzUKRW0sIb39jLzBqyILPmRgUCZp5srwAKCRDLzBqyILPm Rv5DC/9TdM/gdbiLbOOnL3ASApX2hmzvA+tTVm/SCpJOKFgjYl04n/KkL+0g5e/F2GCfMaB603u vgdrZuwrFdNYTIOr9yISyWMh63opU+uIc5NwfXarBcMsXdZfXb6oJx/c5QpC+bAsUNXbBrHBaf0 itm3BR6NslqTsoQij/gydh7vmiFeI8CHPNi8pc98ZDCR3Gy7KLKLSfdiEDWY0E7L4lY/eAcmflS U7F3iNRBg33bvxTwi5UJn5Xk8U86o5trQqJ5ezH1LRqI6HqfiNmf+GVgQOW0ziDwzXxyCPHVe4W kjpyDx253Nh071hYEbfS2u8uONYipAPcTC3ilFRFtqa7KPIROhc+4yDUtNA20/baXuzckdUy+rs vnOWrJa7q/36mkT6L1zxLTzHBehGCwtyrydbcrui4AslbrfJRPTWaLfCugLMygpnzH/V/fRuVLd zLqZcyDYx2FHJyCVltuOF7u0/NdZGz1Jz2twD3ekdHF9VT08RaunRaqzaE65uxywif2d4= X-Developer-Key: i=andrea.cervesato@suse.com; a=openpgp; fpr=F5CAC17350A456D2C21BDFD8CBCC1AB220B3E646 X-Spam-Score: -1.31 X-Spamd-Result: default: False [-1.31 / 50.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; DWL_DNSWL_BLOCKED(0.00)[suse.de:dkim]; RCVD_TLS_ALL(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.com:email]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Action: no action X-Spam-Level: X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 8B5321F8D4 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-3.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-3.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v3 1/5] 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 22 14:28:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1963275 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=LVwd3j2t; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=bRCBERv1; 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=LVwd3j2t; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=bRCBERv1; 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 4WSN3w4vldz1yZ7 for ; Tue, 23 Jul 2024 00:30:36 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 48CB23D1BEB for ; Mon, 22 Jul 2024 16:30:34 +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 [IPv6:2001:4b78:1:20::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 447F23D0BC9 for ; Mon, 22 Jul 2024 16:29:26 +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 7657B60140B for ; Mon, 22 Jul 2024 16:29:25 +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-out2.suse.de (Postfix) with ESMTPS id BEB871FB7D; Mon, 22 Jul 2024 14:29:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1721658564; 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=EvucEIdry0LYhkBykhT60oI2qMDIV/JPocWbCgODFYs=; b=LVwd3j2tyzskxm7xsWtLdXceGgfCN2dMvFYXPW9Wxw66WV/MmmKK6kS0WY5q9xjTvNXhkC AxNEqFfejXJ+92e3i7Qzl4HvdMMarHFEtVqaOEuc0ko+fQkadFPTM14cUGtfZvsSp1qR0g 4WMMqOhE+3ZUJQUQoyQzemSpcEw4pmI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1721658564; 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=EvucEIdry0LYhkBykhT60oI2qMDIV/JPocWbCgODFYs=; b=bRCBERv1H1bGViQDBcoX5jARbin3sWRtq7AV/3vD2pvtmFy1Q4CylfA/BfKfuu26C4sdzU iDImy8M3oiDTY1Aw== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=LVwd3j2t; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=bRCBERv1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1721658564; 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=EvucEIdry0LYhkBykhT60oI2qMDIV/JPocWbCgODFYs=; b=LVwd3j2tyzskxm7xsWtLdXceGgfCN2dMvFYXPW9Wxw66WV/MmmKK6kS0WY5q9xjTvNXhkC AxNEqFfejXJ+92e3i7Qzl4HvdMMarHFEtVqaOEuc0ko+fQkadFPTM14cUGtfZvsSp1qR0g 4WMMqOhE+3ZUJQUQoyQzemSpcEw4pmI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1721658564; 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=EvucEIdry0LYhkBykhT60oI2qMDIV/JPocWbCgODFYs=; b=bRCBERv1H1bGViQDBcoX5jARbin3sWRtq7AV/3vD2pvtmFy1Q4CylfA/BfKfuu26C4sdzU iDImy8M3oiDTY1Aw== 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 9460113996; Mon, 22 Jul 2024 14:29:24 +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 2DszIsRsnmazSwAAD6G6ig (envelope-from ); Mon, 22 Jul 2024 14:29:24 +0000 From: Andrea Cervesato Date: Mon, 22 Jul 2024 16:28:41 +0200 MIME-Version: 1.0 Message-Id: <20240722-cachestat-v3-2-a0386f7cdaaa@suse.com> References: <20240722-cachestat-v3-0-a0386f7cdaaa@suse.com> In-Reply-To: <20240722-cachestat-v3-0-a0386f7cdaaa@suse.com> To: ltp@lists.linux.it X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5392; i=andrea.cervesato@suse.com; h=from:subject:message-id; bh=neTU2zW/6UEhUO17K1yncvKwJtTkPTAK2HSuqsYgfO0=; b=owEB7QES/pANAwAIAcvMGrIgs+ZGAcsmYgBmnmyvR7IPKnekL5RneSQ/pMWPMOz6G1hD7oq0u S99S2hVsLeJAbMEAAEIAB0WIQT1ysFzUKRW0sIb39jLzBqyILPmRgUCZp5srwAKCRDLzBqyILPm RnbqC/sGVzrxmnNOMadgoNHGyyRFNptZBP7onYGjgA1Umby5lgD+HaUpF1yacZbJDQK2csTeL3X 0QqLuby6cWOm0hTRalb1JoVB773wwLguaAa2sn/z3hoTvF47y4w9Mg2Kbxbh3QTnRCalD8oL1ui DO1HsQ+M63u7gCyXV+ZvsbKnhbLQoQUPamikb+9yjfS6Uz8MT5keLnEEyvIXEYG6ImB4GDbP31P H2vgVq9fBGF+jB7Oo+vPSzVpkA70+zucdf3Cy5RYAvdxo7JdAwihcZ6Jo73LKbZY+OW8dmh23/J JaZu0br/zgQgW3QSwgi69c/9+nWbFtA34NOduc6CKqblmY4BFq89dt2vRchROh1/v+EbsiNZ+by SjwjG49vkkOFeL4embiGpExxehLO6jqYdXObsVpcAfuYi1k0UCAayXtiAgmw+adJ2jfOI6H2hpK VEgQw3bO8T+Y7ZFLgfAqM8sXmac65YDxO95aotsNxjAUGRDfpO5hy+C82bkObwMtBFzIk= X-Developer-Key: i=andrea.cervesato@suse.com; a=openpgp; fpr=F5CAC17350A456D2C21BDFD8CBCC1AB220B3E646 X-Spam-Score: -4.31 X-Rspamd-Action: no action X-Spam-Level: X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: BEB871FB7D X-Spamd-Result: default: False [-4.31 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_DN_SOME(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.de:dkim,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] 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 v3 2/5] 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 | 106 ++++++++++++++++++++++ 5 files changed, 146 insertions(+) diff --git a/runtest/syscalls b/runtest/syscalls index 27eb9a86b..ce974b317 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..7b0700f2c --- /dev/null +++ b/testcases/kernel/syscalls/cachestat/cachestat01.c @@ -0,0 +1,106 @@ +// 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 +#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 22 14:28:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1963273 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=w3REsMKW; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=+aRT4jtm; 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=w3REsMKW; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=+aRT4jtm; 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 4WSN3J4Zmmz1yYm for ; Tue, 23 Jul 2024 00:30:04 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 3AB573D1BEA for ; Mon, 22 Jul 2024 16:30:02 +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 8A2173D0C06 for ; Mon, 22 Jul 2024 16:29:26 +0200 (CEST) Authentication-Results: in-5.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=2a07:de40:b251:101:10:150:64:1; 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 [IPv6:2a07:de40:b251:101:10:150:64:1]) (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 04F3F601405 for ; Mon, 22 Jul 2024 16:29:25 +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 DCE1921BB0; Mon, 22 Jul 2024 14:29:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1721658564; 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=MkFxdFl7jR6KujdwGsx679ej3wa5LeF4hx9ZkitGN+4=; b=w3REsMKW3E14xbjQjGa8yqA7XEYWP16SB3nMPPPSEaxgYayoXJpJDjDWEHwn8YoUQS5/5t eoVnxXIuMpnPHYUbzA1c1Qmyinj7lHEl1O+T/9bKN0IU50KUWUsHFgLRjoufwHSEyIoC7O a4Xbq9BEk2onwgCmHP1rA+PVYpHbZ1U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1721658564; 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=MkFxdFl7jR6KujdwGsx679ej3wa5LeF4hx9ZkitGN+4=; b=+aRT4jtmgsa4QNi8raRW79By07XsvbCbtng45dGIWyBWXqDrdom0Y34V/5NT1xf4Z8MXP9 Ux8dCKsIyaqP/0Dg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=w3REsMKW; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=+aRT4jtm DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1721658564; 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=MkFxdFl7jR6KujdwGsx679ej3wa5LeF4hx9ZkitGN+4=; b=w3REsMKW3E14xbjQjGa8yqA7XEYWP16SB3nMPPPSEaxgYayoXJpJDjDWEHwn8YoUQS5/5t eoVnxXIuMpnPHYUbzA1c1Qmyinj7lHEl1O+T/9bKN0IU50KUWUsHFgLRjoufwHSEyIoC7O a4Xbq9BEk2onwgCmHP1rA+PVYpHbZ1U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1721658564; 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=MkFxdFl7jR6KujdwGsx679ej3wa5LeF4hx9ZkitGN+4=; b=+aRT4jtmgsa4QNi8raRW79By07XsvbCbtng45dGIWyBWXqDrdom0Y34V/5NT1xf4Z8MXP9 Ux8dCKsIyaqP/0Dg== 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 BF9AB136A9; Mon, 22 Jul 2024 14:29:24 +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 mKHGLMRsnmazSwAAD6G6ig (envelope-from ); Mon, 22 Jul 2024 14:29:24 +0000 From: Andrea Cervesato Date: Mon, 22 Jul 2024 16:28:42 +0200 MIME-Version: 1.0 Message-Id: <20240722-cachestat-v3-3-a0386f7cdaaa@suse.com> References: <20240722-cachestat-v3-0-a0386f7cdaaa@suse.com> In-Reply-To: <20240722-cachestat-v3-0-a0386f7cdaaa@suse.com> To: ltp@lists.linux.it X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3337; i=andrea.cervesato@suse.com; h=from:subject:message-id; bh=K6xA0fn1iDZYMw0xNXuyJ3O4Zu5xvambteVvR9rSyHY=; b=owEB7QES/pANAwAIAcvMGrIgs+ZGAcsmYgBmnmyveIO8ZgjFsY1fXM168DzkavZhzLV03Xo6c EZVBxVTMyGJAbMEAAEIAB0WIQT1ysFzUKRW0sIb39jLzBqyILPmRgUCZp5srwAKCRDLzBqyILPm Rsy9DACKnvxmWHp0IlfZ68NdF1RFd12H0tscGlI0HehuIJZ0IOSxWERfBioE5rpGUAawL7LqJuY fnm+nEYo+Gz5JxW/+vIivuH4ZRutyaMUPsRuUrZfEC7W278Tu6m/aeuRKxSuULz+dLJRbZEmH4q NhqE+RdPGGXepWLEUviNqIqkY+zilx8nTl2iRG1LYZH/VTtBtn6rOz8/y/jPB0/5/KV/CyqJI/u Ab1IcaoFw+ZCEkM2RHk8bI4uRukfnNey0mZpoaau9ekbWJsNvV9u6aISZqewa01upYgPa0yGE4Z pblSwafjo1fFUW5HMpYmMZ5eCPDbgiEexBd5mjd7T4Xh8Xpr5L44aDdEUyQ3HMqVmYHtQ2TNhpe q11oMj1qjwwQXhKOFcNe8Am1dCFkerEBvPbr6Ef44ABqU93qFVF29arT3RTzkjVrGMp7rzYQDjP y3RfB7qHweN8bbkm4UwKzeoXDtuU9bWTRCrTtI/gZwvliy5dN/WVNgb8uhxk/50d0TE7I= X-Developer-Key: i=andrea.cervesato@suse.com; a=openpgp; fpr=F5CAC17350A456D2C21BDFD8CBCC1AB220B3E646 X-Spam-Score: -4.31 X-Rspamd-Action: no action X-Spam-Level: X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: DCE1921BB0 X-Spamd-Result: default: False [-4.31 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_DN_SOME(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:dkim]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] 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 v3 3/5] 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 | 90 +++++++++++++++++++++++ 3 files changed, 92 insertions(+) diff --git a/runtest/syscalls b/runtest/syscalls index ce974b317..294e3cebf 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..deaaa6d32 --- /dev/null +++ b/testcases/kernel/syscalls/cachestat/cachestat02.c @@ -0,0 +1,90 @@ +// 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 +#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 22 14:28:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1963272 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=xuMq2ga+; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=l/EFWt1l; 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=xuMq2ga+; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=l/EFWt1l; 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 4WSN304389z1yYm for ; Tue, 23 Jul 2024 00:29:48 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 248AF3D1BE2 for ; Mon, 22 Jul 2024 16:29:46 +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 6A6103D0BC9 for ; Mon, 22 Jul 2024 16:29:26 +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 80C8E6013EF for ; Mon, 22 Jul 2024 16:29:25 +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-out2.suse.de (Postfix) with ESMTPS id 109571FD06; Mon, 22 Jul 2024 14:29:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1721658565; 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=+aI5/A9bCeAbsod8PLVisqTrtVPSr9kNWkI57RobPlg=; b=xuMq2ga+VTGcBE2BvQGAAuRQFRRyTwDTqcScw+xfUUmUDrhg8t9N2HbHOXLfpQ5Q+yGuJb 0kYMv1GHX16/6mRF8eYgkCNzIjaSBMbkgyL1zF0rT4erl5iMAoGnJqxKSxk4wiCKBGq1/u wGn2kmdZBQxHP9I20l2zsirwB9vCmmM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1721658565; 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=+aI5/A9bCeAbsod8PLVisqTrtVPSr9kNWkI57RobPlg=; b=l/EFWt1lLGu8p6c5WIVWdZFWpU5sZfLI9UD7CJ4fn9TyF9osOWR+cENIdKPtA0TvJBtfwy VTC7HxSNf2mBUhAA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=xuMq2ga+; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="l/EFWt1l" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1721658565; 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=+aI5/A9bCeAbsod8PLVisqTrtVPSr9kNWkI57RobPlg=; b=xuMq2ga+VTGcBE2BvQGAAuRQFRRyTwDTqcScw+xfUUmUDrhg8t9N2HbHOXLfpQ5Q+yGuJb 0kYMv1GHX16/6mRF8eYgkCNzIjaSBMbkgyL1zF0rT4erl5iMAoGnJqxKSxk4wiCKBGq1/u wGn2kmdZBQxHP9I20l2zsirwB9vCmmM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1721658565; 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=+aI5/A9bCeAbsod8PLVisqTrtVPSr9kNWkI57RobPlg=; b=l/EFWt1lLGu8p6c5WIVWdZFWpU5sZfLI9UD7CJ4fn9TyF9osOWR+cENIdKPtA0TvJBtfwy VTC7HxSNf2mBUhAA== 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 E74D51398E; Mon, 22 Jul 2024 14:29:24 +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 CAaTNsRsnmazSwAAD6G6ig (envelope-from ); Mon, 22 Jul 2024 14:29:24 +0000 From: Andrea Cervesato Date: Mon, 22 Jul 2024 16:28:43 +0200 MIME-Version: 1.0 Message-Id: <20240722-cachestat-v3-4-a0386f7cdaaa@suse.com> References: <20240722-cachestat-v3-0-a0386f7cdaaa@suse.com> In-Reply-To: <20240722-cachestat-v3-0-a0386f7cdaaa@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=iE2E3tR9ImwC0SsKWtotDqGe5U1PqnXGHHfk2QGnL8c=; b=owEB7QES/pANAwAIAcvMGrIgs+ZGAcsmYgBmnmyvwrbOA+PAt0/c0vHPDYV2iZ+s8WLcnjo/5 /g2a3N8SBaJAbMEAAEIAB0WIQT1ysFzUKRW0sIb39jLzBqyILPmRgUCZp5srwAKCRDLzBqyILPm RjbnC/45AgF/Ys+Bg3XMWtFYnzWT/4/sJiE0/yd3lDjH/JEeT/bx0cTul8T6x8HcbFTdAgd8nuz mzZfXU/u6xJj9lmndY1vP8PC9raDNibE6kNwf/YnHliesKD6jSAJ/MFurXse31y2R1yGv+mCsow 5G/WZRODt5PrxTO778GIE+TKzRQxoJupkxU4KOzQ4DcqTxE+LPqKf+g6aRbidS9fwJ1INbDzJHK HDITBxCxSGXqK5p63+WuSrDhlAtxD9zMA4XNK6mfwNUs22FnoGo24ydlPgJrzHIvI90h0twFui9 2qDd3kc6xk8i4ZM1QKJN49gom48yfmKBJ5c41BBf40AJqSSZ+ENnBFztOsqzutyWC4y5IsPXG64 3fp/ch31Un1yrsFF6Hia3uvV/PT8p/7jlSAn89sIUCF8honC2EAEvIsVyjmUbRSZa2M4y6ha8PT yj/9ejKSnIniAzwLjas2O7j/u+h3eVh6rFYk351Y3XChsyi3Xbe8GYKc3xE2Qlq+9vxFc= X-Developer-Key: i=andrea.cervesato@suse.com; a=openpgp; fpr=F5CAC17350A456D2C21BDFD8CBCC1AB220B3E646 X-Spam-Score: -1.31 X-Spamd-Result: default: False [-1.31 / 50.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; 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:+]; DWL_DNSWL_BLOCKED(0.00)[suse.de:dkim]; RCVD_TLS_ALL(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.com:email,suse.de:dkim]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Action: no action X-Spam-Level: X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 109571FD06 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 v3 4/5] 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 294e3cebf..8a297429b 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)}, + {} + }, +}; From patchwork Mon Jul 22 14:28:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1963274 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=w9jE8OMo; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=kSUhHlRu; 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=w9jE8OMo; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=kSUhHlRu; 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) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WSN3d1fwdz1yZ7 for ; Tue, 23 Jul 2024 00:30:21 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id D2A1F3D1BE3 for ; Mon, 22 Jul 2024 16:30:18 +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 B7D613D0BC9 for ; Mon, 22 Jul 2024 16:29:26 +0200 (CEST) Authentication-Results: in-5.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=2a07:de40:b251:101:10:150:64:1; 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 [IPv6:2a07:de40:b251:101:10:150:64:1]) (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 3B4E9601400 for ; Mon, 22 Jul 2024 16:29:26 +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 3A1C621BB1; Mon, 22 Jul 2024 14:29:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1721658565; 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=l096ivDghQE0tjwZMlVJ9zBIef6OTR4H412lcYeZCSs=; b=w9jE8OMo/JHDYQ4BQpRMFdqoP8SAc8iga2ZuBCR+Rtwcozs0cHylzUR26HTIk4uBpTbIv3 QiaaucsnbXJ5QF/G37I14SXd9onYuZPpP4KZzt2Srhr290YmE5AU59a1xWIvYlYTCTJx4o NmBGbgNkr5yqUT/Y0ADG1H1DJIBIGng= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1721658565; 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=l096ivDghQE0tjwZMlVJ9zBIef6OTR4H412lcYeZCSs=; b=kSUhHlRuf5czjiiNh9I/BeleVKQL5Fg3oeCc1IPBuMEVyYx8oiBEk05ThMJYDWhsuIfP0H j8VZ4V+VHSvrLjDw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=w9jE8OMo; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=kSUhHlRu DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1721658565; 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=l096ivDghQE0tjwZMlVJ9zBIef6OTR4H412lcYeZCSs=; b=w9jE8OMo/JHDYQ4BQpRMFdqoP8SAc8iga2ZuBCR+Rtwcozs0cHylzUR26HTIk4uBpTbIv3 QiaaucsnbXJ5QF/G37I14SXd9onYuZPpP4KZzt2Srhr290YmE5AU59a1xWIvYlYTCTJx4o NmBGbgNkr5yqUT/Y0ADG1H1DJIBIGng= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1721658565; 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=l096ivDghQE0tjwZMlVJ9zBIef6OTR4H412lcYeZCSs=; b=kSUhHlRuf5czjiiNh9I/BeleVKQL5Fg3oeCc1IPBuMEVyYx8oiBEk05ThMJYDWhsuIfP0H j8VZ4V+VHSvrLjDw== 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 1C4A2136A9; Mon, 22 Jul 2024 14:29:25 +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 uGP9BMVsnmazSwAAD6G6ig (envelope-from ); Mon, 22 Jul 2024 14:29:25 +0000 From: Andrea Cervesato Date: Mon, 22 Jul 2024 16:28:44 +0200 MIME-Version: 1.0 Message-Id: <20240722-cachestat-v3-5-a0386f7cdaaa@suse.com> References: <20240722-cachestat-v3-0-a0386f7cdaaa@suse.com> In-Reply-To: <20240722-cachestat-v3-0-a0386f7cdaaa@suse.com> To: ltp@lists.linux.it X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2771; i=andrea.cervesato@suse.com; h=from:subject:message-id; bh=UMbXZ66TkrbxH1wHz02kyAue2T5gN+71SHqJibR5aGY=; b=owEB7QES/pANAwAIAcvMGrIgs+ZGAcsmYgBmnmyv0tuiObZlpUxZcBUUpOQ2WMDnKDCnxvlYp 8Kkm7m3YGyJAbMEAAEIAB0WIQT1ysFzUKRW0sIb39jLzBqyILPmRgUCZp5srwAKCRDLzBqyILPm RnePC/9F+SjoFLb3cTIVdNfJgiyEFKleZ/a2WNnJ0VU7s06FyMJ05GXEGLmoLRmmAcj7jg66nmq pwl38GAK0OX75EU7lA4ZNfduaiQg9v/09IbKRSjXd0pEFYzMnaFeZ/1A43acFU7xtLE98gLUH0C tUvns9uM7xqo6M/EG72BeBYiKNxAo34qMEdje8E4P8EBTqOm0gObkZ6cFNNES0DInaJx+lbVmIS zN/zz2Z6BCq3Tmx2Ql+Gw3x4T3hgYu1I1PEyx4I5zTO5olHDCMzij6zdSid0OjD2pi7jLMDuKop f44ITNuAMEDJtyrb/etX13nbnKBa6cI84dYL2QGypYesc8uZuSD7Y7VHK3+10xQXUQA1oKukZdE To8U/NcD0+kkV+7YTssfuoBDNJwPugQ68QyOpKm5+tJbf5dGbeMaNB+0nIh9A4Qu70syAGUyJOn mp7/YNIgWWi5gC8slZkpELT+wpNcq6h1h7YZTXAdWUpNj3X4Mivl/pn/ekUyntqscpnDY= X-Developer-Key: i=andrea.cervesato@suse.com; a=openpgp; fpr=F5CAC17350A456D2C21BDFD8CBCC1AB220B3E646 X-Spam-Score: -4.31 X-Rspamd-Action: no action X-Spam-Level: X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 3A1C621BB1 X-Spamd-Result: default: False [-4.31 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_DN_SOME(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.de:dkim,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] 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 v3 5/5] Add cachestat04 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 cachestat() for all possible file descriptors, checking that returned statistics are always zero, unless file descriptor is unsupported and EBADF is raised. Signed-off-by: Andrea Cervesato --- runtest/syscalls | 1 + testcases/kernel/syscalls/cachestat/.gitignore | 1 + testcases/kernel/syscalls/cachestat/cachestat04.c | 58 +++++++++++++++++++++++ 3 files changed, 60 insertions(+) diff --git a/runtest/syscalls b/runtest/syscalls index 8a297429b..9b041b03d 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -65,6 +65,7 @@ cacheflush01 cacheflush01 cachestat01 cachestat01 cachestat02 cachestat02 cachestat03 cachestat03 +cachestat04 cachestat04 chdir01 chdir01 chdir01A symlink01 -T chdir01 diff --git a/testcases/kernel/syscalls/cachestat/.gitignore b/testcases/kernel/syscalls/cachestat/.gitignore index 6cfa3fa10..a3611a533 100644 --- a/testcases/kernel/syscalls/cachestat/.gitignore +++ b/testcases/kernel/syscalls/cachestat/.gitignore @@ -1,3 +1,4 @@ cachestat01 cachestat02 cachestat03 +cachestat04 diff --git a/testcases/kernel/syscalls/cachestat/cachestat04.c b/testcases/kernel/syscalls/cachestat/cachestat04.c new file mode 100644 index 000000000..0913dd57a --- /dev/null +++ b/testcases/kernel/syscalls/cachestat/cachestat04.c @@ -0,0 +1,58 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2024 SUSE LLC Andrea Cervesato + */ + +/*\ + * [Description] + * + * This test verifies cachestat() for all the possible file descriptors, + * checking that cache statistics are always zero, except for unsupported file + * descriptors which cause EBADF to be raised. + */ + +#include "tst_test.h" +#include "lapi/mman.h" + +#define MNTPOINT "mnt" + +static struct cachestat *cs; +static struct cachestat_range *cs_range; + +static void check_cachestat(struct tst_fd *fd_in) +{ + int ret; + + ret = cachestat(fd_in->fd, cs_range, cs, 0); + if (ret == -1) { + TST_EXP_EQ_LI(errno, EBADF); + return; + } + + TST_EXP_EQ_LI(cs->nr_cache, 0); + TST_EXP_EQ_LI(cs->nr_dirty, 0); + TST_EXP_EQ_LI(cs->nr_writeback, 0); + TST_EXP_EQ_LI(cs->nr_evicted, 0); + TST_EXP_EQ_LI(cs->nr_recently_evicted, 0); +} + +static void run(void) +{ + TST_FD_FOREACH(fd) { + tst_res(TINFO, "%s -> ...", tst_fd_desc(&fd)); + check_cachestat(&fd); + } +} + +static struct tst_test test = { + .test_all = run, + .min_kver = "6.5", + .mount_device = 1, + .mntpoint = MNTPOINT, + .bufs = (struct tst_buffers []) { + {&cs, .size = sizeof(struct cachestat)}, + {&cs_range, .size = sizeof(struct cachestat_range)}, + {} + }, +}; +