Message ID | 20230418114506.46788-21-ilpo.jarvinen@linux.intel.com |
---|---|
State | New |
Headers | show |
Series | selftests/resctrl: Fixes, cleanups, and rewritten CAT test | expand |
Hi Ilpo, On 4/18/2023 4:45 AM, Ilpo Järvinen wrote: > 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. > Could you please move this patch earlier, before usage of long_mask in earlier patch. > 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(-) > > diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c > index ae21e656cf6e..ef3ba22bdde5 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; > > cache_size = 0; Seems like this initialization can be moved to the definition? > diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c > index 087378a775ee..6adee08661e7 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; Same here. Reinette
diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index ae21e656cf6e..ef3ba22bdde5 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; cache_size = 0; diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index 087378a775ee..6adee08661e7 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;
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(-)