From patchwork Wed Feb 8 09:30:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 54308 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3355724wrn; Wed, 8 Feb 2023 01:33:16 -0800 (PST) X-Google-Smtp-Source: AK7set+xmxV+qDftWjgBN/sOJiZnjtfnF3guX9vJmqJVALVVqa6Le+bYLXsJFRF1wJT2Lpyz+I6+ X-Received: by 2002:a17:90b:4a0d:b0:230:c723:f37d with SMTP id kk13-20020a17090b4a0d00b00230c723f37dmr7828146pjb.40.1675848796014; Wed, 08 Feb 2023 01:33:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675848796; cv=none; d=google.com; s=arc-20160816; b=JQ7i8KUxQ6ErgkxNBpuk/YkJcCWoLTYl25x/bCux89j1hLF3DDLiBks/Cqsx9WUlR+ WDrXQY0tna5OtICeI9uoFJJRtE/cLUuQkaO55MWvTFvCPILBe7PxUjlIS6D9nP8ybm5l 8a3a6zNU80rsudW35tb7QbZ5ALsFSz4rAZafmKj3OSStEQKMzaxCL89GWBBW9tQRsEq9 ozeY0pq+18j8Y69crvZh1JEHMVGoEIuMASRL1n43CjwTNKWvhGu0KXvNFFoi9mICUCxo WejiN6f1mV34DgiMk3SCxenSnQ6eHAUjHUYe+5uwZ+mpOzgkhLC7h9T/sQRf2w5oqD2S UFKw== 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 :dkim-signature; bh=Xa3TXuN8tr5PiZ9Qve/BF6IoWGdWzSHONEqG2K1qAtQ=; b=CKRIgiBISZnKUayqWIGSOVPq2XZRM8/RuoTPpud/r4CjLQ0Rapw/gttzkfKUg9AoUr Dek+/M5iCzdu46lCXQWtUlBBcKdhNKCtkluOprJBlCdc/JUT0VZ3rkUmNd3g4IaOboGq O5asFhbHUFuxypXQa28rk4EuRKa9lC0/k29f1XjvuMO+aF/OwYOaUKLt30JgJ/N7vu+Q hqyKqHqcaR9p3LQs4pgRUkS1PxyIW2+nAlTOmGyvIFkm8vW6izBkoX85+HgbTx7CTYST 3NAamXstmPMIpEq0iABYV7o8fM2f+im4v9fc8OYKPuvSe8ottb9zgR3zV5lQtwLJnXJS AA3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KCx3UlJ4; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x91-20020a17090a6c6400b00229d64c32dfsi1660970pjj.15.2023.02.08.01.33.03; Wed, 08 Feb 2023 01:33:15 -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; dkim=pass header.i=@intel.com header.s=Intel header.b=KCx3UlJ4; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229745AbjBHJbn (ORCPT + 99 others); Wed, 8 Feb 2023 04:31:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230073AbjBHJbP (ORCPT ); Wed, 8 Feb 2023 04:31:15 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD7A63B3CF; Wed, 8 Feb 2023 01:30:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675848634; x=1707384634; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=q1oBWKuYYomRqNoQkEbpKAD3e1aQEGBUh4JgrqrFNLo=; b=KCx3UlJ45MkfqbEisr/BYe02wtyF9HQ7dZ1uMOvQ2wqALLsagaSRvNYy +UfPh3mxv3Af3SQYHKj+XYlkN8KtdRMN2cDrjJsk+qr28dB99rVV3fQKD eXAXJE8MfQmnW5gS6H5R16kMCAv2Pwu85XvX3hLTUNL3h/8rWCy8urVNx TEt20ZsF++bFzfUUPmiv/SAz9bBzCvgv2TROiB4XHqoI9snl658hMle6k xKmRs2VMfdy6Y2dqolYm2sQREX1vW+18OXZJqIKb0D83HX1gJDh9XoTgr Z0+Z2d86OGokbcmIfLPYJu1uRvTl7AXqonyUnKXpDcnBJHmDQupIv0qhs Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10614"; a="415974516" X-IronPort-AV: E=Sophos;i="5.97,280,1669104000"; d="scan'208";a="415974516" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2023 01:30:34 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10614"; a="697613892" X-IronPort-AV: E=Sophos;i="5.97,280,1669104000"; d="scan'208";a="697613892" Received: from jstelter-mobl.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.38.39]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2023 01:30:31 -0800 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH 2/4] selftests/resctrl: Move ->setup() call outside of test specific branches Date: Wed, 8 Feb 2023 11:30:14 +0200 Message-Id: <20230208093016.20670-3-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230208093016.20670-1-ilpo.jarvinen@linux.intel.com> References: <20230208093016.20670-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE 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?1757254826956758173?= X-GMAIL-MSGID: =?utf-8?q?1757254826956758173?= resctrl_val() function is called only by mbm, mba, and cmt tests which means the else branch is never used and can be removed. Presently, both of the the test branches call param->setup(). Thus, the call can be placed outside of the test specific branches reducing code duplication. Co-developed-by: Fenghua Yu Signed-off-by: Fenghua Yu Signed-off-by: Ilpo Järvinen --- tools/testing/selftests/resctrl/resctrl_val.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index b32b96356ec7..787546a52849 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -734,29 +734,22 @@ int resctrl_val(char **benchmark_cmd, struct resctrl_val_param *param) /* Test runs until the callback setup() tells the test to stop. */ while (1) { + ret = param->setup(1, param); + if (ret) { + ret = 0; + break; + } + if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR)) || !strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR))) { - ret = param->setup(1, param); - if (ret) { - ret = 0; - break; - } - ret = measure_vals(param, &bw_resc_start); if (ret) break; } else if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) { - ret = param->setup(1, param); - if (ret) { - ret = 0; - break; - } sleep(1); ret = measure_cache_vals(param, bm_pid); if (ret) break; - } else { - break; } }