diff options
author | Babu Moger <[email protected]> | 2020-01-16 13:32:43 -0800 |
---|---|---|
committer | Shuah Khan <[email protected]> | 2020-02-10 18:43:17 -0700 |
commit | 53f74fbec9f069241aa6f4c4d908229c77ee83e2 (patch) | |
tree | 441424a750794e87f90a958a15876c6ef9e5acaa /tools/testing/selftests/resctrl/resctrl_tests.c | |
parent | 790bf585b0eeec9aa0e680ba090142b98da7f948 (diff) |
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 <[email protected]>
Co-developed-by: Fenghua Yu <[email protected]>
Signed-off-by: Fenghua Yu <[email protected]>
Signed-off-by: Shuah Khan <[email protected]>
Diffstat (limited to 'tools/testing/selftests/resctrl/resctrl_tests.c')
-rw-r--r-- | tools/testing/selftests/resctrl/resctrl_tests.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index 7f75b0b01bb5..884e918b1e97 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -13,6 +13,27 @@ #define BENCHMARK_ARGS 64 #define BENCHMARK_ARG_SIZE 64 +bool is_amd; + +void detect_amd(void) +{ + FILE *inf = fopen("/proc/cpuinfo", "r"); + char *res; + + if (!inf) + return; + + res = fgrep(inf, "vendor_id"); + + if (res) { + char *s = strchr(res, ':'); + + is_amd = s && !strcmp(s, ": AuthenticAMD\n"); + free(res); + } + fclose(inf); +} + static void cmd_help(void) { printf("usage: resctrl_tests [-h] [-b \"benchmark_cmd [options]\"] [-t test list] [-n no_of_bits]\n"); @@ -107,6 +128,9 @@ int main(int argc, char **argv) if (geteuid() != 0) printf("# WARNING: not running as root, tests may fail.\n"); + /* Detect AMD vendor */ + detect_amd(); + if (has_ben) { /* Extract benchmark command from command line. */ for (i = ben_ind; i < argc; i++) { |