selftests/resctrl: Extend CPU vendor detection
Currently, the resctrl_tests only has a function to detect AMD vendor. Since when the Intel Sub-NUMA Clustering feature is enabled, Intel CMT and MBM counters may not be accurate, the resctrl_tests also need a function to detect Intel vendor. And in the future, resctrl_tests will need a function to detect different vendors, such as Arm. Extend the function to detect Intel vendor as well. Also, this function can be easily extended to detect other vendors. Signed-off-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Reviewed-by: Shuah Khan <skhan@linuxfoundation.org> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
This commit is contained in:
parent
170d1c23f2
commit
6220f69e72
@ -89,7 +89,7 @@ static int check_results(struct resctrl_val_param *param)
|
|||||||
|
|
||||||
return show_cache_info(sum_llc_perf_miss, no_of_bits, param->span / 64,
|
return show_cache_info(sum_llc_perf_miss, no_of_bits, param->span / 64,
|
||||||
MAX_DIFF, MAX_DIFF_PERCENT, NUM_OF_RUNS,
|
MAX_DIFF, MAX_DIFF_PERCENT, NUM_OF_RUNS,
|
||||||
!is_amd, false);
|
get_vendor() == ARCH_INTEL, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cat_test_cleanup(void)
|
void cat_test_cleanup(void)
|
||||||
|
@ -34,6 +34,9 @@
|
|||||||
#define L3_MON_PATH "/sys/fs/resctrl/info/L3_MON"
|
#define L3_MON_PATH "/sys/fs/resctrl/info/L3_MON"
|
||||||
#define L3_MON_FEATURES_PATH "/sys/fs/resctrl/info/L3_MON/mon_features"
|
#define L3_MON_FEATURES_PATH "/sys/fs/resctrl/info/L3_MON/mon_features"
|
||||||
|
|
||||||
|
#define ARCH_INTEL 1
|
||||||
|
#define ARCH_AMD 2
|
||||||
|
|
||||||
#define PARENT_EXIT(err_msg) \
|
#define PARENT_EXIT(err_msg) \
|
||||||
do { \
|
do { \
|
||||||
perror(err_msg); \
|
perror(err_msg); \
|
||||||
@ -75,8 +78,8 @@ struct resctrl_val_param {
|
|||||||
extern pid_t bm_pid, ppid;
|
extern pid_t bm_pid, ppid;
|
||||||
|
|
||||||
extern char llc_occup_path[1024];
|
extern char llc_occup_path[1024];
|
||||||
extern bool is_amd;
|
|
||||||
|
|
||||||
|
int get_vendor(void);
|
||||||
bool check_resctrlfs_support(void);
|
bool check_resctrlfs_support(void);
|
||||||
int filter_dmesg(void);
|
int filter_dmesg(void);
|
||||||
int remount_resctrlfs(bool mum_resctrlfs);
|
int remount_resctrlfs(bool mum_resctrlfs);
|
||||||
|
@ -13,25 +13,41 @@
|
|||||||
#define BENCHMARK_ARGS 64
|
#define BENCHMARK_ARGS 64
|
||||||
#define BENCHMARK_ARG_SIZE 64
|
#define BENCHMARK_ARG_SIZE 64
|
||||||
|
|
||||||
bool is_amd;
|
static int detect_vendor(void)
|
||||||
|
|
||||||
void detect_amd(void)
|
|
||||||
{
|
{
|
||||||
FILE *inf = fopen("/proc/cpuinfo", "r");
|
FILE *inf = fopen("/proc/cpuinfo", "r");
|
||||||
|
int vendor_id = 0;
|
||||||
|
char *s = NULL;
|
||||||
char *res;
|
char *res;
|
||||||
|
|
||||||
if (!inf)
|
if (!inf)
|
||||||
return;
|
return vendor_id;
|
||||||
|
|
||||||
res = fgrep(inf, "vendor_id");
|
res = fgrep(inf, "vendor_id");
|
||||||
|
|
||||||
if (res) {
|
if (res)
|
||||||
char *s = strchr(res, ':');
|
s = strchr(res, ':');
|
||||||
|
|
||||||
|
if (s && !strcmp(s, ": GenuineIntel\n"))
|
||||||
|
vendor_id = ARCH_INTEL;
|
||||||
|
else if (s && !strcmp(s, ": AuthenticAMD\n"))
|
||||||
|
vendor_id = ARCH_AMD;
|
||||||
|
|
||||||
is_amd = s && !strcmp(s, ": AuthenticAMD\n");
|
|
||||||
free(res);
|
|
||||||
}
|
|
||||||
fclose(inf);
|
fclose(inf);
|
||||||
|
free(res);
|
||||||
|
return vendor_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_vendor(void)
|
||||||
|
{
|
||||||
|
static int vendor = -1;
|
||||||
|
|
||||||
|
if (vendor == -1)
|
||||||
|
vendor = detect_vendor();
|
||||||
|
if (vendor == 0)
|
||||||
|
ksft_print_msg("Can not get vendor info...\n");
|
||||||
|
|
||||||
|
return vendor;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_help(void)
|
static void cmd_help(void)
|
||||||
@ -207,9 +223,6 @@ int main(int argc, char **argv)
|
|||||||
if (geteuid() != 0)
|
if (geteuid() != 0)
|
||||||
return ksft_exit_fail_msg("Not running as root, abort testing.\n");
|
return ksft_exit_fail_msg("Not running as root, abort testing.\n");
|
||||||
|
|
||||||
/* Detect AMD vendor */
|
|
||||||
detect_amd();
|
|
||||||
|
|
||||||
if (has_ben) {
|
if (has_ben) {
|
||||||
/* Extract benchmark command from command line. */
|
/* Extract benchmark command from command line. */
|
||||||
for (i = ben_ind; i < argc; i++) {
|
for (i = ben_ind; i < argc; i++) {
|
||||||
@ -241,10 +254,10 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
ksft_set_plan(tests ? : 4);
|
ksft_set_plan(tests ? : 4);
|
||||||
|
|
||||||
if (!is_amd && mbm_test)
|
if ((get_vendor() == ARCH_INTEL) && mbm_test)
|
||||||
run_mbm_test(has_ben, benchmark_cmd, span, cpu_no, bw_report);
|
run_mbm_test(has_ben, benchmark_cmd, span, cpu_no, bw_report);
|
||||||
|
|
||||||
if (!is_amd && mba_test)
|
if ((get_vendor() == ARCH_INTEL) && mba_test)
|
||||||
run_mba_test(has_ben, benchmark_cmd, span, cpu_no, bw_report);
|
run_mba_test(has_ben, benchmark_cmd, span, cpu_no, bw_report);
|
||||||
|
|
||||||
if (cmt_test)
|
if (cmt_test)
|
||||||
|
@ -106,7 +106,7 @@ int get_resource_id(int cpu_no, int *resource_id)
|
|||||||
char phys_pkg_path[1024];
|
char phys_pkg_path[1024];
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
if (is_amd)
|
if (get_vendor() == ARCH_AMD)
|
||||||
sprintf(phys_pkg_path, "%s%d/cache/index3/id",
|
sprintf(phys_pkg_path, "%s%d/cache/index3/id",
|
||||||
PHYS_ID_PATH, cpu_no);
|
PHYS_ID_PATH, cpu_no);
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user