From patchwork Thu Jul 13 13:19:30 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: 119891 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1822716vqm; Thu, 13 Jul 2023 06:24:55 -0700 (PDT) X-Google-Smtp-Source: APBJJlFAjvL8uCQuq7B67vCq9zY1Gb/1zGoI3SvYQby3A5eCVbHEi/6vDXvRXHptPlsByA/Ujz3/ X-Received: by 2002:a05:6402:541:b0:516:81d3:2627 with SMTP id i1-20020a056402054100b0051681d32627mr2189525edx.0.1689254695278; Thu, 13 Jul 2023 06:24:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689254695; cv=none; d=google.com; s=arc-20160816; b=YjBq6PtL2NNRcuj5ittkgfXy3f4ictfbtjRQQdTEqb3qwGjDc5EbKJHd/mPD0jVBer h6MfArwAAUXDKXAIIrejXqkprqWrQKOKCnv9LymRfgAV349agvcw5/GYFpuvGKz0DVzJ 52UfStOjr91Gsg4DXU7V59diwTyrCyGGRCMGRFXJH96DALeeRf8FeGRXjtXabxk9gEX/ bc1OgSVSyOPmmhYoT2F92xi7cn1lmQNi/7UwfWl04FvAGiuvY29mJncGDvgS57tvMnis ELeErzt2ArGkF9YM2GSpFpwcw7t7LN4bj7mtvDrBFUFZo2vprKc4GuaMB0MgVHFb8HSw Kbiw== 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=kuva4r8Gv98cUco/tH7/JGjCJYVXFJD6cCkoPnJN2yQ=; fh=yQZVCT9uasVczKlazciVDh1mdZVasudsfBJLxIYHjUw=; b=terUKby6SKQ3vq1BE0wy8TuPqxrdEf2h4bvm26N42kkv64ADmd6m7GtZdD0ga8t19X PriKB6SwUI9jAyTFOgdSxkQl3R/uvoBbMsLJTUG9SybHNwg1shAEVsnxRujG7SbFLVcE MY7Bh1DE5tl/atTMVGWO5R6r9P3j0KM9sHIKqMyt4CUKjDhqpOoSKHrb5psgaFAU3tGX wM5uc0xV/jhCZnPwLi9JIHY5Dn6Lsz4Cu74zli6fHCRqeNfNEL1e7WZYl7HaF4Cq0gh6 amHFn92rMhSdXFIRrWChO69ZtuN4VjzqqtY+HF+q2v8uklGGF553ZlHUfRY5viy6eM/i 4G0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RjQx52d8; 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 n21-20020aa7c455000000b0051e186a6faesi6872214edr.194.2023.07.13.06.24.31; Thu, 13 Jul 2023 06:24:55 -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; dkim=pass header.i=@intel.com header.s=Intel header.b=RjQx52d8; 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 S234495AbjGMNXh (ORCPT + 99 others); Thu, 13 Jul 2023 09:23:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235175AbjGMNWk (ORCPT ); Thu, 13 Jul 2023 09:22:40 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5159135B3; Thu, 13 Jul 2023 06:21:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689254495; x=1720790495; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WIWnJB3NculwQZQw1FR80Zi4TS+CrST66ZBC+3Ji4ag=; b=RjQx52d8MBtNjwsm2rVPb1ZzLvuPXKh5sU5MYo6Joa/IMN9T5fySe+vS cxeB3KNHRy/FQaF7Oah2CZCoIhhaTGCZgeJ8pGlmS/CDKmn211Ys7j0aZ F+5usqwe5fGitR4BNfGdMKg3W++9Kc3BPUxG7irHqTstQ04SLSdPS4uRh B+c7YJ0xs3zovwVO6PVDWc0aFdQEiVRgaFJLvWKLaILFtF1OM1CRJMLCL Vlehfgp7QU50Guk1rtzrcI6SyydZxIH2qXdm2rcjy3Y0hE8PSN5fnpR51 ytS5neMIlLj7hx5Sju2iRYRlLfkRMFf3LvBtHIiwblYSI9wr/amlieY5N A==; X-IronPort-AV: E=McAfee;i="6600,9927,10770"; a="345497087" X-IronPort-AV: E=Sophos;i="6.01,202,1684825200"; d="scan'208";a="345497087" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2023 06:21:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10770"; a="968616051" X-IronPort-AV: E=Sophos;i="6.01,202,1684825200"; d="scan'208";a="968616051" Received: from ijarvine-mobl2.ger.corp.intel.com ([10.251.222.39]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2023 06:21:12 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: linux-kselftest@vger.kernel.org, Reinette Chatre , Shuah Khan , Shaopeng Tan , Fenghua Yu , linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v4 17/19] selftests/resctrl: Move CAT/CMT test global vars to function they are used in Date: Thu, 13 Jul 2023 16:19:30 +0300 Message-Id: <20230713131932.133258-18-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230713131932.133258-1-ilpo.jarvinen@linux.intel.com> References: <20230713131932.133258-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,T_SCC_BODY_TEXT_LINE 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: INBOX X-GMAIL-THRID: 1771311931315651175 X-GMAIL-MSGID: 1771311931315651175 CAT and CMT tests have count_of_bits, long_mask, cbm_mask, and cache_size global variables that can be moved into the sole using function. Make the global variables local variables of the relevant function to scope them better. While at it, move cache_size initialization into the declaration line. Signed-off-by: Ilpo Järvinen Reviewed-by: Reinette Chatre --- tools/testing/selftests/resctrl/cat_test.c | 11 ++++------- tools/testing/selftests/resctrl/cmt_test.c | 11 ++++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index 42e35269d8b6..ed6c8e64ad11 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -17,11 +17,6 @@ #define MAX_DIFF_PERCENT 4 #define MAX_DIFF 1000000 -static int count_of_bits; -static char cbm_mask[256]; -static unsigned long long_mask; -static unsigned long cache_size; - /* * Change schemata. Write schemata to specified * con_mon grp, mon_grp in resctrl FS. @@ -96,10 +91,12 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) { unsigned long l_mask, l_mask_1; int ret, pipefd[2], sibling_cpu_no; + unsigned long cache_size = 0; + unsigned long long_mask; + char cbm_mask[256]; + int count_of_bits; char pipe_message; - cache_size = 0; - /* Get default cbm mask for L3/L2 cache */ ret = get_cbm_mask(cache_type, cbm_mask); if (ret) diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index 7214aefb55ed..0ac9d6bbd13d 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -16,11 +16,6 @@ #define MAX_DIFF 2000000 #define MAX_DIFF_PERCENT 15 -static int count_of_bits; -static char cbm_mask[256]; -static unsigned long long_mask; -static unsigned long cache_size; - static int cmt_setup(struct resctrl_val_param *p) { /* Run NUM_OF_RUNS times */ @@ -75,10 +70,12 @@ void cmt_test_cleanup(void) int cmt_resctrl_val(int cpu_no, int n, char **benchmark_cmd) { + unsigned long cache_size = 0; + unsigned long long_mask; + char cbm_mask[256]; + int count_of_bits; int ret; - cache_size = 0; - if (!validate_resctrl_feature_request(CMT_STR)) return -1;