Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/resctrl: Add vendor detection mechanism

RESCTRL feature is supported both on Intel and AMD now. Some features
are implemented differently. Add vendor detection mechanism. Use the vendor
check where there are differences.

Signed-off-by: Babu Moger <babu.moger@amd.com>
Co-developed-by: Fenghua Yu <fenghua.yu@intel.com>
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Babu Moger and committed by
Shuah Khan
53f74fbe 790bf585

+25
+1
tools/testing/selftests/resctrl/resctrl.h
··· 66 66 int tests_run; 67 67 68 68 char llc_occup_path[1024]; 69 + bool is_amd; 69 70 70 71 bool check_resctrlfs_support(void); 71 72 int filter_dmesg(void);
+24
tools/testing/selftests/resctrl/resctrl_tests.c
··· 13 13 #define BENCHMARK_ARGS 64 14 14 #define BENCHMARK_ARG_SIZE 64 15 15 16 + bool is_amd; 17 + 18 + void detect_amd(void) 19 + { 20 + FILE *inf = fopen("/proc/cpuinfo", "r"); 21 + char *res; 22 + 23 + if (!inf) 24 + return; 25 + 26 + res = fgrep(inf, "vendor_id"); 27 + 28 + if (res) { 29 + char *s = strchr(res, ':'); 30 + 31 + is_amd = s && !strcmp(s, ": AuthenticAMD\n"); 32 + free(res); 33 + } 34 + fclose(inf); 35 + } 36 + 16 37 static void cmd_help(void) 17 38 { 18 39 printf("usage: resctrl_tests [-h] [-b \"benchmark_cmd [options]\"] [-t test list] [-n no_of_bits]\n"); ··· 127 106 */ 128 107 if (geteuid() != 0) 129 108 printf("# WARNING: not running as root, tests may fail.\n"); 109 + 110 + /* Detect AMD vendor */ 111 + detect_amd(); 130 112 131 113 if (has_ben) { 132 114 /* Extract benchmark command from command line. */