From patchwork Thu Nov 17 01:05:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaopeng Tan X-Patchwork-Id: 21361 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp152076wrr; Wed, 16 Nov 2022 17:12:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf4yDbEZQabFbGvupsi9WuBAnbfz3YeE/8yLg/fi64ZgPcOsagB/A1Wqlk5sy4zZay2RZOcW X-Received: by 2002:aa7:c98a:0:b0:462:d288:16f8 with SMTP id c10-20020aa7c98a000000b00462d28816f8mr255190edt.170.1668647570311; Wed, 16 Nov 2022 17:12:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668647570; cv=none; d=google.com; s=arc-20160816; b=DLp9CqRLIBaqaZcL3OXRPIpEC87KRBuhW7t6U8NgT5Gdpjndcfm1PDEQe6shRUhTHN 0chjqtCrh1lcKMJnOOrUd6CeEmYZW1pd40sj5Er+UGemL3TQ1dtaoFD84mwG28h2D+5s V5em5Kd5aS/o1qlmTeP+xRpwbgX6sY1fdlH2PfBwbNX9vCEhSqfDLoAWGquyy+p6oGsu Wo+NyvVPrY/fxDorczyLCVE21/hspjr1HGla0YvmyKSMwfLrfOoqnazI0VzKGk0iVpXG 131f9ZTbvz1O77fu6id39JIVNoSVy8X9KmA4UJQSKKFz8mh377vH+SHli4XfTj9uNE4L hQ9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=DYA4/xfV6gdF5efekXUd3A2FwgLkRnn02fG7LKFB6rk=; b=mdKQ9CkZTKlf1TMCmt28Z4NZWluyqC5ZRrqV5sdcMDX+AjrIEUeZ7eD5HM0lwh1YuK P2NLGByQyS127FqwY/0ZPQeXW7KiQPhNbZvNoZg0eY+YxZgCoHjlO0PhPoPA51lN0xww o5gLQiLJVJNR/jnbOcOcnHEegMZdXSSf0ca22Q/TX+SgxtlXzer7sGyjxXT/TprMeXC4 nty7xPikRszdAjua1Ih0rsTowpN3sZqv+F4e9tpbGJk1oWPhU4F+jIIcau/sGrqwW1/3 cAbYiKlNqQ/m7R9rxSzi0RAwCtOvVAxv7M6nK/6hqB7gRq9LRGNUR1Qi3SUMwc/hEUZI 3avw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n14-20020a05640205ce00b0046805e6392csi8276334edx.474.2022.11.16.17.12.26; Wed, 16 Nov 2022 17:12:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234449AbiKQBLl (ORCPT + 99 others); Wed, 16 Nov 2022 20:11:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233955AbiKQBLg (ORCPT ); Wed, 16 Nov 2022 20:11:36 -0500 Received: from esa2.hc1455-7.c3s2.iphmx.com (esa2.hc1455-7.c3s2.iphmx.com [207.54.90.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 011DC1DF11; Wed, 16 Nov 2022 17:11:34 -0800 (PST) X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="96213598" X-IronPort-AV: E=Sophos;i="5.96,169,1665414000"; d="scan'208";a="96213598" Received: from unknown (HELO yto-r2.gw.nic.fujitsu.com) ([218.44.52.218]) by esa2.hc1455-7.c3s2.iphmx.com with ESMTP; 17 Nov 2022 10:11:34 +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 0309AC68E1; Thu, 17 Nov 2022 10:11:33 +0900 (JST) Received: from oym-om4.fujitsu.com (oym-om4.o.css.fujitsu.com [10.85.58.164]) by yto-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id 454E3D35DB; Thu, 17 Nov 2022 10:11:32 +0900 (JST) Received: from cn-r05-10.example.com (n3235113.np.ts.nmh.cs.fujitsu.co.jp [10.123.235.113]) by oym-om4.fujitsu.com (Postfix) with ESMTP id 2458440089710; Thu, 17 Nov 2022 10:11:32 +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 v4 1/5] selftests/resctrl: Fix set up schemata with 100% allocation on first run in MBM test Date: Thu, 17 Nov 2022 10:05:37 +0900 Message-Id: <20221117010541.1014481-2-tan.shaopeng@jp.fujitsu.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20221117010541.1014481-1-tan.shaopeng@jp.fujitsu.com> References: <20221117010541.1014481-1-tan.shaopeng@jp.fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749703794641502925?= X-GMAIL-MSGID: =?utf-8?q?1749703794641502925?= There is a comment "Set up shemata with 100% allocation on the first run" in function mbm_setup(), but there is an increment bug and the condition "num_of_runs == 0" will never be met and write_schemata() will never be called to set schemata to 100%. Even if write_schemata() is called in MBM test, since it is not supported for MBM test it does not set the schemata. This is currently fine because resctrl_val_parm->mum_resctrlfs is always 1 and umount/mount will be run in each test to set the schemata to 100%. To support the usage when MBM test does not unmount/remount resctrl filesystem before the test starts, fix to call write_schemata() and set schemata properly when the function is called for the first time. Also, remove static local variable 'num_of_runs' because this is not needed as there is resctrl_val_param->num_of_runs which should be used instead like in cat_setup(). Reviewed-by: Reinette Chatre Signed-off-by: Shaopeng Tan --- tools/testing/selftests/resctrl/mbm_test.c | 13 +++++++------ tools/testing/selftests/resctrl/resctrlfs.c | 4 +++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index 8392e5c55ed0..6d550f012829 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -89,23 +89,24 @@ 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 = 0; - /* Run NUM_OF_RUNS times */ - if (num_of_runs++ >= NUM_OF_RUNS) - return -1; - va_start(param, num); p = va_arg(param, struct resctrl_val_param *); va_end(param); + /* Run NUM_OF_RUNS times */ + if (p->num_of_runs >= NUM_OF_RUNS) + return -1; + /* Set up shemata with 100% allocation on the first run. */ - if (num_of_runs == 0) + if (p->num_of_runs == 0) ret = write_schemata(p->ctrlgrp, "100", p->cpu_no, p->resctrl_val); + p->num_of_runs++; + return ret; } diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index 6f543e470ad4..8546bc9f1786 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -498,6 +498,7 @@ int write_schemata(char *ctrlgrp, char *schemata, int cpu_no, char *resctrl_val) FILE *fp; if (strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR)) && + strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR)) && strncmp(resctrl_val, CAT_STR, sizeof(CAT_STR)) && strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) return -ENOENT; @@ -523,7 +524,8 @@ int write_schemata(char *ctrlgrp, char *schemata, int cpu_no, char *resctrl_val) if (!strncmp(resctrl_val, CAT_STR, sizeof(CAT_STR)) || !strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) sprintf(schema, "%s%d%c%s", "L3:", resource_id, '=', schemata); - if (!strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR))) + if (!strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR)) || + !strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR))) sprintf(schema, "%s%d%c%s", "MB:", resource_id, '=', schemata); fp = fopen(controlgroup, "w"); From patchwork Thu Nov 17 01:05:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaopeng Tan X-Patchwork-Id: 21363 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp152436wrr; Wed, 16 Nov 2022 17:13:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf75OhQ+f+TwIwKJXZGZoWLmPUWArrgimuCdJyio4rYqBlTDDnZH7/9LqRMFhOFj/sdlW5UZ X-Received: by 2002:aa7:d2c5:0:b0:459:1788:5e49 with SMTP id k5-20020aa7d2c5000000b0045917885e49mr225557edr.321.1668647622690; Wed, 16 Nov 2022 17:13:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668647622; cv=none; d=google.com; s=arc-20160816; b=wiCAfdQGgcdDz2vy39mVtsuOoiM8+DtUDMgHegRCCDAIYaJRuZAEi76UdWJgwkrJqC F2t8p5Fk1S+lMMiAc2xXOWkz57gQoMem4u9r0WAbqlBHLIOYWVmbr3n/ToOZqEdbbJ22 z2WtSASflF0pBRL2ozxp0QF1plR3F5HDhGArgMCkzRKKD41I5ZBzuoycTczlbL2vBtbD KvoX8oDtZUO0fK77Ny7Ix/c92HXwa+BLxh3zQU+2QIyibP1RuL9d3xWX3jzXbANkXFz6 V5Wt209ZBxPXHeR/bOx5uh1nnuyIf1AQ9K79Ah1LGVKH5mFkVTgEGdyxq4rqKHqps5rZ wn3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=8vB7wSoHkVQdDBEgWvv4iIcFC9Fe76TYmbSGIUh7/DA=; b=anLNJDeshqqBOgNvo2sj5bhN3jONiTU4PugFO2gmaJecRUIgbWNsekxDBI6ZAt/IAF fj4W9I+EIj4sdDY1Zb98LE0/GfL7AFi+TFJwRjM4dIy6lbxopaMWpPKuVyS5NQgQKdI+ +PMLXQVCxdWbjSkXSmkCRhHuxd1PSIq6dSv5Cnn9UbX3m4OL04kRMPmfOF9FD35E1k5B fXCKpqwViViaOx3rotccLdExjYm4SfXHGxpbYkhVeH6l+FqWBPQRliVU+axTt+cVNilK Tj6QCflvr4xplxpR1OX45qtSmqPp7RxNZ5oF3MdNmcETnXxxoJqVU7iUUfK0DdG7SkcM 3cJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qq16-20020a17090720d000b007721f88d3e0si12214125ejb.554.2022.11.16.17.13.19; Wed, 16 Nov 2022 17:13:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238754AbiKQBLs (ORCPT + 99 others); Wed, 16 Nov 2022 20:11:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234238AbiKQBLj (ORCPT ); Wed, 16 Nov 2022 20:11:39 -0500 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 0A65C2496B; Wed, 16 Nov 2022 17:11:37 -0800 (PST) X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="75100886" X-IronPort-AV: E=Sophos;i="5.96,169,1665414000"; d="scan'208";a="75100886" Received: from unknown (HELO yto-r4.gw.nic.fujitsu.com) ([218.44.52.220]) by esa7.hc1455-7.c3s2.iphmx.com with ESMTP; 17 Nov 2022 10:11:35 +0900 Received: from yto-m1.gw.nic.fujitsu.com (yto-nat-yto-m1.gw.nic.fujitsu.com [192.168.83.64]) by yto-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id BB290D3EA0; Thu, 17 Nov 2022 10:11:34 +0900 (JST) Received: from oym-om4.fujitsu.com (oym-om4.o.css.fujitsu.com [10.85.58.164]) by yto-m1.gw.nic.fujitsu.com (Postfix) with ESMTP id 1B6D2CFF8A; Thu, 17 Nov 2022 10:11:34 +0900 (JST) Received: from cn-r05-10.example.com (n3235113.np.ts.nmh.cs.fujitsu.co.jp [10.123.235.113]) by oym-om4.fujitsu.com (Postfix) with ESMTP id ED07840089710; Thu, 17 Nov 2022 10:11:33 +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, Shuah Khan Subject: [PATCH v4 2/5] selftests/resctrl: Return MBA check result and make it to output message Date: Thu, 17 Nov 2022 10:05:38 +0900 Message-Id: <20221117010541.1014481-3-tan.shaopeng@jp.fujitsu.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20221117010541.1014481-1-tan.shaopeng@jp.fujitsu.com> References: <20221117010541.1014481-1-tan.shaopeng@jp.fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749703850066993143?= X-GMAIL-MSGID: =?utf-8?q?1749703850066993143?= 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 false. Make output message to be "not ok" if MBA check result is failed. Reviewed-by: Shuah Khan Reviewed-by: Reinette Chatre Signed-off-by: Shaopeng Tan --- tools/testing/selftests/resctrl/mba_test.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c index 1a1bdb6180cf..e3a473976d74 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -51,10 +51,10 @@ static int mba_setup(int num, ...) return 0; } -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 = false; + bool ret = false; ksft_print_msg("Results are displayed in (MB)\n"); /* Memory bandwidth from 100% down to 10% */ @@ -90,13 +90,15 @@ static void show_mba_info(unsigned long *bw_imc, unsigned long *bw_resc) ksft_print_msg("avg_bw_imc: %lu\n", avg_bw_imc); ksft_print_msg("avg_bw_resc: %lu\n", avg_bw_resc); if (avg_diff_per > MAX_DIFF_PERCENT) - failed = true; + ret = true; } ksft_print_msg("%s Check schemata change using MBA\n", - failed ? "Fail:" : "Pass:"); - if (failed) + ret ? "Fail:" : "Pass:"); + if (ret) ksft_print_msg("At least one test failed\n"); + + return ret; } static int check_results(void) @@ -132,9 +134,7 @@ static int check_results(void) fclose(fp); - show_mba_info(bw_imc, bw_resc); - - return 0; + return show_mba_info(bw_imc, bw_resc); } void mba_test_cleanup(void) From patchwork Thu Nov 17 01:05:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaopeng Tan X-Patchwork-Id: 21362 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp152389wrr; Wed, 16 Nov 2022 17:13:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf7KOpS90lunSHie+sOz5Q3/iVnUo8tj0P2Jld9+zXoHYD0ei9VbBu+v9NvK/+B5YeRw88RM X-Received: by 2002:a17:906:84a:b0:7ae:1e53:3f97 with SMTP id f10-20020a170906084a00b007ae1e533f97mr347709ejd.169.1668647616425; Wed, 16 Nov 2022 17:13:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668647616; cv=none; d=google.com; s=arc-20160816; b=kVEWetcJXdvG2A/dXiWSBjKade7HPRASk3g1ciM6tfLU0nTp7im+blDjr3aE8lze7R Ir9aS3w/3A3I1KZrWLXY98Dmex7WKLIeguc4lliBva7MwM+zwNWaLY2wkDMe6gIWXtUK GaOEQkLtBKZRWYQLx5CcoQyQmB2W55nHqswMFrkaxZITd7j3KqqZstSF2DXrHj/PpclY sOmAzJdmCAxWLwBWs3ZKK5bUfDmpY0bMFmvR6nMuBqjADfa9l1fZH9De0QvMDXL/KW1S k1v3BF1u1GxqhYttPjUp7jV2sLtLobG3fKNPV0TbNbNUaxs1TdPuUgLn7IMyYj5+u60u 9veQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=RjAUSPDbrjqL+ZLCB8tfzB84CWFLe7V4Zlb51S559KY=; b=RdpQK9kkKzWy7Gf9dSfI088YBpG1BsbslT6SwBc88N+siOZdIpB8cjZmS7YMMUIzGR 6//C2V9u7Tsg21MUZPGb6yR1JCwYaC9cfJ43iui8LFwn5UOB+3I13f72nCX8Y0pMya8G B08UGnjtAhzMhaRrkgL2V+zHPjXfqDabwaq9VrYhly8LLC2GE/az1gIZJCFPvgxoaED4 wFO6LxdpBqPwMqg1CaF6ehvIQ32kh5P/n7/m5gkzEBG0KNquR+FxZCS+ZbbAi/CuSUMv RvskhlhR+aeFQR1Jw8Umuv2J9hrovFX/s0Wgi9DljKmm4fGpZUfZb0Org0cj6L6um0+t +UrQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ka24-20020a170907991800b007aea2b23ee3si12439379ejc.277.2022.11.16.17.13.11; Wed, 16 Nov 2022 17:13:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238829AbiKQBLw (ORCPT + 99 others); Wed, 16 Nov 2022 20:11:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234493AbiKQBLl (ORCPT ); Wed, 16 Nov 2022 20:11:41 -0500 Received: from esa12.hc1455-7.c3s2.iphmx.com (esa12.hc1455-7.c3s2.iphmx.com [139.138.37.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7EE91DF11; Wed, 16 Nov 2022 17:11:39 -0800 (PST) X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="75835688" X-IronPort-AV: E=Sophos;i="5.96,169,1665414000"; d="scan'208";a="75835688" Received: from unknown (HELO yto-r2.gw.nic.fujitsu.com) ([218.44.52.218]) by esa12.hc1455-7.c3s2.iphmx.com with ESMTP; 17 Nov 2022 10:11:36 +0900 Received: from yto-m3.gw.nic.fujitsu.com (yto-nat-yto-m3.gw.nic.fujitsu.com [192.168.83.66]) by yto-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id C8AE5C68E4; Thu, 17 Nov 2022 10:11:35 +0900 (JST) Received: from oym-om4.fujitsu.com (oym-om4.o.css.fujitsu.com [10.85.58.164]) by yto-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id 2D62CD9693; Thu, 17 Nov 2022 10:11:35 +0900 (JST) Received: from cn-r05-10.example.com (n3235113.np.ts.nmh.cs.fujitsu.co.jp [10.123.235.113]) by oym-om4.fujitsu.com (Postfix) with ESMTP id 0A7C540089710; Thu, 17 Nov 2022 10:11:35 +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, Shuah Khan Subject: [PATCH v4 3/5] selftests/resctrl: Flush stdout file buffer before executing fork() Date: Thu, 17 Nov 2022 10:05:39 +0900 Message-Id: <20221117010541.1014481-4-tan.shaopeng@jp.fujitsu.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20221117010541.1014481-1-tan.shaopeng@jp.fujitsu.com> References: <20221117010541.1014481-1-tan.shaopeng@jp.fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749703842876589390?= X-GMAIL-MSGID: =?utf-8?q?1749703842876589390?= 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(). Reviewed-by: Shuah Khan Reviewed-by: Reinette Chatre Signed-off-by: Shaopeng Tan --- 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/selftests/resctrl/cat_test.c index 1c5e90c63254..6a8306b0a109 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_type) return errno; } + fflush(stdout); bm_pid = fork(); /* 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_val_param *param) * Fork to start benchmark, save child's pid so that it can be killed * when needed */ + fflush(stdout); bm_pid = fork(); if (bm_pid == -1) { perror("# Unable to fork"); diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index 8546bc9f1786..d95688298469 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -678,6 +678,7 @@ int filter_dmesg(void) perror("pipe"); return ret; } + fflush(stdout); pid = fork(); if (pid == 0) { close(pipefds[0]); From patchwork Thu Nov 17 01:05:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaopeng Tan X-Patchwork-Id: 21364 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp152608wrr; Wed, 16 Nov 2022 17:14:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf5fTaWHZUj88EPdtdPR/4/hQvwMSZWzcH1kM1PhuYzNl89Nix+7NQtFn33aFP0htPnydqU3 X-Received: by 2002:a05:6402:356:b0:461:9e1f:222b with SMTP id r22-20020a056402035600b004619e1f222bmr224465edw.312.1668647647945; Wed, 16 Nov 2022 17:14:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668647647; cv=none; d=google.com; s=arc-20160816; b=ptnZVm623aSyCOviJAPREyEZNPHNcul8dPQB2wjRhD5vZlcqb0zQ1+1T/665SfZd5z FJSdZ7pzm5ocMn0+wYGPX1yXYyqEgey/qsizlUJZ/dogrwgGW7WMHDeXuC4eVc5hy7R6 EtBQyDjKbEUgDMwrjHm2DZifPY2oudUiAIycaB6SnS73UrUqLHeQ4Ly0GAfVstKSdHYM 7TowXTT+whxTTInX6PhUirOt7IbL1D138n63vao1gACaNO1tZbV0nzp9noip0GkwgTTC A0OGTFM4Etsw9DmMd/assjwaexKwwwvmci3oqxipUmr6cH0CWcZszJrq77wr6L2+xWUg LwUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/TbJVFvQ+xv+xnC0vH6c1wb6JNKBFY4aB/biyviI8/8=; b=O37njrLe1c7k/BZ+1Mf/YOF5NO577faI/TwzSZajMtIn529KtABDekuxq2h8/jlZM8 9PSwgES9SsEguZy5IsFJvQ5zpnkDx9gBiZKC+Tc57lhXKl9LBOWQVY8ZOpQlnlCHRYHZ wgdq4x0Iu6H/tWQ8SFN25uS+ycS4zL7BFOKThgT78lzXl+S6vuEZ9DsoOFRhl4doURza yrciRcFQ58dm5D8oonIf29WCseyh7NBkfi6ZMi0KOaV0HmF4zbSHn/smZOzsH3YKJqFH peXUECIUeAW+pL3eHpqIQmMvX3GU960JS7t/cG5wWiAasyobaTNPGUrbhWoAoDaFm0z+ HaTg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c10-20020a0564021f8a00b004585e0f44fesi13627304edc.60.2022.11.16.17.13.44; Wed, 16 Nov 2022 17:14:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238867AbiKQBLz (ORCPT + 99 others); Wed, 16 Nov 2022 20:11:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234174AbiKQBLm (ORCPT ); Wed, 16 Nov 2022 20:11:42 -0500 Received: from esa3.hc1455-7.c3s2.iphmx.com (esa3.hc1455-7.c3s2.iphmx.com [207.54.90.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BC3E3C6CF; Wed, 16 Nov 2022 17:11:40 -0800 (PST) X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="96352867" X-IronPort-AV: E=Sophos;i="5.96,169,1665414000"; d="scan'208";a="96352867" Received: from unknown (HELO oym-r2.gw.nic.fujitsu.com) ([210.162.30.90]) by esa3.hc1455-7.c3s2.iphmx.com with ESMTP; 17 Nov 2022 10:11:39 +0900 Received: from oym-m2.gw.nic.fujitsu.com (oym-nat-oym-m2.gw.nic.fujitsu.com [192.168.87.59]) by oym-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id 62C0DD4C26; Thu, 17 Nov 2022 10:11:37 +0900 (JST) Received: from oym-om4.fujitsu.com (oym-om4.o.css.fujitsu.com [10.85.58.164]) by oym-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id A2E99BD696; Thu, 17 Nov 2022 10:11:36 +0900 (JST) Received: from cn-r05-10.example.com (n3235113.np.ts.nmh.cs.fujitsu.co.jp [10.123.235.113]) by oym-om4.fujitsu.com (Postfix) with ESMTP id 8D53A40089714; Thu, 17 Nov 2022 10:11:36 +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, Shuah Khan Subject: [PATCH v4 4/5] selftests/resctrl: Cleanup properly when an error occurs in CAT test Date: Thu, 17 Nov 2022 10:05:40 +0900 Message-Id: <20221117010541.1014481-5-tan.shaopeng@jp.fujitsu.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20221117010541.1014481-1-tan.shaopeng@jp.fujitsu.com> References: <20221117010541.1014481-1-tan.shaopeng@jp.fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749703875890614771?= X-GMAIL-MSGID: =?utf-8?q?1749703875890614771?= After creating a child process with fork() in CAT test, if there is an error occurs or such as a SIGINT signal is received, the parent process will be terminated immediately, but the child process will not be killed and also umount_resctrlfs() will not be called. Add a signal handler like other tests to kill child process, umount resctrlfs, cleanup result files, etc. if an error occurs in parent process. To use ctrlc_handler() of other tests to kill child process(bm_pid), using global bm_pid instead of local bm_pid. Wait for child process to be killed if an error occurs in child process. Reviewed-by: Shuah Khan Signed-off-by: Shaopeng Tan --- tools/testing/selftests/resctrl/cat_test.c | 30 ++++++++++++++-------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index 6a8306b0a109..1f8f5cf94e95 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -100,10 +100,10 @@ void cat_test_cleanup(void) int cat_perf_miss_val(int cpu_no, int n, char *cache_type) { + struct sigaction sigact; unsigned long l_mask, l_mask_1; int ret, pipefd[2], sibling_cpu_no; char pipe_message; - pid_t bm_pid; cache_size = 0; @@ -181,17 +181,25 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) strcpy(param.filename, RESULT_FILE_NAME1); param.num_of_runs = 0; param.cpu_no = sibling_cpu_no; + } else { + /* + * Register CTRL-C handler for parent, as it has to kill + * child process before exiting + */ + sigact.sa_sigaction = ctrlc_handler; + sigemptyset(&sigact.sa_mask); + sigact.sa_flags = SA_SIGINFO; + if (sigaction(SIGINT, &sigact, NULL) || + sigaction(SIGTERM, &sigact, NULL) || + sigaction(SIGHUP, &sigact, NULL)) + perror("# sigaction"); } remove(param.filename); ret = cat_val(¶m); - if (ret) - return ret; - - ret = check_results(¶m); - if (ret) - return ret; + if (ret == 0) + ret = check_results(¶m); if (bm_pid == 0) { /* Tell parent that child is ready */ @@ -199,9 +207,11 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) pipe_message = 1; if (write(pipefd[1], &pipe_message, sizeof(pipe_message)) < sizeof(pipe_message)) { - close(pipefd[1]); + /* + * Just print the error message. + * Let while(1) run and wait for itself to be killed. + */ perror("# failed signaling parent process"); - return errno; } close(pipefd[1]); @@ -226,5 +236,5 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) if (bm_pid) umount_resctrlfs(); - return 0; + return ret; } From patchwork Thu Nov 17 01:05:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaopeng Tan X-Patchwork-Id: 21365 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp152901wrr; Wed, 16 Nov 2022 17:14:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf4+0OVLCZN7W5LRzgKnZYLE+MYaR1bPRZu7cN2wKEWgkD9yPF3f0CRAkBZc/5DwyHsgGZAm X-Received: by 2002:a17:906:1ed3:b0:7b2:7aef:59ff with SMTP id m19-20020a1709061ed300b007b27aef59ffmr280834ejj.573.1668647682346; Wed, 16 Nov 2022 17:14:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668647682; cv=none; d=google.com; s=arc-20160816; b=hnqiwGt4X4Qc4vqXkuR60of0zscj9jMz4jWDLPrKGqqkp/jtNQ0D/C2ZT+3Iw2FgGo mmZhjPz8VSCoTpadGx+hql3qI1i0FnRUCo3k7R0Ng3UJnoX6u5ZpWJh5pJ4hXSAqQqS7 cDJmwC+0Y+WGntDfNWV3238QmylcgTZMNJ9igpuPR5j41RrMCWR5CUJgOUYHuXfWejjh +6o8PhgG7tQUcUT/nqEI3nNTkIekttQEnNwMu1WVF4WAKFIE1dtLPzcQ06irYQLTdztA UHIQo5yQC4NhqPk1o24MDiMGeUzQ7aLf7lr4nwutghA5HiGWgAIZ8cKCjeTIWX8B2fKq 6/vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=CLfyTHEYjjj8Q1pGPthuKa/u8n0LBFJFpBdkLiDN76Q=; b=aF0r7F8UhCPc025AdHazHINL17uZi8tfC5jCvl5Tyay8Uv17hkTei05PmQwwF70zB8 b3Rg8TBbb8C4MZ6ppK6qQAIyBx9Q7tPSGdVHoTHgCNSyyvR1VEMYeWaCU3NWss/gkRmY I5hYMxWoUE1rdCiXy2oso/MYi04vL44zfzq06qP9cgTQe7wnK9yPga4EZ1mmk5W0+azA JjBtNh406+Mn2qgLgbppAutk2GU+jFjk8EGEx9/pZ0laMKMG+n36mqRhkzpyNL7UdUMo 51lCyBoTATtPkzZOZxsJpEXNh4OkeGUcdSVsNe26FDLbMofNuHmWwuWGRejz7PcTGZqt f6iw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qk10-20020a1709077f8a00b007ac2daa0b49si15941214ejc.367.2022.11.16.17.14.19; Wed, 16 Nov 2022 17:14:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239085AbiKQBL7 (ORCPT + 99 others); Wed, 16 Nov 2022 20:11:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238577AbiKQBLq (ORCPT ); Wed, 16 Nov 2022 20:11:46 -0500 Received: from esa6.hc1455-7.c3s2.iphmx.com (esa6.hc1455-7.c3s2.iphmx.com [68.232.139.139]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49C0769DF3; Wed, 16 Nov 2022 17:11:43 -0800 (PST) X-IronPort-AV: E=McAfee;i="6500,9779,10533"; a="97042898" X-IronPort-AV: E=Sophos;i="5.96,169,1665414000"; d="scan'208";a="97042898" Received: from unknown (HELO yto-r1.gw.nic.fujitsu.com) ([218.44.52.217]) by esa6.hc1455-7.c3s2.iphmx.com with ESMTP; 17 Nov 2022 10:11:40 +0900 Received: from yto-m4.gw.nic.fujitsu.com (yto-nat-yto-m4.gw.nic.fujitsu.com [192.168.83.67]) by yto-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id A29F7D66A9; Thu, 17 Nov 2022 10:11:38 +0900 (JST) Received: from oym-om4.fujitsu.com (oym-om4.o.css.fujitsu.com [10.85.58.164]) by yto-m4.gw.nic.fujitsu.com (Postfix) with ESMTP id E096C14209; Thu, 17 Nov 2022 10:11:37 +0900 (JST) Received: from cn-r05-10.example.com (n3235113.np.ts.nmh.cs.fujitsu.co.jp [10.123.235.113]) by oym-om4.fujitsu.com (Postfix) with ESMTP id BEA7740089714; Thu, 17 Nov 2022 10:11:37 +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 v4 5/5] selftests/resctrl: Remove duplicate codes that clear each test result file Date: Thu, 17 Nov 2022 10:05:41 +0900 Message-Id: <20221117010541.1014481-6-tan.shaopeng@jp.fujitsu.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20221117010541.1014481-1-tan.shaopeng@jp.fujitsu.com> References: <20221117010541.1014481-1-tan.shaopeng@jp.fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749703912277616888?= X-GMAIL-MSGID: =?utf-8?q?1749703912277616888?= Before exiting each test function(run_cmt/cat/mbm/mba_test()), test results("ok","not ok") are printed by ksft_test_result() and then temporary result files are cleaned by function cmt/cat/mbm/mba_test_cleanup(). However, before running ksft_test_result(), 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, while ensuring cleanup properly even when errors occur in each test. Signed-off-by: Shaopeng Tan Reviewed-by: Reinette Chatre --- tools/testing/selftests/resctrl/cmt_test.c | 7 +++---- tools/testing/selftests/resctrl/mba_test.c | 7 +++---- tools/testing/selftests/resctrl/mbm_test.c | 7 +++---- tools/testing/selftests/resctrl/resctrl_tests.c | 4 ---- 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index 8968e36db99d..617ee95d272d 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -133,13 +133,12 @@ int cmt_resctrl_val(int cpu_no, int n, char **benchmark_cmd) ret = resctrl_val(benchmark_cmd, ¶m); if (ret) - return ret; + goto out; ret = check_results(¶m, n); - if (ret) - return ret; +out: cmt_test_cleanup(); - return 0; + return ret; } diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c index e3a473976d74..b948938a3b4d 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -160,13 +160,12 @@ int mba_schemata_change(int cpu_no, char *bw_report, char **benchmark_cmd) ret = resctrl_val(benchmark_cmd, ¶m); if (ret) - return ret; + goto out; ret = check_results(); - if (ret) - return ret; +out: mba_test_cleanup(); - return 0; + return ret; } diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index 6d550f012829..040ca1f9c173 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -134,13 +134,12 @@ int mbm_bw_change(int span, int cpu_no, char *bw_report, char **benchmark_cmd) ret = resctrl_val(benchmark_cmd, ¶m); if (ret) - return ret; + goto out; ret = check_results(span); - if (ret) - return ret; +out: mbm_test_cleanup(); - return 0; + return ret; } diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index df0d8d8526fc..8732cf736528 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -88,7 +88,6 @@ static void run_mbm_test(bool has_ben, char **benchmark_cmd, int span, ksft_test_result(!res, "MBM: bw change\n"); if ((get_vendor() == ARCH_INTEL) && res) ksft_print_msg("Intel MBM may be inaccurate when Sub-NUMA Clustering is enabled. Check BIOS configuration.\n"); - mbm_test_cleanup(); } static void run_mba_test(bool has_ben, char **benchmark_cmd, int span, @@ -107,7 +106,6 @@ static void run_mba_test(bool has_ben, char **benchmark_cmd, int span, sprintf(benchmark_cmd[1], "%d", span); res = mba_schemata_change(cpu_no, bw_report, benchmark_cmd); ksft_test_result(!res, "MBA: schemata change\n"); - mba_test_cleanup(); } static void run_cmt_test(bool has_ben, char **benchmark_cmd, int cpu_no) @@ -126,7 +124,6 @@ static void run_cmt_test(bool has_ben, char **benchmark_cmd, int cpu_no) ksft_test_result(!res, "CMT: test\n"); if ((get_vendor() == ARCH_INTEL) && res) ksft_print_msg("Intel CMT may be inaccurate when Sub-NUMA Clustering is enabled. Check BIOS configuration.\n"); - cmt_test_cleanup(); } static void run_cat_test(int cpu_no, int no_of_bits) @@ -142,7 +139,6 @@ static void run_cat_test(int cpu_no, int no_of_bits) res = cat_perf_miss_val(cpu_no, no_of_bits, "L3"); ksft_test_result(!res, "CAT: test\n"); - cat_test_cleanup(); } int main(int argc, char **argv)