2020-01-16 21:32:39 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/*
|
|
|
|
* Resctrl tests
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018 Intel Corporation
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>,
|
|
|
|
* Fenghua Yu <fenghua.yu@intel.com>
|
|
|
|
*/
|
|
|
|
#include "resctrl.h"
|
|
|
|
|
|
|
|
#define BENCHMARK_ARGS 64
|
|
|
|
#define BENCHMARK_ARG_SIZE 64
|
|
|
|
|
2020-01-16 21:32:43 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2020-01-16 21:32:39 +00:00
|
|
|
static void cmd_help(void)
|
|
|
|
{
|
2020-01-16 21:32:41 +00:00
|
|
|
printf("usage: resctrl_tests [-h] [-b \"benchmark_cmd [options]\"] [-t test list] [-n no_of_bits]\n");
|
selftests/resctrl: Rename CQM test as CMT test
CMT (Cache Monitoring Technology) [1] is a H/W feature that reports cache
occupancy of a process. resctrl selftest suite has a unit test to test CMT
for LLC but the test is named as CQM (Cache Quality Monitoring).
Furthermore, the unit test source file is named as cqm_test.c and several
functions, variables, comments, preprocessors and statements widely use
"cqm" as either suffix or prefix. This rampant misusage of CQM for CMT
might confuse someone who is newly looking at resctrl selftests because
this feature is named CMT in the Intel Software Developer's Manual.
Hence, rename all the occurrences (unit test source file name, functions,
variables, comments and preprocessors) of cqm with cmt.
[1] Please see Intel SDM, Volume 3, chapter 17 and section 18 for more
information on CMT: https://software.intel.com/content/www/us/en/develop/articles/intel-sdm.html
Suggested-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>
2021-03-17 02:22:41 +00:00
|
|
|
printf("\t-b benchmark_cmd [options]: run specified benchmark for MBM, MBA and CMT");
|
2020-01-16 21:32:39 +00:00
|
|
|
printf("\t default benchmark is builtin fill_buf\n");
|
|
|
|
printf("\t-t test list: run tests specified in the test list, ");
|
selftests/resctrl: Rename CQM test as CMT test
CMT (Cache Monitoring Technology) [1] is a H/W feature that reports cache
occupancy of a process. resctrl selftest suite has a unit test to test CMT
for LLC but the test is named as CQM (Cache Quality Monitoring).
Furthermore, the unit test source file is named as cqm_test.c and several
functions, variables, comments, preprocessors and statements widely use
"cqm" as either suffix or prefix. This rampant misusage of CQM for CMT
might confuse someone who is newly looking at resctrl selftests because
this feature is named CMT in the Intel Software Developer's Manual.
Hence, rename all the occurrences (unit test source file name, functions,
variables, comments and preprocessors) of cqm with cmt.
[1] Please see Intel SDM, Volume 3, chapter 17 and section 18 for more
information on CMT: https://software.intel.com/content/www/us/en/develop/articles/intel-sdm.html
Suggested-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>
2021-03-17 02:22:41 +00:00
|
|
|
printf("e.g. -t mbm, mba, cmt, cat\n");
|
2020-01-16 21:32:41 +00:00
|
|
|
printf("\t-n no_of_bits: run cache tests using specified no of bits in cache bit mask\n");
|
|
|
|
printf("\t-p cpu_no: specify CPU number to run the test. 1 is default\n");
|
2020-01-16 21:32:39 +00:00
|
|
|
printf("\t-h: help\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void tests_cleanup(void)
|
|
|
|
{
|
|
|
|
mbm_test_cleanup();
|
2020-01-16 21:32:40 +00:00
|
|
|
mba_test_cleanup();
|
selftests/resctrl: Rename CQM test as CMT test
CMT (Cache Monitoring Technology) [1] is a H/W feature that reports cache
occupancy of a process. resctrl selftest suite has a unit test to test CMT
for LLC but the test is named as CQM (Cache Quality Monitoring).
Furthermore, the unit test source file is named as cqm_test.c and several
functions, variables, comments, preprocessors and statements widely use
"cqm" as either suffix or prefix. This rampant misusage of CQM for CMT
might confuse someone who is newly looking at resctrl selftests because
this feature is named CMT in the Intel Software Developer's Manual.
Hence, rename all the occurrences (unit test source file name, functions,
variables, comments and preprocessors) of cqm with cmt.
[1] Please see Intel SDM, Volume 3, chapter 17 and section 18 for more
information on CMT: https://software.intel.com/content/www/us/en/develop/articles/intel-sdm.html
Suggested-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>
2021-03-17 02:22:41 +00:00
|
|
|
cmt_test_cleanup();
|
2020-01-16 21:32:42 +00:00
|
|
|
cat_test_cleanup();
|
2020-01-16 21:32:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
selftests/resctrl: Rename CQM test as CMT test
CMT (Cache Monitoring Technology) [1] is a H/W feature that reports cache
occupancy of a process. resctrl selftest suite has a unit test to test CMT
for LLC but the test is named as CQM (Cache Quality Monitoring).
Furthermore, the unit test source file is named as cqm_test.c and several
functions, variables, comments, preprocessors and statements widely use
"cqm" as either suffix or prefix. This rampant misusage of CQM for CMT
might confuse someone who is newly looking at resctrl selftests because
this feature is named CMT in the Intel Software Developer's Manual.
Hence, rename all the occurrences (unit test source file name, functions,
variables, comments and preprocessors) of cqm with cmt.
[1] Please see Intel SDM, Volume 3, chapter 17 and section 18 for more
information on CMT: https://software.intel.com/content/www/us/en/develop/articles/intel-sdm.html
Suggested-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>
2021-03-17 02:22:41 +00:00
|
|
|
bool has_ben = false, mbm_test = true, mba_test = true, cmt_test = true;
|
2020-01-16 21:32:41 +00:00
|
|
|
int res, c, cpu_no = 1, span = 250, argc_new = argc, i, no_of_bits = 5;
|
2020-01-16 21:32:39 +00:00
|
|
|
char *benchmark_cmd[BENCHMARK_ARGS], bw_report[64], bm_type[64];
|
|
|
|
char benchmark_cmd_area[BENCHMARK_ARGS][BENCHMARK_ARG_SIZE];
|
2021-03-17 02:22:42 +00:00
|
|
|
int ben_ind, ben_count, tests = 0;
|
2020-01-16 21:32:42 +00:00
|
|
|
bool cat_test = true;
|
2020-01-16 21:32:39 +00:00
|
|
|
|
|
|
|
for (i = 0; i < argc; i++) {
|
|
|
|
if (strcmp(argv[i], "-b") == 0) {
|
|
|
|
ben_ind = i + 1;
|
|
|
|
ben_count = argc - ben_ind;
|
|
|
|
argc_new = ben_ind - 1;
|
|
|
|
has_ben = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-17 02:22:40 +00:00
|
|
|
while ((c = getopt(argc_new, argv, "ht:b:n:p:")) != -1) {
|
2020-01-16 21:32:39 +00:00
|
|
|
char *token;
|
|
|
|
|
|
|
|
switch (c) {
|
|
|
|
case 't':
|
|
|
|
token = strtok(optarg, ",");
|
|
|
|
|
|
|
|
mbm_test = false;
|
2020-01-16 21:32:40 +00:00
|
|
|
mba_test = false;
|
selftests/resctrl: Rename CQM test as CMT test
CMT (Cache Monitoring Technology) [1] is a H/W feature that reports cache
occupancy of a process. resctrl selftest suite has a unit test to test CMT
for LLC but the test is named as CQM (Cache Quality Monitoring).
Furthermore, the unit test source file is named as cqm_test.c and several
functions, variables, comments, preprocessors and statements widely use
"cqm" as either suffix or prefix. This rampant misusage of CQM for CMT
might confuse someone who is newly looking at resctrl selftests because
this feature is named CMT in the Intel Software Developer's Manual.
Hence, rename all the occurrences (unit test source file name, functions,
variables, comments and preprocessors) of cqm with cmt.
[1] Please see Intel SDM, Volume 3, chapter 17 and section 18 for more
information on CMT: https://software.intel.com/content/www/us/en/develop/articles/intel-sdm.html
Suggested-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>
2021-03-17 02:22:41 +00:00
|
|
|
cmt_test = false;
|
2020-01-16 21:32:42 +00:00
|
|
|
cat_test = false;
|
2020-01-16 21:32:39 +00:00
|
|
|
while (token) {
|
2021-03-17 02:22:38 +00:00
|
|
|
if (!strncmp(token, MBM_STR, sizeof(MBM_STR))) {
|
2020-01-16 21:32:39 +00:00
|
|
|
mbm_test = true;
|
2021-03-17 02:22:42 +00:00
|
|
|
tests++;
|
2021-03-17 02:22:38 +00:00
|
|
|
} else if (!strncmp(token, MBA_STR, sizeof(MBA_STR))) {
|
2020-01-16 21:32:40 +00:00
|
|
|
mba_test = true;
|
2021-03-17 02:22:42 +00:00
|
|
|
tests++;
|
selftests/resctrl: Rename CQM test as CMT test
CMT (Cache Monitoring Technology) [1] is a H/W feature that reports cache
occupancy of a process. resctrl selftest suite has a unit test to test CMT
for LLC but the test is named as CQM (Cache Quality Monitoring).
Furthermore, the unit test source file is named as cqm_test.c and several
functions, variables, comments, preprocessors and statements widely use
"cqm" as either suffix or prefix. This rampant misusage of CQM for CMT
might confuse someone who is newly looking at resctrl selftests because
this feature is named CMT in the Intel Software Developer's Manual.
Hence, rename all the occurrences (unit test source file name, functions,
variables, comments and preprocessors) of cqm with cmt.
[1] Please see Intel SDM, Volume 3, chapter 17 and section 18 for more
information on CMT: https://software.intel.com/content/www/us/en/develop/articles/intel-sdm.html
Suggested-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>
2021-03-17 02:22:41 +00:00
|
|
|
} else if (!strncmp(token, CMT_STR, sizeof(CMT_STR))) {
|
|
|
|
cmt_test = true;
|
2021-03-17 02:22:42 +00:00
|
|
|
tests++;
|
2021-03-17 02:22:38 +00:00
|
|
|
} else if (!strncmp(token, CAT_STR, sizeof(CAT_STR))) {
|
2020-01-16 21:32:42 +00:00
|
|
|
cat_test = true;
|
2021-03-17 02:22:42 +00:00
|
|
|
tests++;
|
2020-01-16 21:32:39 +00:00
|
|
|
} else {
|
|
|
|
printf("invalid argument\n");
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
token = strtok(NULL, ":\t");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'p':
|
|
|
|
cpu_no = atoi(optarg);
|
|
|
|
break;
|
2020-01-16 21:32:41 +00:00
|
|
|
case 'n':
|
|
|
|
no_of_bits = atoi(optarg);
|
|
|
|
break;
|
2020-01-16 21:32:39 +00:00
|
|
|
case 'h':
|
|
|
|
cmd_help();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
printf("invalid argument\n");
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-17 02:22:42 +00:00
|
|
|
ksft_print_header();
|
2020-01-16 21:32:39 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Typically we need root privileges, because:
|
|
|
|
* 1. We write to resctrl FS
|
|
|
|
* 2. We execute perf commands
|
|
|
|
*/
|
|
|
|
if (geteuid() != 0)
|
2021-03-17 02:22:42 +00:00
|
|
|
return ksft_exit_fail_msg("Not running as root, abort testing.\n");
|
2020-01-16 21:32:39 +00:00
|
|
|
|
2020-01-16 21:32:43 +00:00
|
|
|
/* Detect AMD vendor */
|
|
|
|
detect_amd();
|
|
|
|
|
2020-01-16 21:32:39 +00:00
|
|
|
if (has_ben) {
|
|
|
|
/* Extract benchmark command from command line. */
|
|
|
|
for (i = ben_ind; i < argc; i++) {
|
|
|
|
benchmark_cmd[i - ben_ind] = benchmark_cmd_area[i];
|
|
|
|
sprintf(benchmark_cmd[i - ben_ind], "%s", argv[i]);
|
|
|
|
}
|
|
|
|
benchmark_cmd[ben_count] = NULL;
|
|
|
|
} else {
|
|
|
|
/* If no benchmark is given by "-b" argument, use fill_buf. */
|
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
benchmark_cmd[i] = benchmark_cmd_area[i];
|
|
|
|
|
|
|
|
strcpy(benchmark_cmd[0], "fill_buf");
|
|
|
|
sprintf(benchmark_cmd[1], "%d", span);
|
|
|
|
strcpy(benchmark_cmd[2], "1");
|
|
|
|
strcpy(benchmark_cmd[3], "1");
|
|
|
|
strcpy(benchmark_cmd[4], "0");
|
|
|
|
strcpy(benchmark_cmd[5], "");
|
|
|
|
benchmark_cmd[6] = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(bw_report, "reads");
|
|
|
|
sprintf(bm_type, "fill_buf");
|
|
|
|
|
2021-03-17 02:22:42 +00:00
|
|
|
if (!check_resctrlfs_support())
|
|
|
|
return ksft_exit_fail_msg("resctrl FS does not exist\n");
|
|
|
|
|
2020-01-16 21:32:39 +00:00
|
|
|
filter_dmesg();
|
|
|
|
|
2021-03-17 02:22:42 +00:00
|
|
|
ksft_set_plan(tests ? : 4);
|
|
|
|
|
2020-01-16 21:32:45 +00:00
|
|
|
if (!is_amd && mbm_test) {
|
2021-03-17 02:22:42 +00:00
|
|
|
ksft_print_msg("Starting MBM BW change ...\n");
|
2020-01-16 21:32:39 +00:00
|
|
|
if (!has_ben)
|
2021-03-17 02:22:38 +00:00
|
|
|
sprintf(benchmark_cmd[5], "%s", MBA_STR);
|
2020-01-16 21:32:39 +00:00
|
|
|
res = mbm_bw_change(span, cpu_no, bw_report, benchmark_cmd);
|
2021-03-17 02:22:42 +00:00
|
|
|
ksft_test_result(!res, "MBM: bw change\n");
|
2020-01-16 21:32:39 +00:00
|
|
|
mbm_test_cleanup();
|
|
|
|
}
|
|
|
|
|
2020-01-16 21:32:45 +00:00
|
|
|
if (!is_amd && mba_test) {
|
2021-03-17 02:22:42 +00:00
|
|
|
ksft_print_msg("Starting MBA Schemata change ...\n");
|
2020-01-16 21:32:40 +00:00
|
|
|
if (!has_ben)
|
|
|
|
sprintf(benchmark_cmd[1], "%d", span);
|
|
|
|
res = mba_schemata_change(cpu_no, bw_report, benchmark_cmd);
|
2021-03-17 02:22:42 +00:00
|
|
|
ksft_test_result(!res, "MBA: schemata change\n");
|
2020-01-16 21:32:40 +00:00
|
|
|
mba_test_cleanup();
|
|
|
|
}
|
|
|
|
|
selftests/resctrl: Rename CQM test as CMT test
CMT (Cache Monitoring Technology) [1] is a H/W feature that reports cache
occupancy of a process. resctrl selftest suite has a unit test to test CMT
for LLC but the test is named as CQM (Cache Quality Monitoring).
Furthermore, the unit test source file is named as cqm_test.c and several
functions, variables, comments, preprocessors and statements widely use
"cqm" as either suffix or prefix. This rampant misusage of CQM for CMT
might confuse someone who is newly looking at resctrl selftests because
this feature is named CMT in the Intel Software Developer's Manual.
Hence, rename all the occurrences (unit test source file name, functions,
variables, comments and preprocessors) of cqm with cmt.
[1] Please see Intel SDM, Volume 3, chapter 17 and section 18 for more
information on CMT: https://software.intel.com/content/www/us/en/develop/articles/intel-sdm.html
Suggested-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>
2021-03-17 02:22:41 +00:00
|
|
|
if (cmt_test) {
|
2021-03-17 02:22:42 +00:00
|
|
|
ksft_print_msg("Starting CMT test ...\n");
|
2020-01-16 21:32:41 +00:00
|
|
|
if (!has_ben)
|
selftests/resctrl: Rename CQM test as CMT test
CMT (Cache Monitoring Technology) [1] is a H/W feature that reports cache
occupancy of a process. resctrl selftest suite has a unit test to test CMT
for LLC but the test is named as CQM (Cache Quality Monitoring).
Furthermore, the unit test source file is named as cqm_test.c and several
functions, variables, comments, preprocessors and statements widely use
"cqm" as either suffix or prefix. This rampant misusage of CQM for CMT
might confuse someone who is newly looking at resctrl selftests because
this feature is named CMT in the Intel Software Developer's Manual.
Hence, rename all the occurrences (unit test source file name, functions,
variables, comments and preprocessors) of cqm with cmt.
[1] Please see Intel SDM, Volume 3, chapter 17 and section 18 for more
information on CMT: https://software.intel.com/content/www/us/en/develop/articles/intel-sdm.html
Suggested-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>
2021-03-17 02:22:41 +00:00
|
|
|
sprintf(benchmark_cmd[5], "%s", CMT_STR);
|
|
|
|
res = cmt_resctrl_val(cpu_no, no_of_bits, benchmark_cmd);
|
2021-03-17 02:22:42 +00:00
|
|
|
ksft_test_result(!res, "CMT: test\n");
|
selftests/resctrl: Rename CQM test as CMT test
CMT (Cache Monitoring Technology) [1] is a H/W feature that reports cache
occupancy of a process. resctrl selftest suite has a unit test to test CMT
for LLC but the test is named as CQM (Cache Quality Monitoring).
Furthermore, the unit test source file is named as cqm_test.c and several
functions, variables, comments, preprocessors and statements widely use
"cqm" as either suffix or prefix. This rampant misusage of CQM for CMT
might confuse someone who is newly looking at resctrl selftests because
this feature is named CMT in the Intel Software Developer's Manual.
Hence, rename all the occurrences (unit test source file name, functions,
variables, comments and preprocessors) of cqm with cmt.
[1] Please see Intel SDM, Volume 3, chapter 17 and section 18 for more
information on CMT: https://software.intel.com/content/www/us/en/develop/articles/intel-sdm.html
Suggested-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>
2021-03-17 02:22:41 +00:00
|
|
|
cmt_test_cleanup();
|
2020-01-16 21:32:41 +00:00
|
|
|
}
|
|
|
|
|
2020-01-16 21:32:42 +00:00
|
|
|
if (cat_test) {
|
2021-03-17 02:22:42 +00:00
|
|
|
ksft_print_msg("Starting CAT test ...\n");
|
2020-01-16 21:32:42 +00:00
|
|
|
res = cat_perf_miss_val(cpu_no, no_of_bits, "L3");
|
2021-03-17 02:22:42 +00:00
|
|
|
ksft_test_result(!res, "CAT: test\n");
|
2020-01-16 21:32:42 +00:00
|
|
|
cat_test_cleanup();
|
|
|
|
}
|
|
|
|
|
2021-03-17 02:22:42 +00:00
|
|
|
return ksft_exit_pass();
|
2020-01-16 21:32:39 +00:00
|
|
|
}
|