Skip to content

Commit 85b7344

Browse files
ij-intelshuahkh
authored andcommitted
selftests/resctrl: Move CAT/CMT test global vars to function they are used in
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 <ilpo.jarvinen@linux.intel.com> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Tested-by: Babu Moger <babu.moger@amd.com> Tested-by: Shaopeng Tan (Fujitsu) <tan.shaopeng@fujitsu.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent 8ee592a commit 85b7344

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

tools/testing/selftests/resctrl/cat_test.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717
#define MAX_DIFF_PERCENT 4
1818
#define MAX_DIFF 1000000
1919

20-
static int count_of_bits;
21-
static char cbm_mask[256];
22-
static unsigned long long_mask;
23-
static unsigned long cache_size;
24-
2520
/*
2621
* Change schemata. Write schemata to specified
2722
* 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)
9691
{
9792
unsigned long l_mask, l_mask_1;
9893
int ret, pipefd[2], sibling_cpu_no;
94+
unsigned long cache_size = 0;
95+
unsigned long long_mask;
96+
char cbm_mask[256];
97+
int count_of_bits;
9998
char pipe_message;
10099

101-
cache_size = 0;
102-
103100
/* Get default cbm mask for L3/L2 cache */
104101
ret = get_cbm_mask(cache_type, cbm_mask);
105102
if (ret)

tools/testing/selftests/resctrl/cmt_test.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616
#define MAX_DIFF 2000000
1717
#define MAX_DIFF_PERCENT 15
1818

19-
static int count_of_bits;
20-
static char cbm_mask[256];
21-
static unsigned long long_mask;
22-
static unsigned long cache_size;
23-
2419
static int cmt_setup(struct resctrl_val_param *p)
2520
{
2621
/* Run NUM_OF_RUNS times */
@@ -75,10 +70,12 @@ void cmt_test_cleanup(void)
7570

7671
int cmt_resctrl_val(int cpu_no, int n, char **benchmark_cmd)
7772
{
73+
unsigned long cache_size = 0;
74+
unsigned long long_mask;
75+
char cbm_mask[256];
76+
int count_of_bits;
7877
int ret;
7978

80-
cache_size = 0;
81-
8279
if (!validate_resctrl_feature_request(CMT_STR))
8380
return -1;
8481

0 commit comments

Comments
 (0)