[18/22] selftests/resctrl: Move CAT/CMT test global vars to func they are used

Message ID 20230412132122.29452-19-ilpo.jarvinen@linux.intel.com
State New
Headers
Series selftests/resctrl: Fixes, cleanups, and rewritten CAT test |

Commit Message

Ilpo Järvinen April 12, 2023, 1:21 p.m. UTC
  CAT and CMT tests have count_of_bits, long_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.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 tools/testing/selftests/resctrl/cat_test.c | 7 +++----
 tools/testing/selftests/resctrl/cmt_test.c | 7 +++----
 2 files changed, 6 insertions(+), 8 deletions(-)
  

Patch

diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c
index edcc340744d7..cfad7e488340 100644
--- a/tools/testing/selftests/resctrl/cat_test.c
+++ b/tools/testing/selftests/resctrl/cat_test.c
@@ -17,10 +17,6 @@ 
 #define MAX_DIFF_PERCENT	4
 #define MAX_DIFF		1000000
 
-static int count_of_bits;
-static unsigned long long_mask;
-static unsigned long cache_size;
-
 /*
  * Change schemata. Write schemata to specified
  * con_mon grp, mon_grp in resctrl FS.
@@ -95,6 +91,9 @@  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;
+	unsigned long long_mask;
+	int count_of_bits;
 	char pipe_message;
 	pid_t bm_pid;
 
diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c
index 70c656581686..8fda7fc4d159 100644
--- a/tools/testing/selftests/resctrl/cmt_test.c
+++ b/tools/testing/selftests/resctrl/cmt_test.c
@@ -16,10 +16,6 @@ 
 #define MAX_DIFF		2000000
 #define MAX_DIFF_PERCENT	15
 
-static int count_of_bits;
-static unsigned long long_mask;
-static unsigned long cache_size;
-
 static int cmt_setup(struct resctrl_val_param *p)
 {
 	/* Run NUM_OF_RUNS times */
@@ -74,6 +70,9 @@  void cmt_test_cleanup(void)
 
 int cmt_resctrl_val(int cpu_no, int n, char **benchmark_cmd)
 {
+	unsigned long cache_size;
+	unsigned long long_mask;
+	int count_of_bits;
 	int ret;
 
 	cache_size = 0;