From patchwork Wed Feb 15 13:05:58 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: 57529 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp179882wrn; Wed, 15 Feb 2023 05:08:23 -0800 (PST) X-Google-Smtp-Source: AK7set/7eqM8PKLT1GxnrrSb/3XIY1psUz+BuOs//eFfZO2gF/c2J3fT3yp6eLx8Xle0TgNCqp+z X-Received: by 2002:a17:90b:1bcf:b0:233:f09c:82c9 with SMTP id oa15-20020a17090b1bcf00b00233f09c82c9mr2868222pjb.20.1676466502827; Wed, 15 Feb 2023 05:08:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676466502; cv=none; d=google.com; s=arc-20160816; b=macI9WFLDuyhENcjz7PRnkm1PS3B7KnzivObY/KFk08eLtN2lXv7hh0uu8rFvQfK8W AA0G21a7ObzAO8mbs+hyPgFle3cfOLSZ2ZQhP1UjjkB/+9oXZs0T75es1Hs2a3YxGkj1 i1Aw2E2QX9qX3jC4XVTh71hPeERPe8lCjZOY3PFvWcpQUT4M8tuYoLij6nJExO611aoq vMUwuod4WY4ZuM7lDl1Q7orl5/g+PtAUq7oICGV7Fl5vs8lFz7RmUPTjTJoE/GMI6IYa sV77Ov8Pa7ijR/WMaSNc+144ydc76BSRWAx2hr7Sc5BCUuqm/8XufGrBjAfbIiNA+wFq TM8Q== 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=iKDNovyzYNoYZPtyRDZOtCOZFK8zFKNumUZD2PHNeuw=; b=PThiF7P8UdPbYCSBNZlaIlumOfwdXVUsI0pKVOmLPESAxIGdjxhtraBPbbIYl7R2bh /hPN7QD6GzJ4Yk8KDmXz7fnvKtezZ/dNC252QoYf7ey4iQMgX9cOMovLbdUHEnsstV/G 09quNYPitpc5m9mYgtEJUgz4EwuIsK9xs8Z3kzZroRPyBkWPmPCVr53ffG8HeDYbD8w5 Gcd6PnVtCv68DwUfY0FbWc0o7r8lT0AbHbduq1uHtEIHMvImrZ/Uoi5Agz3wPe137n1a 6CrBxhxlth9D1uBQxj5qQDLeZI3HlOKgdkfUQ+zCyd4xDR22IcqedIeQJNwvlfoTs934 u4RA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FJYLqX7L; 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 a6-20020a17090abe0600b00233ea41cd31si1899900pjs.74.2023.02.15.05.08.10; Wed, 15 Feb 2023 05:08:22 -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=FJYLqX7L; 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 S234068AbjBONGa (ORCPT + 99 others); Wed, 15 Feb 2023 08:06:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234037AbjBONG1 (ORCPT ); Wed, 15 Feb 2023 08:06:27 -0500 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6AD538B4D; Wed, 15 Feb 2023 05:06:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676466386; x=1708002386; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Qn//9IBm5Kac9zEBQzEQS4jENOC77V8ts13HcmG10h0=; b=FJYLqX7L1ASRhBvDcgzvrIHms/65ar9D4R5WvRizu2+wAhNTR8Sv1f3V 5mgYHb+4X+3koKI3cib9DKmTZpqKRqjrU3Z64SmXdgF4QTbrpUcqfsre9 Lk0pjQf20NWHRqFMMmJVD7iCy8UrGHqiK/VEAKnFEx2keN/ofuKG/KGdz 51yM1QCSS1tBvONq+dTlh7Lyr+2V2scI31KSnZs2cGm3PlGFE9Llmr7++ wWCiA/Z0KvKfnAAfIE3FlBb8riEUR1iqk0P/HhsOE/DHXc20VAGTQJVcI PJTEepshmIxKmfnQbzI9bw3Ws941KMPAnVVY0xd90Q8G+1opGT29YF/5j A==; X-IronPort-AV: E=McAfee;i="6500,9779,10621"; a="319456252" X-IronPort-AV: E=Sophos;i="5.97,299,1669104000"; d="scan'208";a="319456252" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Feb 2023 05:06:26 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10621"; a="812436033" X-IronPort-AV: E=Sophos;i="5.97,299,1669104000"; d="scan'208";a="812436033" Received: from hshannan-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.49.120]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Feb 2023 05:06:24 -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 v2 2/9] selftests/resctrl: Move ->setup() call outside of test specific branches Date: Wed, 15 Feb 2023 15:05:58 +0200 Message-Id: <20230215130605.31583-3-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230215130605.31583-1-ilpo.jarvinen@linux.intel.com> References: <20230215130605.31583-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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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?1757902539791546181?= X-GMAIL-MSGID: =?utf-8?q?1757902539791546181?= resctrl_val() function is called only by MBM, MBA, and CMT tests which means the else branch is never used. Both test branches call param->setup(). Remove the unused else branch and place the ->setup() call 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 Reviewed-by: Reinette Chatre --- 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; } }