mirror of
https://github.com/torvalds/linux.git
synced 2026-06-07 14:04:54 +02:00
selftests/resctrl: Fix compilation issues for global variables
[ Upstream commit 8236c51d85 ]
Reinette reported following compilation issue on Fedora 32, gcc version
10.1.1
/usr/bin/ld: cqm_test.o:<src_dir>/cqm_test.c:22: multiple definition of
`cache_size'; cat_test.o:<src_dir>/cat_test.c:23: first defined here
The same issue is reported for long_mask, cbm_mask, count_of_bits etc
variables as well. Compiler isn't happy because these variables are
defined globally in two .c files namely cqm_test.c and cat_test.c and
the compiler during compilation finds that the variable is already
defined (multiple definition error).
Taking a closer look at the usage of these variables reveals that these
variables are used only locally in functions such as cqm_resctrl_val()
(defined in cqm_test.c) and cat_perf_miss_val() (defined in cat_test.c).
These variables are not shared between those functions. So, there is no
need for these variables to be global. Hence, fix this issue by making
them static variables.
Reported-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
078d3d75dd
commit
cf99daf7c3
|
|
@ -17,10 +17,10 @@
|
||||||
#define MAX_DIFF_PERCENT 4
|
#define MAX_DIFF_PERCENT 4
|
||||||
#define MAX_DIFF 1000000
|
#define MAX_DIFF 1000000
|
||||||
|
|
||||||
int count_of_bits;
|
static int count_of_bits;
|
||||||
char cbm_mask[256];
|
static char cbm_mask[256];
|
||||||
unsigned long long_mask;
|
static unsigned long long_mask;
|
||||||
unsigned long cache_size;
|
static unsigned long cache_size;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Change schemata. Write schemata to specified
|
* Change schemata. Write schemata to specified
|
||||||
|
|
@ -136,7 +136,7 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Get default cbm mask for L3/L2 cache */
|
/* Get default cbm mask for L3/L2 cache */
|
||||||
ret = get_cbm_mask(cache_type);
|
ret = get_cbm_mask(cache_type, cbm_mask);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,10 @@
|
||||||
#define MAX_DIFF 2000000
|
#define MAX_DIFF 2000000
|
||||||
#define MAX_DIFF_PERCENT 15
|
#define MAX_DIFF_PERCENT 15
|
||||||
|
|
||||||
int count_of_bits;
|
static int count_of_bits;
|
||||||
char cbm_mask[256];
|
static char cbm_mask[256];
|
||||||
unsigned long long_mask;
|
static unsigned long long_mask;
|
||||||
unsigned long cache_size;
|
static unsigned long cache_size;
|
||||||
|
|
||||||
static int cqm_setup(int num, ...)
|
static int cqm_setup(int num, ...)
|
||||||
{
|
{
|
||||||
|
|
@ -125,7 +125,7 @@ int cqm_resctrl_val(int cpu_no, int n, char **benchmark_cmd)
|
||||||
if (!validate_resctrl_feature_request("cqm"))
|
if (!validate_resctrl_feature_request("cqm"))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
ret = get_cbm_mask("L3");
|
ret = get_cbm_mask("L3", cbm_mask);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ void tests_cleanup(void);
|
||||||
void mbm_test_cleanup(void);
|
void mbm_test_cleanup(void);
|
||||||
int mba_schemata_change(int cpu_no, char *bw_report, char **benchmark_cmd);
|
int mba_schemata_change(int cpu_no, char *bw_report, char **benchmark_cmd);
|
||||||
void mba_test_cleanup(void);
|
void mba_test_cleanup(void);
|
||||||
int get_cbm_mask(char *cache_type);
|
int get_cbm_mask(char *cache_type, char *cbm_mask);
|
||||||
int get_cache_size(int cpu_no, char *cache_type, unsigned long *cache_size);
|
int get_cache_size(int cpu_no, char *cache_type, unsigned long *cache_size);
|
||||||
void ctrlc_handler(int signum, siginfo_t *info, void *ptr);
|
void ctrlc_handler(int signum, siginfo_t *info, void *ptr);
|
||||||
int cat_val(struct resctrl_val_param *param);
|
int cat_val(struct resctrl_val_param *param);
|
||||||
|
|
|
||||||
|
|
@ -49,8 +49,6 @@ static int find_resctrl_mount(char *buffer)
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
char cbm_mask[256];
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* remount_resctrlfs - Remount resctrl FS at /sys/fs/resctrl
|
* remount_resctrlfs - Remount resctrl FS at /sys/fs/resctrl
|
||||||
* @mum_resctrlfs: Should the resctrl FS be remounted?
|
* @mum_resctrlfs: Should the resctrl FS be remounted?
|
||||||
|
|
@ -205,16 +203,18 @@ int get_cache_size(int cpu_no, char *cache_type, unsigned long *cache_size)
|
||||||
/*
|
/*
|
||||||
* get_cbm_mask - Get cbm mask for given cache
|
* get_cbm_mask - Get cbm mask for given cache
|
||||||
* @cache_type: Cache level L2/L3
|
* @cache_type: Cache level L2/L3
|
||||||
*
|
* @cbm_mask: cbm_mask returned as a string
|
||||||
* Mask is stored in cbm_mask which is global variable.
|
|
||||||
*
|
*
|
||||||
* Return: = 0 on success, < 0 on failure.
|
* Return: = 0 on success, < 0 on failure.
|
||||||
*/
|
*/
|
||||||
int get_cbm_mask(char *cache_type)
|
int get_cbm_mask(char *cache_type, char *cbm_mask)
|
||||||
{
|
{
|
||||||
char cbm_mask_path[1024];
|
char cbm_mask_path[1024];
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
|
if (!cbm_mask)
|
||||||
|
return -1;
|
||||||
|
|
||||||
sprintf(cbm_mask_path, "%s/%s/cbm_mask", CBM_MASK_PATH, cache_type);
|
sprintf(cbm_mask_path, "%s/%s/cbm_mask", CBM_MASK_PATH, cache_type);
|
||||||
|
|
||||||
fp = fopen(cbm_mask_path, "r");
|
fp = fopen(cbm_mask_path, "r");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user