From patchwork Thu May 16 10:42:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1935935 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=ub8yMzaI; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=3YLpCjPf; 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=ub8yMzaI; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=3YLpCjPf; 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 4Vg6B803d5z20KF for ; Thu, 16 May 2024 20:42:56 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id AC5903CFA94 for ; Thu, 16 May 2024 12:42:53 +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) server-digest SHA384) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 784333CF9C7 for ; Thu, 16 May 2024 12:42:34 +0200 (CEST) Authentication-Results: in-5.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-5.smtp.seeweb.it (Postfix) with ESMTPS id 8CF466005EC for ; Thu, 16 May 2024 12:42:33 +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 B5909347C2; Thu, 16 May 2024 10:42:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715856152; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Akm5jI4sgGLKvCuy27wMcTLPdn8Sdoz31HzTz1PBRb4=; b=ub8yMzaIPAmAcmbye3ZbtyL1immfKLNOpGosrvvLDMemdddHNRWUL+J3wq9tptpvSzvhE1 eBwdlLkIKyQwVAr64xALmPB3ujmlLA8JdZhjaMyawVV70T8dHPzRTKTrTZhBOpQ3ZwfBa6 2c7ETWgSbvY4Q97+FD/z1gjbUxTsVNg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715856152; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Akm5jI4sgGLKvCuy27wMcTLPdn8Sdoz31HzTz1PBRb4=; b=3YLpCjPfk/m6bB20/suPXQhp1aOUb3NrT1hq43OvY29372Wp/MAr8RcwUd3fKIj5yX6Mrj Vj/7DehBziKA8+AA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=ub8yMzaI; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=3YLpCjPf DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715856152; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Akm5jI4sgGLKvCuy27wMcTLPdn8Sdoz31HzTz1PBRb4=; b=ub8yMzaIPAmAcmbye3ZbtyL1immfKLNOpGosrvvLDMemdddHNRWUL+J3wq9tptpvSzvhE1 eBwdlLkIKyQwVAr64xALmPB3ujmlLA8JdZhjaMyawVV70T8dHPzRTKTrTZhBOpQ3ZwfBa6 2c7ETWgSbvY4Q97+FD/z1gjbUxTsVNg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715856152; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Akm5jI4sgGLKvCuy27wMcTLPdn8Sdoz31HzTz1PBRb4=; b=3YLpCjPfk/m6bB20/suPXQhp1aOUb3NrT1hq43OvY29372Wp/MAr8RcwUd3fKIj5yX6Mrj Vj/7DehBziKA8+AA== 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 9AB5B13A69; Thu, 16 May 2024 10:42:32 +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 yM9wJBjjRWbwGQAAD6G6ig (envelope-from ); Thu, 16 May 2024 10:42:32 +0000 From: Andrea Cervesato To: ltp@lists.linux.it Date: Thu, 16 May 2024 12:42:25 +0200 Message-Id: <20240516104227.25381-2-andrea.cervesato@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240516104227.25381-1-andrea.cervesato@suse.de> References: <20240516104227.25381-1-andrea.cervesato@suse.de> MIME-Version: 1.0 X-Spam-Level: X-Spamd-Result: default: False [-5.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; DWL_DNSWL_MED(-2.00)[suse.de:dkim]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; 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)[]; 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]; FUZZY_BLOCKED(0.00)[rspamd.com]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(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] X-Rspamd-Action: no action X-Rspamd-Queue-Id: B5909347C2 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Score: -5.01 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 v1 1/3] 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(+) create mode 100644 include/lapi/mman.h diff --git a/configure.ac b/configure.ac index 85c5739c4..8d59cb605 100644 --- a/configure.ac +++ b/configure.ac @@ -90,6 +90,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 \ @@ -233,6 +234,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 2cb6c2d87..1c0218eae 100644 --- a/include/lapi/syscalls/aarch64.in +++ b/include/lapi/syscalls/aarch64.in @@ -297,4 +297,5 @@ faccessat2 439 epoll_pwait2 441 quotactl_fd 443 futex_waitv 449 +cachestat 451 _sysctl 1078 diff --git a/include/lapi/syscalls/arc.in b/include/lapi/syscalls/arc.in index 3e2ee9061..5d7cd6ca4 100644 --- a/include/lapi/syscalls/arc.in +++ b/include/lapi/syscalls/arc.in @@ -317,3 +317,4 @@ faccessat2 439 epoll_pwait2 441 quotactl_fd 443 futex_waitv 449 +cachestat 451 diff --git a/include/lapi/syscalls/arm.in b/include/lapi/syscalls/arm.in index 7bdbca533..e41a7e576 100644 --- a/include/lapi/syscalls/arm.in +++ b/include/lapi/syscalls/arm.in @@ -395,3 +395,4 @@ faccessat2 (__NR_SYSCALL_BASE+439) epoll_pwait2 (__NR_SYSCALL_BASE+441) quotactl_fd (__NR_SYSCALL_BASE+443) 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 8ebdafafb..2772e7334 100644 --- a/include/lapi/syscalls/hppa.in +++ b/include/lapi/syscalls/hppa.in @@ -44,3 +44,4 @@ faccessat2 439 epoll_pwait2 441 quotactl_fd 443 futex_waitv 449 +cachestat 451 diff --git a/include/lapi/syscalls/i386.in b/include/lapi/syscalls/i386.in index 1472631c4..2d341182e 100644 --- a/include/lapi/syscalls/i386.in +++ b/include/lapi/syscalls/i386.in @@ -431,3 +431,4 @@ faccessat2 439 epoll_pwait2 441 quotactl_fd 443 futex_waitv 449 +cachestat 451 diff --git a/include/lapi/syscalls/ia64.in b/include/lapi/syscalls/ia64.in index 0ea6e9722..141c6be51 100644 --- a/include/lapi/syscalls/ia64.in +++ b/include/lapi/syscalls/ia64.in @@ -344,3 +344,4 @@ faccessat2 1463 epoll_pwait2 1465 quotactl_fd 1467 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 e818c9d92..3b08add08 100644 --- a/include/lapi/syscalls/mips_n32.in +++ b/include/lapi/syscalls/mips_n32.in @@ -371,3 +371,4 @@ epoll_pwait2 6441 mount_setattr 6442 quotactl_fd 6443 futex_waitv 6449 +cachestat 6451 diff --git a/include/lapi/syscalls/mips_n64.in b/include/lapi/syscalls/mips_n64.in index 6e15f43b3..bfc65cd2b 100644 --- a/include/lapi/syscalls/mips_n64.in +++ b/include/lapi/syscalls/mips_n64.in @@ -347,3 +347,4 @@ epoll_pwait2 5441 mount_setattr 5442 quotactl_fd 5443 futex_waitv 5449 +cachestat 5451 diff --git a/include/lapi/syscalls/mips_o32.in b/include/lapi/syscalls/mips_o32.in index 921d5d331..8dc542b48 100644 --- a/include/lapi/syscalls/mips_o32.in +++ b/include/lapi/syscalls/mips_o32.in @@ -417,3 +417,4 @@ epoll_pwait2 4441 mount_setattr 4442 quotactl_fd 4443 futex_waitv 4449 +cachestat 4451 diff --git a/include/lapi/syscalls/powerpc.in b/include/lapi/syscalls/powerpc.in index 545d9d3d6..67e928951 100644 --- a/include/lapi/syscalls/powerpc.in +++ b/include/lapi/syscalls/powerpc.in @@ -424,3 +424,4 @@ faccessat2 439 epoll_pwait2 441 quotactl_fd 443 futex_waitv 449 +cachestat 451 diff --git a/include/lapi/syscalls/powerpc64.in b/include/lapi/syscalls/powerpc64.in index 545d9d3d6..67e928951 100644 --- a/include/lapi/syscalls/powerpc64.in +++ b/include/lapi/syscalls/powerpc64.in @@ -424,3 +424,4 @@ faccessat2 439 epoll_pwait2 441 quotactl_fd 443 futex_waitv 449 +cachestat 451 diff --git a/include/lapi/syscalls/s390.in b/include/lapi/syscalls/s390.in index 7213ac5f8..b456ea408 100644 --- a/include/lapi/syscalls/s390.in +++ b/include/lapi/syscalls/s390.in @@ -411,3 +411,4 @@ faccessat2 439 epoll_pwait2 441 quotactl_fd 443 futex_waitv 449 +cachestat 451 diff --git a/include/lapi/syscalls/s390x.in b/include/lapi/syscalls/s390x.in index 879012e2b..2c57eacdf 100644 --- a/include/lapi/syscalls/s390x.in +++ b/include/lapi/syscalls/s390x.in @@ -359,3 +359,4 @@ faccessat2 439 epoll_pwait2 441 quotactl_fd 443 futex_waitv 449 +cachestat 451 diff --git a/include/lapi/syscalls/sh.in b/include/lapi/syscalls/sh.in index 7d5192a27..25eb9bb26 100644 --- a/include/lapi/syscalls/sh.in +++ b/include/lapi/syscalls/sh.in @@ -405,3 +405,4 @@ faccessat2 439 epoll_pwait2 441 quotactl_fd 443 futex_waitv 449 +cachestat 451 diff --git a/include/lapi/syscalls/sparc.in b/include/lapi/syscalls/sparc.in index 91d2fb1c2..e934591dd 100644 --- a/include/lapi/syscalls/sparc.in +++ b/include/lapi/syscalls/sparc.in @@ -410,3 +410,4 @@ faccessat2 439 epoll_pwait2 441 quotactl_fd 443 futex_waitv 449 +cachestat 451 diff --git a/include/lapi/syscalls/sparc64.in b/include/lapi/syscalls/sparc64.in index 1f2fc59b7..4c489e38d 100644 --- a/include/lapi/syscalls/sparc64.in +++ b/include/lapi/syscalls/sparc64.in @@ -375,3 +375,4 @@ faccessat2 439 epoll_pwait2 441 quotactl_fd 443 futex_waitv 449 +cachestat 451 diff --git a/include/lapi/syscalls/x86_64.in b/include/lapi/syscalls/x86_64.in index dc61aa56e..4afea6019 100644 --- a/include/lapi/syscalls/x86_64.in +++ b/include/lapi/syscalls/x86_64.in @@ -352,6 +352,7 @@ faccessat2 439 epoll_pwait2 441 quotactl_fd 443 futex_waitv 449 +cachestat 451 rt_sigaction 512 rt_sigreturn 513 ioctl 514 From patchwork Thu May 16 10:42:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1935936 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=n3cNoRM+; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Udfm2vHk; 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=n3cNoRM+; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Udfm2vHk; 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 4Vg6BS0gGRz20KF for ; Thu, 16 May 2024 20:43:12 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id C04033CFA0D for ; Thu, 16 May 2024 12:43:09 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [IPv6:2001:4b78:1:20::7]) (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 picard.linux.it (Postfix) with ESMTPS id B899A3CFA6B for ; Thu, 16 May 2024 12:42:34 +0200 (CEST) Authentication-Results: in-7.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-7.smtp.seeweb.it (Postfix) with ESMTPS id 3B551200BB7 for ; Thu, 16 May 2024 12:42:34 +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 DB388347C3; Thu, 16 May 2024 10:42:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715856152; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/Sduz6UrFj+8hawv2qrNVKlEIVirWdk2qziGH3mrTTw=; b=n3cNoRM+To9K+a4Q9AEBkrCfXj5RjMy0hQ6i4axxpcRtG57oD9gedIAQo/f3gw4TmXv1gq NHfCyg1gc4i8fQ37//nzKWlqi+/f6tvLmv8eGxIY1dxa9N9jNoE9zp0H9Wneu8UDnGgFVY 263TthMn9a4MEuV7yZEHeofjpV9sBwk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715856152; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/Sduz6UrFj+8hawv2qrNVKlEIVirWdk2qziGH3mrTTw=; b=Udfm2vHk1aE/DIUOnKQ0ra3OQsZIS86p5jBWWZ2A4l+7IdMafVQUy+cMUpmJwE/A9Emsu1 Voi+klHFzfHH5rBA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=n3cNoRM+; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Udfm2vHk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715856152; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/Sduz6UrFj+8hawv2qrNVKlEIVirWdk2qziGH3mrTTw=; b=n3cNoRM+To9K+a4Q9AEBkrCfXj5RjMy0hQ6i4axxpcRtG57oD9gedIAQo/f3gw4TmXv1gq NHfCyg1gc4i8fQ37//nzKWlqi+/f6tvLmv8eGxIY1dxa9N9jNoE9zp0H9Wneu8UDnGgFVY 263TthMn9a4MEuV7yZEHeofjpV9sBwk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715856152; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/Sduz6UrFj+8hawv2qrNVKlEIVirWdk2qziGH3mrTTw=; b=Udfm2vHk1aE/DIUOnKQ0ra3OQsZIS86p5jBWWZ2A4l+7IdMafVQUy+cMUpmJwE/A9Emsu1 Voi+klHFzfHH5rBA== 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 BC72213A6A; Thu, 16 May 2024 10:42:32 +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 uBnALBjjRWbwGQAAD6G6ig (envelope-from ); Thu, 16 May 2024 10:42:32 +0000 From: Andrea Cervesato To: ltp@lists.linux.it Date: Thu, 16 May 2024 12:42:26 +0200 Message-Id: <20240516104227.25381-3-andrea.cervesato@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240516104227.25381-1-andrea.cervesato@suse.de> References: <20240516104227.25381-1-andrea.cervesato@suse.de> MIME-Version: 1.0 X-Spam-Score: -5.01 X-Rspamd-Action: no action X-Rspamd-Queue-Id: DB388347C3 X-Spam-Level: X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-5.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; DWL_DNSWL_MED(-2.00)[suse.de:dkim]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; 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)[]; 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]; FUZZY_BLOCKED(0.00)[rspamd.com]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo, imap1.dmz-prg2.suse.org:rdns, suse.de:dkim] 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-7.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-7.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v1 2/3] Add cachestat01 and cachestat01A tests 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. The cachestat01 covers the first scenario and cachestat01A covers the second one. Signed-off-by: Andrea Cervesato --- runtest/syscalls | 3 + .../kernel/syscalls/cachestat/.gitignore | 1 + testcases/kernel/syscalls/cachestat/Makefile | 10 ++ .../kernel/syscalls/cachestat/cachestat.h | 27 +++++ .../kernel/syscalls/cachestat/cachestat01.c | 102 ++++++++++++++++++ 5 files changed, 143 insertions(+) create mode 100644 testcases/kernel/syscalls/cachestat/.gitignore create mode 100644 testcases/kernel/syscalls/cachestat/Makefile create mode 100644 testcases/kernel/syscalls/cachestat/cachestat.h create mode 100644 testcases/kernel/syscalls/cachestat/cachestat01.c diff --git a/runtest/syscalls b/runtest/syscalls index cf06ee563..961775cf7 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -62,6 +62,9 @@ capset04 capset04 cacheflush01 cacheflush01 +cachestat01 cachestat01 +cachestat01A cachestat01 -s + 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..7362a9dcf --- /dev/null +++ b/testcases/kernel/syscalls/cachestat/cachestat01.c @@ -0,0 +1,102 @@ +// 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" +#define NUMPAGES 32 + +static char *data; +static int file_size; +static struct cachestat *cs; +static struct cachestat_range *cs_range; +static char *run_fsync; + +static void run(void) +{ + int fd; + + memset(cs, 0, sizeof(struct cachestat)); + + fd = SAFE_OPEN(FILENAME, O_RDWR | O_CREAT, 0600); + SAFE_WRITE(0, fd, data, file_size); + + if (run_fsync) + fsync(fd); + + TST_EXP_PASS(cachestat(fd, cs_range, cs, 0)); + print_cachestat(cs); + + TST_EXP_EQ_LI(cs->nr_cache + cs->nr_evicted, NUMPAGES); + + if (run_fsync) + TST_EXP_EQ_LI(cs->nr_dirty, 0); + + SAFE_CLOSE(fd); + SAFE_UNLINK(FILENAME); +} + +static void setup(void) +{ + int page_size; + + page_size = (int)sysconf(_SC_PAGESIZE); + file_size = page_size * NUMPAGES; + + data = SAFE_MALLOC(file_size); + memset(data, 'a', file_size); + + cs_range->off = 0; + cs_range->len = file_size; +} + +static void cleanup(void) +{ + if (data) + free(data); +} + +static struct tst_test test = { + .test_all = run, + .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)}, + {} + }, + .options = (struct tst_option[]) { + {"s", &run_fsync, "Synchronize file with storage device"}, + {}, + }, +}; From patchwork Thu May 16 10:42:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1935934 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=GNHixUl5; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Impg/Qm7; 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=GNHixUl5; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Impg/Qm7; 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 4Vg69v05rwz20KF for ; Thu, 16 May 2024 20:42:40 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id DA1733CF9D5 for ; Thu, 16 May 2024 12:42:36 +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 46FB73CF9C7 for ; Thu, 16 May 2024 12:42:34 +0200 (CEST) Authentication-Results: in-2.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-2.smtp.seeweb.it (Postfix) with ESMTPS id 9D3E4601FC2 for ; Thu, 16 May 2024 12:42:33 +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 12DB35C194; Thu, 16 May 2024 10:42:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715856153; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bmnso/iw81B7NPXDWWCJBw2iM0w1yyRIvNgZXTroXjw=; b=GNHixUl5vDpbayNc9HqKP+xLFkNelIiQTW7O/DwfaDI9lOE1OuK+ban7nlynmvoF770xw5 lVx7ep4PwcNG1k8V7G9TYQlGjpK2CABpoIXXWlG/5RqwbyZoPOJkwxIVBNIy7BZ74Bm3Vb VAsMBGGcxyNusCh1bMBSPxHrYZKj/Jw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715856153; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bmnso/iw81B7NPXDWWCJBw2iM0w1yyRIvNgZXTroXjw=; b=Impg/Qm7mFsmsOvppEK6E5n2Y3g8eurfLtrVrlkxs6HpSRmJ+D0FrqEurFLExbGDusjnV0 UlHIxCe9FK9aeVAw== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=GNHixUl5; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="Impg/Qm7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715856153; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bmnso/iw81B7NPXDWWCJBw2iM0w1yyRIvNgZXTroXjw=; b=GNHixUl5vDpbayNc9HqKP+xLFkNelIiQTW7O/DwfaDI9lOE1OuK+ban7nlynmvoF770xw5 lVx7ep4PwcNG1k8V7G9TYQlGjpK2CABpoIXXWlG/5RqwbyZoPOJkwxIVBNIy7BZ74Bm3Vb VAsMBGGcxyNusCh1bMBSPxHrYZKj/Jw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715856153; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bmnso/iw81B7NPXDWWCJBw2iM0w1yyRIvNgZXTroXjw=; b=Impg/Qm7mFsmsOvppEK6E5n2Y3g8eurfLtrVrlkxs6HpSRmJ+D0FrqEurFLExbGDusjnV0 UlHIxCe9FK9aeVAw== 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 DF4AF137C3; Thu, 16 May 2024 10:42:32 +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 EIw9NRjjRWbwGQAAD6G6ig (envelope-from ); Thu, 16 May 2024 10:42:32 +0000 From: Andrea Cervesato To: ltp@lists.linux.it Date: Thu, 16 May 2024 12:42:27 +0200 Message-Id: <20240516104227.25381-4-andrea.cervesato@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240516104227.25381-1-andrea.cervesato@suse.de> References: <20240516104227.25381-1-andrea.cervesato@suse.de> MIME-Version: 1.0 X-Spam-Level: X-Spamd-Result: default: False [-5.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; DWL_DNSWL_MED(-2.00)[suse.de:dkim]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; 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)[]; 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]; FUZZY_BLOCKED(0.00)[rspamd.com]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo, imap1.dmz-prg2.suse.org:rdns, suse.de:dkim] X-Rspamd-Action: no action X-Rspamd-Queue-Id: 12DB35C194 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Score: -5.01 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 v1 3/3] 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 + .../kernel/syscalls/cachestat/.gitignore | 1 + .../kernel/syscalls/cachestat/cachestat02.c | 82 +++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 testcases/kernel/syscalls/cachestat/cachestat02.c diff --git a/runtest/syscalls b/runtest/syscalls index 961775cf7..1b0a3bb23 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -64,6 +64,7 @@ cacheflush01 cacheflush01 cachestat01 cachestat01 cachestat01A cachestat01 -s +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..0221cead4 --- /dev/null +++ b/testcases/kernel/syscalls/cachestat/cachestat02.c @@ -0,0 +1,82 @@ +// 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" +#define NUMPAGES 32 + +static char *data; +static int file_size; +static struct cachestat *cs; +static struct cachestat_range *cs_range; + +static void run(void) +{ + int fd; + + 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"); + + SAFE_FTRUNCATE(fd, file_size); + SAFE_WRITE(0, fd, data, file_size); + + TST_EXP_PASS(cachestat(fd, cs_range, cs, 0)); + print_cachestat(cs); + + TST_EXP_EQ_LI(cs->nr_cache + cs->nr_evicted, NUMPAGES); + + SAFE_CLOSE(fd); + shm_unlink(FILENAME); +} + +static void setup(void) +{ + int page_size; + + page_size = (int)sysconf(_SC_PAGESIZE); + file_size = page_size * NUMPAGES; + + data = SAFE_MALLOC(file_size); + memset(data, 'a', file_size); + + cs_range->off = 0; + cs_range->len = file_size; +} + +static void cleanup(void) +{ + if (data) + free(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)}, + {} + }, +};