Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp2058747rwi; Tue, 1 Nov 2022 03:23:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5SInapOxkcR/eF1RFEJtPvvK2CwcSt2CwlJWeNLNjKYDzZK30N4Q3JhsewSNqpE8Ba8wpB X-Received: by 2002:a17:90b:1c8e:b0:205:783b:fe32 with SMTP id oo14-20020a17090b1c8e00b00205783bfe32mr37233022pjb.39.1667298229577; Tue, 01 Nov 2022 03:23:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667298229; cv=none; d=google.com; s=arc-20160816; b=nE+5Br2T0EywfZw8+XQ6CAwZo6OACF5dqxxlgAewdVSxcs2N4WU/Ti1RIvUJ3xZ7og eB+vec9r0VBdB6666D4dPGIp5/gANsE87hHINvszHqaW+6bED23ZUANQlFah8hrsImg/ S+0lOVDi5U2Hk7JTaTp5f9GF1VnOz7rJv35+E3QcAPQo+JGDGIIplk0xO2mQTyDWoY90 UGKdFTTeOaHWpWQ4dnk9ZevyAHkCoepFprpJitd9fgcP2lJENEhoLxqdydySiV+4Fm4b u1jBXc0HrTxjU6P3ojZ79r6wet3jooY3YvLow8TXMqUBqtaY5S3iSF48z+0BNaInzaQt W/8Q== 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=XR0la8Maw0mpuL+rwmSxqIZtl2xv4GJkKNyP6gp2N8g=; b=zr4AafJZ8ofAKeSJbPB+Cf1zERxsTlVC8QjQnYC2CZVYUjzuHjrAVwqRNhwDZbLXkG TdsQ+SEz6Ra/B9g55zD4yKiCXKcjY9amXAwm8WK5PmclTB4+I2apdm8XG/lWqcrqsxDS JT+TMN2t2q+LkpmWbYTWmh7zwKfvf1HFgz01DqyMZ6bXY6u+f490URlZC0v+OxoTOZhp 2BXwbX++RO4CqoA1DGI0sE1WkfdAoWCgvvwfswgDgtKrLubPknE0DS5C0o/2Q0VA54lK Rd+Vi5SR1m1S8nRczjn3nR/p3ZvsfoonyYWu569RzzxmaLh35+KZ5jiwAlut62eLhJmF v4Hw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l10-20020a17090a49ca00b001fd9be4fb6csi10606082pjm.39.2022.11.01.03.23.36; Tue, 01 Nov 2022 03:23:49 -0700 (PDT) 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 S230387AbiKAJsv (ORCPT + 97 others); Tue, 1 Nov 2022 05:48:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229907AbiKAJss (ORCPT ); Tue, 1 Nov 2022 05:48:48 -0400 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 91E6011A39; Tue, 1 Nov 2022 02:48:47 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="73993957" X-IronPort-AV: E=Sophos;i="5.95,230,1661785200"; d="scan'208";a="73993957" Received: from unknown (HELO yto-r4.gw.nic.fujitsu.com) ([218.44.52.220]) by esa12.hc1455-7.c3s2.iphmx.com with ESMTP; 01 Nov 2022 18:48:45 +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 339AFD4F62; Tue, 1 Nov 2022 18:48:45 +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 75482E679E; Tue, 1 Nov 2022 18:48:44 +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 4D00040164011; Tue, 1 Nov 2022 18:48:44 +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 v3 1/5] selftests/resctrl: Fix set up schemata with 100% allocation on first run in MBM test Date: Tue, 1 Nov 2022 18:43:37 +0900 Message-Id: <20221101094341.3383073-2-tan.shaopeng@jp.fujitsu.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20221101094341.3383073-1-tan.shaopeng@jp.fujitsu.com> References: <20221101094341.3383073-1-tan.shaopeng@jp.fujitsu.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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(). 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"); -- 2.27.0