Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp1134626rwp; Thu, 13 Jul 2023 06:42:11 -0700 (PDT) X-Google-Smtp-Source: APBJJlELTgC+nelZ0hYGm22qc5FNJN1J6b691pSsPIZ1z7waEDNg3mSmbR0/oQdy0Y0kdzSPO9ds X-Received: by 2002:a05:6358:99a8:b0:134:c1a5:aeee with SMTP id j40-20020a05635899a800b00134c1a5aeeemr2257481rwb.21.1689255731271; Thu, 13 Jul 2023 06:42:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689255731; cv=none; d=google.com; s=arc-20160816; b=Q8EIAt/S1vDhdf+ITd5wo1k3ujEhNJBIIg76dYq4+0oKwNHx6Vxtpi1rglEay8wYEv dNHdepaEw+Hfp8NZsQT6lhL/4Tl7Tyy5lIFU+aKYZzwegqltL12tepoYDYk7RfpXZ/qg eSPxEmZI95Q0tKtpqpg8Wj2BIKdXZ4UyUlqQG6YWVG72920XMT+pTdEI/HpGVtFmUTtm WfwPVKpAuP/bRGIa7qlfPAzF4qrPbMU2rSSFU4Xzyua3bOoX+2w+pCMwlPtdexpGX9UZ HSHC8bSeztIASZkcBRkYBTuwvBfgW1csy55xqsrZxGzvxP/8is149xC4EOwo/HspSyKu SeBg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d7-20020a631d07000000b0055c7da0216dsi1746981pgd.635.2023.07.13.06.41.59; Thu, 13 Jul 2023 06:42:11 -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 S234306AbjGMNXg (ORCPT + 99 others); Thu, 13 Jul 2023 09:23:36 -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=20J=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=20J=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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 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 --- 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; -- 2.30.2