From nobody Fri Apr 3 08:18:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BAE25C54EE9 for ; Wed, 14 Sep 2022 01:55:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229768AbiINBzK (ORCPT ); Tue, 13 Sep 2022 21:55:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229531AbiINBzG (ORCPT ); Tue, 13 Sep 2022 21:55:06 -0400 Received: from esa7.hc1455-7.c3s2.iphmx.com (esa7.hc1455-7.c3s2.iphmx.com [139.138.61.252]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA97822500; Tue, 13 Sep 2022 18:55:04 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6500,9779,10469"; a="67233255" X-IronPort-AV: E=Sophos;i="5.93,313,1654527600"; d="scan'208";a="67233255" Received: from unknown (HELO oym-r4.gw.nic.fujitsu.com) ([210.162.30.92]) by esa7.hc1455-7.c3s2.iphmx.com with ESMTP; 14 Sep 2022 10:55:01 +0900 Received: from oym-m1.gw.nic.fujitsu.com (oym-nat-oym-m1.gw.nic.fujitsu.com [192.168.87.58]) by oym-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id 761CDDA69A; Wed, 14 Sep 2022 10:55:00 +0900 (JST) Received: from oym-om3.fujitsu.com (oym-om3.o.css.fujitsu.com [10.85.58.163]) by oym-m1.gw.nic.fujitsu.com (Postfix) with ESMTP id B355DD996F; Wed, 14 Sep 2022 10:54:59 +0900 (JST) Received: from cn-r05-10.example.com (n3235113.np.ts.nmh.cs.fujitsu.co.jp [10.123.235.113]) by oym-om3.fujitsu.com (Postfix) with ESMTP id 997BC403DF707; Wed, 14 Sep 2022 10:54:59 +0900 (JST) From: Shaopeng Tan To: Fenghua Yu , Reinette Chatre , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, tan.shaopeng@jp.fujitsu.com Subject: [PATCH 1/5] selftests/resctrl: Clear unused initalization code in MBM tests Date: Wed, 14 Sep 2022 10:51:42 +0900 Message-Id: <20220914015147.3071025-2-tan.shaopeng@jp.fujitsu.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220914015147.3071025-1-tan.shaopeng@jp.fujitsu.com> References: <20220914015147.3071025-1-tan.shaopeng@jp.fujitsu.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" There is a comment "Set up shemata with 100% allocation on the first run" in function mbm_setup(), but the condition "num_of_runs =3D=3D 0" will never be met and write_schemata() will never be called to set schemata to 100%. Since umount/mount resctrl file system is run on each resctrl test, at the same time the default schemata will also be set to 100%. Clear unused initialization code in MBM test, such as CMT test. Signed-off-by: Shaopeng Tan --- tools/testing/selftests/resctrl/mbm_test.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/sel= ftests/resctrl/mbm_test.c index 8392e5c55ed0..38a3b3ad1c76 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -89,24 +89,19 @@ static int check_results(int span) static int mbm_setup(int num, ...) { struct resctrl_val_param *p; - static int num_of_runs; va_list param; - int ret =3D 0; - - /* Run NUM_OF_RUNS times */ - if (num_of_runs++ >=3D NUM_OF_RUNS) - return -1; =20 va_start(param, num); p =3D va_arg(param, struct resctrl_val_param *); va_end(param); =20 - /* Set up shemata with 100% allocation on the first run. */ - if (num_of_runs =3D=3D 0) - ret =3D write_schemata(p->ctrlgrp, "100", p->cpu_no, - p->resctrl_val); + /* Run NUM_OF_RUNS times */ + if (p->num_of_runs >=3D NUM_OF_RUNS) + return -1; + + p->num_of_runs++; =20 - return ret; + return 0; } =20 void mbm_test_cleanup(void) --=20 2.27.0 From nobody Fri Apr 3 08:18:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E665AC54EE9 for ; Wed, 14 Sep 2022 01:56:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230118AbiINB4R (ORCPT ); Tue, 13 Sep 2022 21:56:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229950AbiINB4N (ORCPT ); Tue, 13 Sep 2022 21:56:13 -0400 Received: from esa10.hc1455-7.c3s2.iphmx.com (esa10.hc1455-7.c3s2.iphmx.com [139.138.36.225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8DCC3FA04 for ; Tue, 13 Sep 2022 18:56:11 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6500,9779,10469"; a="76247790" X-IronPort-AV: E=Sophos;i="5.93,313,1654527600"; d="scan'208";a="76247790" Received: from unknown (HELO yto-r4.gw.nic.fujitsu.com) ([218.44.52.220]) by esa10.hc1455-7.c3s2.iphmx.com with ESMTP; 14 Sep 2022 10:55:05 +0900 Received: from yto-m2.gw.nic.fujitsu.com (yto-nat-yto-m2.gw.nic.fujitsu.com [192.168.83.65]) by yto-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id 107B7B63B4; Wed, 14 Sep 2022 10:55:04 +0900 (JST) Received: from oym-om3.fujitsu.com (oym-om3.o.css.fujitsu.com [10.85.58.163]) by yto-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id 4EF9AE6751; Wed, 14 Sep 2022 10:55:03 +0900 (JST) Received: from cn-r05-10.example.com (n3235113.np.ts.nmh.cs.fujitsu.co.jp [10.123.235.113]) by oym-om3.fujitsu.com (Postfix) with ESMTP id 24203403E058D; Wed, 14 Sep 2022 10:55:03 +0900 (JST) From: Shaopeng Tan To: Fenghua Yu , Reinette Chatre , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, tan.shaopeng@jp.fujitsu.com Subject: [PATCH 2/5] selftests/resctrl: Clear unused common codes called by CAT/MBA tests Date: Wed, 14 Sep 2022 10:51:44 +0900 Message-Id: <20220914015147.3071025-4-tan.shaopeng@jp.fujitsu.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220914015147.3071025-1-tan.shaopeng@jp.fujitsu.com> References: <20220914015147.3071025-1-tan.shaopeng@jp.fujitsu.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In CAT/MBA(allocation) tests, function write_schemata() is used to change the percentage of schemata. In CMT/MBM(monitoring) tests schemata only need to be set 100% once, and the default value of schemata is 100% which is set by executing mount/umout resctrl filesystem. In addition, write_schemata() was not currently called from CMT. Clean up unused CMT-related processing in function write_schemata(). Signed-off-by: Shaopeng Tan --- tools/testing/selftests/resctrl/resctrlfs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/se= lftests/resctrl/resctrlfs.c index 6f543e470ad4..349dce00472f 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -498,8 +498,7 @@ int write_schemata(char *ctrlgrp, char *schemata, int c= pu_no, char *resctrl_val) FILE *fp; =20 if (strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR)) && - strncmp(resctrl_val, CAT_STR, sizeof(CAT_STR)) && - strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) + strncmp(resctrl_val, CAT_STR, sizeof(CAT_STR))) return -ENOENT; =20 if (!schemata) { @@ -520,8 +519,7 @@ int write_schemata(char *ctrlgrp, char *schemata, int c= pu_no, char *resctrl_val) else sprintf(controlgroup, "%s/schemata", RESCTRL_PATH); =20 - if (!strncmp(resctrl_val, CAT_STR, sizeof(CAT_STR)) || - !strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) + if (!strncmp(resctrl_val, CAT_STR, sizeof(CAT_STR))) sprintf(schema, "%s%d%c%s", "L3:", resource_id, '=3D', schemata); if (!strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR))) sprintf(schema, "%s%d%c%s", "MB:", resource_id, '=3D', schemata); --=20 2.27.0 From nobody Fri Apr 3 08:18:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5E4DC54EE9 for ; Wed, 14 Sep 2022 01:56:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230120AbiINB4V (ORCPT ); Tue, 13 Sep 2022 21:56:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230105AbiINB4P (ORCPT ); Tue, 13 Sep 2022 21:56:15 -0400 Received: from esa9.hc1455-7.c3s2.iphmx.com (esa9.hc1455-7.c3s2.iphmx.com [139.138.36.223]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C03833A4B8 for ; Tue, 13 Sep 2022 18:56:12 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6500,9779,10469"; a="76604944" X-IronPort-AV: E=Sophos;i="5.93,313,1654527600"; d="scan'208";a="76604944" Received: from unknown (HELO yto-r4.gw.nic.fujitsu.com) ([218.44.52.220]) by esa9.hc1455-7.c3s2.iphmx.com with ESMTP; 14 Sep 2022 10:55:05 +0900 Received: from yto-m4.gw.nic.fujitsu.com (yto-nat-yto-m4.gw.nic.fujitsu.com [192.168.83.67]) by yto-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id 14C38ADA71; Wed, 14 Sep 2022 10:55:05 +0900 (JST) Received: from oym-om3.fujitsu.com (oym-om3.o.css.fujitsu.com [10.85.58.163]) by yto-m4.gw.nic.fujitsu.com (Postfix) with ESMTP id 5990EE6478; Wed, 14 Sep 2022 10:55:04 +0900 (JST) Received: from cn-r05-10.example.com (n3235113.np.ts.nmh.cs.fujitsu.co.jp [10.123.235.113]) by oym-om3.fujitsu.com (Postfix) with ESMTP id 321E1403E058D; Wed, 14 Sep 2022 10:55:04 +0900 (JST) From: Shaopeng Tan To: Fenghua Yu , Reinette Chatre , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, tan.shaopeng@jp.fujitsu.com Subject: [PATCH 3/5] selftests/resctrl: Remove duplicate codes that clear each test result file Date: Wed, 14 Sep 2022 10:51:45 +0900 Message-Id: <20220914015147.3071025-5-tan.shaopeng@jp.fujitsu.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220914015147.3071025-1-tan.shaopeng@jp.fujitsu.com> References: <20220914015147.3071025-1-tan.shaopeng@jp.fujitsu.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Before exiting each test function(run_cmt/cat/mbm/mba_test()), test results are printed by ksft_print_msg() and then temporary result files are cleaned by function cmt/cat/mbm/mba_test_cleanup(). However, before running ksft_print_msg(), function cmt/cat/mbm/mba_test_cleanup() has been run in each test function as follows: cmt_resctrl_val() cat_perf_miss_val() mba_schemata_change() mbm_bw_change() Remove duplicate codes that clear each test result file. Signed-off-by: Shaopeng Tan --- tools/testing/selftests/resctrl/cat_test.c | 1 - tools/testing/selftests/resctrl/cmt_test.c | 2 -- tools/testing/selftests/resctrl/mba_test.c | 2 -- tools/testing/selftests/resctrl/mbm_test.c | 2 -- 4 files changed, 7 deletions(-) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/sel= ftests/resctrl/cat_test.c index 1c5e90c63254..d1134f66469f 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -221,7 +221,6 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_ty= pe) kill(bm_pid, SIGKILL); } =20 - cat_test_cleanup(); if (bm_pid) umount_resctrlfs(); =20 diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/sel= ftests/resctrl/cmt_test.c index 8968e36db99d..b3b17fb876f4 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -139,7 +139,5 @@ int cmt_resctrl_val(int cpu_no, int n, char **benchmark= _cmd) if (ret) return ret; =20 - cmt_test_cleanup(); - return 0; } diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/sel= ftests/resctrl/mba_test.c index 1a1bdb6180cf..93ffacb416df 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -166,7 +166,5 @@ int mba_schemata_change(int cpu_no, char *bw_report, ch= ar **benchmark_cmd) if (ret) return ret; =20 - mba_test_cleanup(); - return 0; } diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/sel= ftests/resctrl/mbm_test.c index 38a3b3ad1c76..a453db4c221f 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -134,7 +134,5 @@ int mbm_bw_change(int span, int cpu_no, char *bw_report= , char **benchmark_cmd) if (ret) return ret; =20 - mbm_test_cleanup(); - return 0; } --=20 2.27.0 From nobody Fri Apr 3 08:18:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9E74ECAAD8 for ; Wed, 14 Sep 2022 02:18:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229929AbiINCSs (ORCPT ); Tue, 13 Sep 2022 22:18:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229637AbiINCSq (ORCPT ); Tue, 13 Sep 2022 22:18:46 -0400 Received: from esa9.hc1455-7.c3s2.iphmx.com (esa9.hc1455-7.c3s2.iphmx.com [139.138.36.223]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46077564D1 for ; Tue, 13 Sep 2022 19:18:44 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6500,9779,10469"; a="76604947" X-IronPort-AV: E=Sophos;i="5.93,313,1654527600"; d="scan'208";a="76604947" Received: from unknown (HELO yto-r2.gw.nic.fujitsu.com) ([218.44.52.218]) by esa9.hc1455-7.c3s2.iphmx.com with ESMTP; 14 Sep 2022 10:55:07 +0900 Received: from yto-m2.gw.nic.fujitsu.com (yto-nat-yto-m2.gw.nic.fujitsu.com [192.168.83.65]) by yto-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id D6F41D6252; Wed, 14 Sep 2022 10:55:06 +0900 (JST) Received: from oym-om3.fujitsu.com (oym-om3.o.css.fujitsu.com [10.85.58.163]) by yto-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id 2C70FD35C1; Wed, 14 Sep 2022 10:55:06 +0900 (JST) Received: from cn-r05-10.example.com (n3235113.np.ts.nmh.cs.fujitsu.co.jp [10.123.235.113]) by oym-om3.fujitsu.com (Postfix) with ESMTP id F031F403E0598; Wed, 14 Sep 2022 10:55:05 +0900 (JST) From: Shaopeng Tan To: Fenghua Yu , Reinette Chatre , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, tan.shaopeng@jp.fujitsu.com Subject: [PATCH 4/5] selftests/resctrl: Kill the child process before exiting the parent process if an exception occurs Date: Wed, 14 Sep 2022 10:51:46 +0900 Message-Id: <20220914015147.3071025-6-tan.shaopeng@jp.fujitsu.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220914015147.3071025-1-tan.shaopeng@jp.fujitsu.com> References: <20220914015147.3071025-1-tan.shaopeng@jp.fujitsu.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" After creating a child process with fork() in CAT test, if there is an exception occurs, the parent process will be terminated immediately, but the child process will not be killed and umount_resctrlfs() will not be called. When fork() is used in CMT/MBA/MBM tests. If an exception occurs, before parent process exiting, the child process is killed and umount_resctrlfs() is called. Kill the child process before exiting the parent process if an exception occurs in CAT test, like in CMT/MBA/MBM tests. Signed-off-by: Shaopeng Tan --- tools/testing/selftests/resctrl/cat_test.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/sel= ftests/resctrl/cat_test.c index d1134f66469f..f62da445acbb 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -186,11 +186,11 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_= type) =20 ret =3D cat_val(¶m); if (ret) - return ret; + goto out; =20 ret =3D check_results(¶m); if (ret) - return ret; + goto out; =20 if (bm_pid =3D=3D 0) { /* Tell parent that child is ready */ @@ -200,7 +200,8 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_ty= pe) sizeof(pipe_message)) { close(pipefd[1]); perror("# failed signaling parent process"); - return errno; + ret =3D errno; + goto out; } =20 close(pipefd[1]); @@ -218,11 +219,11 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_= type) } } close(pipefd[0]); - kill(bm_pid, SIGKILL); } =20 - if (bm_pid) - umount_resctrlfs(); +out: + kill(bm_pid, SIGKILL); + umount_resctrlfs(); =20 - return 0; + return ret; } --=20 2.27.0 From nobody Fri Apr 3 08:18:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABD7FC54EE9 for ; Wed, 14 Sep 2022 01:56:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230146AbiINB4a (ORCPT ); Tue, 13 Sep 2022 21:56:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230112AbiINB4Q (ORCPT ); Tue, 13 Sep 2022 21:56:16 -0400 Received: from esa10.hc1455-7.c3s2.iphmx.com (esa10.hc1455-7.c3s2.iphmx.com [139.138.36.225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09BDE476F9 for ; Tue, 13 Sep 2022 18:56:13 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6500,9779,10469"; a="76247799" X-IronPort-AV: E=Sophos;i="5.93,313,1654527600"; d="scan'208";a="76247799" Received: from unknown (HELO yto-r1.gw.nic.fujitsu.com) ([218.44.52.217]) by esa10.hc1455-7.c3s2.iphmx.com with ESMTP; 14 Sep 2022 10:55:08 +0900 Received: from yto-m3.gw.nic.fujitsu.com (yto-nat-yto-m3.gw.nic.fujitsu.com [192.168.83.66]) by yto-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id DA91EDAFCF; Wed, 14 Sep 2022 10:55:07 +0900 (JST) Received: from oym-om3.fujitsu.com (oym-om3.o.css.fujitsu.com [10.85.58.163]) by yto-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id 38326D214B; Wed, 14 Sep 2022 10:55:07 +0900 (JST) Received: from cn-r05-10.example.com (n3235113.np.ts.nmh.cs.fujitsu.co.jp [10.123.235.113]) by oym-om3.fujitsu.com (Postfix) with ESMTP id 1157D403E058D; Wed, 14 Sep 2022 10:55:07 +0900 (JST) From: Shaopeng Tan To: Fenghua Yu , Reinette Chatre , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, tan.shaopeng@jp.fujitsu.com Subject: [PATCH 5/5] selftests/resctrl: Flush stdout file buffer before executing fork() Date: Wed, 14 Sep 2022 10:51:47 +0900 Message-Id: <20220914015147.3071025-7-tan.shaopeng@jp.fujitsu.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220914015147.3071025-1-tan.shaopeng@jp.fujitsu.com> References: <20220914015147.3071025-1-tan.shaopeng@jp.fujitsu.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" When a process has buffered output, a child process created by fork() will also copy buffered output. When using kselftest framework, the output (resctrl test result message) will be printed multiple times. Add fflush() to flush out the buffered output before executing fork(). Signed-off-by: Shaopeng Tan Reviewed-by: Reinette Chatre --- tools/testing/selftests/resctrl/cat_test.c | 1 + tools/testing/selftests/resctrl/resctrl_val.c | 1 + tools/testing/selftests/resctrl/resctrlfs.c | 1 + 3 files changed, 3 insertions(+) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/sel= ftests/resctrl/cat_test.c index f62da445acbb..69d17f5f4606 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -167,6 +167,7 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_ty= pe) return errno; } =20 + fflush(stdout); bm_pid =3D fork(); =20 /* Set param values for child thread which will be allocated bitmask diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/= selftests/resctrl/resctrl_val.c index b32b96356ec7..6948843bf995 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -629,6 +629,7 @@ int resctrl_val(char **benchmark_cmd, struct resctrl_va= l_param *param) * Fork to start benchmark, save child's pid so that it can be killed * when needed */ + fflush(stdout); bm_pid =3D fork(); if (bm_pid =3D=3D -1) { perror("# Unable to fork"); diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/se= lftests/resctrl/resctrlfs.c index 349dce00472f..a8cea64de65e 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -674,6 +674,7 @@ int filter_dmesg(void) perror("pipe"); return ret; } + fflush(stdout); pid =3D fork(); if (pid =3D=3D 0) { close(pipefds[0]); --=20 2.27.0 From nobody Fri Apr 3 08:18:04 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7511ECAAD8 for ; Wed, 14 Sep 2022 01:55:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230100AbiINBzP (ORCPT ); Tue, 13 Sep 2022 21:55:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229665AbiINBzH (ORCPT ); Tue, 13 Sep 2022 21:55:07 -0400 Received: from esa7.hc1455-7.c3s2.iphmx.com (esa7.hc1455-7.c3s2.iphmx.com [139.138.61.252]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 869C42CE1E; Tue, 13 Sep 2022 18:55:06 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6500,9779,10469"; a="67233269" X-IronPort-AV: E=Sophos;i="5.93,313,1654527600"; d="scan'208";a="67233269" Received: from unknown (HELO yto-r1.gw.nic.fujitsu.com) ([218.44.52.217]) by esa7.hc1455-7.c3s2.iphmx.com with ESMTP; 14 Sep 2022 10:55:03 +0900 Received: from yto-m2.gw.nic.fujitsu.com (yto-nat-yto-m2.gw.nic.fujitsu.com [192.168.83.65]) by yto-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id ECED1DAFD0; Wed, 14 Sep 2022 10:55:02 +0900 (JST) Received: from oym-om3.fujitsu.com (oym-om3.o.css.fujitsu.com [10.85.58.163]) by yto-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id 3E55BE676E; Wed, 14 Sep 2022 10:55:02 +0900 (JST) Received: from cn-r05-10.example.com (n3235113.np.ts.nmh.cs.fujitsu.co.jp [10.123.235.113]) by oym-om3.fujitsu.com (Postfix) with ESMTP id 073F8403E0587; Wed, 14 Sep 2022 10:55:02 +0900 (JST) From: Shaopeng Tan To: Fenghua Yu , Reinette Chatre , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, tan.shaopeng@jp.fujitsu.com Subject: [PATCH] selftests/resctrl: Return MBA check result and make it to output message Date: Wed, 14 Sep 2022 10:51:43 +0900 Message-Id: <20220914015147.3071025-3-tan.shaopeng@jp.fujitsu.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220914015147.3071025-1-tan.shaopeng@jp.fujitsu.com> References: <20220914015147.3071025-1-tan.shaopeng@jp.fujitsu.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Since MBA check result is not returned, the MBA test result message is always output as OK regardless of whether the MBA check result is true or fail. Make output message to be "not ok" if MBA check result is failed. This patch is based on Linux v6.0-rc5 Signed-off-by: Shaopeng Tan Reviewed-by: Reinette Chatre --- tools/testing/selftests/resctrl/mba_test.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/sel= ftests/resctrl/mba_test.c index 93ffacb416df..e7dfeb697e5e 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -51,7 +51,7 @@ static int mba_setup(int num, ...) return 0; } =20 -static void show_mba_info(unsigned long *bw_imc, unsigned long *bw_resc) +static bool show_mba_info(unsigned long *bw_imc, unsigned long *bw_resc) { int allocation, runs; bool failed =3D false; @@ -97,6 +97,8 @@ static void show_mba_info(unsigned long *bw_imc, unsigned= long *bw_resc) failed ? "Fail:" : "Pass:"); if (failed) ksft_print_msg("At least one test failed\n"); + + return failed; } =20 static int check_results(void) @@ -132,9 +134,7 @@ static int check_results(void) =20 fclose(fp); =20 - show_mba_info(bw_imc, bw_resc); - - return 0; + return show_mba_info(bw_imc, bw_resc); } =20 void mba_test_cleanup(void) --=20 2.27.0