2020-01-16 13:32:41 -08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/*
|
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
|
|
|
* Cache Monitoring Technology (CMT) test
|
2020-01-16 13:32:41 -08:00
|
|
|
*
|
|
|
|
* Copyright (C) 2018 Intel Corporation
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>,
|
|
|
|
* Fenghua Yu <fenghua.yu@intel.com>
|
|
|
|
*/
|
|
|
|
#include "resctrl.h"
|
|
|
|
#include <unistd.h>
|
|
|
|
|
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
|
|
|
#define RESULT_FILE_NAME "result_cmt"
|
2020-01-16 13:32:41 -08:00
|
|
|
#define NUM_OF_RUNS 5
|
|
|
|
#define MAX_DIFF 2000000
|
|
|
|
#define MAX_DIFF_PERCENT 15
|
|
|
|
|
2024-06-10 18:14:51 +03:00
|
|
|
#define CON_MON_LCC_OCCUP_PATH \
|
2024-06-10 18:14:56 +03:00
|
|
|
"%s/%s/mon_data/mon_L3_%02d/llc_occupancy"
|
2024-06-10 18:14:51 +03:00
|
|
|
|
|
|
|
static int cmt_init(const struct resctrl_val_param *param, int domain_id)
|
|
|
|
{
|
|
|
|
sprintf(llc_occup_path, CON_MON_LCC_OCCUP_PATH, RESCTRL_PATH,
|
2024-06-10 18:14:56 +03:00
|
|
|
param->ctrlgrp, domain_id);
|
2024-06-10 18:14:51 +03:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-12-15 17:05:12 +02:00
|
|
|
static int cmt_setup(const struct resctrl_test *test,
|
|
|
|
const struct user_params *uparams,
|
|
|
|
struct resctrl_val_param *p)
|
2020-01-16 13:32:41 -08:00
|
|
|
{
|
|
|
|
/* Run NUM_OF_RUNS times */
|
|
|
|
if (p->num_of_runs >= NUM_OF_RUNS)
|
2023-02-15 15:05:59 +02:00
|
|
|
return END_OF_TESTS;
|
2020-01-16 13:32:41 -08:00
|
|
|
|
|
|
|
p->num_of_runs++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2024-06-10 18:14:50 +03:00
|
|
|
static int cmt_measure(const struct user_params *uparams,
|
|
|
|
struct resctrl_val_param *param, pid_t bm_pid)
|
|
|
|
{
|
|
|
|
sleep(1);
|
|
|
|
return measure_llc_resctrl(param->filename, bm_pid);
|
|
|
|
}
|
|
|
|
|
2023-12-15 17:04:58 +02:00
|
|
|
static int show_results_info(unsigned long sum_llc_val, int no_of_bits,
|
|
|
|
unsigned long cache_span, unsigned long max_diff,
|
|
|
|
unsigned long max_diff_percent, unsigned long num_of_runs,
|
|
|
|
bool platform)
|
|
|
|
{
|
|
|
|
unsigned long avg_llc_val = 0;
|
|
|
|
float diff_percent;
|
|
|
|
long avg_diff = 0;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
avg_llc_val = sum_llc_val / num_of_runs;
|
2024-05-08 13:41:01 -07:00
|
|
|
avg_diff = (long)(cache_span - avg_llc_val);
|
2023-12-15 17:04:58 +02:00
|
|
|
diff_percent = ((float)cache_span - avg_llc_val) / cache_span * 100;
|
|
|
|
|
|
|
|
ret = platform && abs((int)diff_percent) > max_diff_percent &&
|
2024-05-08 13:41:01 -07:00
|
|
|
labs(avg_diff) > max_diff;
|
2023-12-15 17:04:58 +02:00
|
|
|
|
|
|
|
ksft_print_msg("%s Check cache miss rate within %lu%%\n",
|
|
|
|
ret ? "Fail:" : "Pass:", max_diff_percent);
|
|
|
|
|
|
|
|
ksft_print_msg("Percent diff=%d\n", abs((int)diff_percent));
|
|
|
|
|
|
|
|
show_cache_info(no_of_bits, avg_llc_val, cache_span, false);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2023-09-04 12:53:35 +03:00
|
|
|
static int check_results(struct resctrl_val_param *param, size_t span, int no_of_bits)
|
2020-01-16 13:32:41 -08:00
|
|
|
{
|
|
|
|
char *token_array[8], temp[512];
|
|
|
|
unsigned long sum_llc_occu_resc = 0;
|
|
|
|
int runs = 0;
|
|
|
|
FILE *fp;
|
|
|
|
|
2021-03-17 02:22:42 +00:00
|
|
|
ksft_print_msg("Checking for pass/fail\n");
|
2020-01-16 13:32:41 -08:00
|
|
|
fp = fopen(param->filename, "r");
|
|
|
|
if (!fp) {
|
2023-12-15 17:04:47 +02:00
|
|
|
ksft_perror("Error in opening file");
|
2020-01-16 13:32:41 -08:00
|
|
|
|
2023-12-15 17:04:48 +02:00
|
|
|
return -1;
|
2020-01-16 13:32:41 -08:00
|
|
|
}
|
|
|
|
|
selftests/resctrl: Enable gcc checks to detect buffer overflows
David reported a buffer overflow error in the check_results() function of
the cmt unit test and he suggested enabling _FORTIFY_SOURCE gcc compiler
option to automatically detect any such errors.
Feature Test Macros man page describes_FORTIFY_SOURCE as below
"Defining this macro causes some lightweight checks to be performed to
detect some buffer overflow errors when employing various string and memory
manipulation functions (for example, memcpy, memset, stpcpy, strcpy,
strncpy, strcat, strncat, sprintf, snprintf, vsprintf, vsnprintf, gets, and
wide character variants thereof). For some functions, argument consistency
is checked; for example, a check is made that open has been supplied with a
mode argument when the specified flags include O_CREAT. Not all problems
are detected, just some common cases.
If _FORTIFY_SOURCE is set to 1, with compiler optimization level 1 (gcc
-O1) and above, checks that shouldn't change the behavior of conforming
programs are performed.
With _FORTIFY_SOURCE set to 2, some more checking is added, but some
conforming programs might fail.
Some of the checks can be performed at compile time (via macros logic
implemented in header files), and result in compiler warnings; other checks
take place at run time, and result in a run-time error if the check fails.
Use of this macro requires compiler support, available with gcc since
version 4.0."
Fix the buffer overflow error in the check_results() function of the cmt
unit test and enable _FORTIFY_SOURCE gcc check to catch any future buffer
overflow errors.
Reported-by: David Binderman <dcb314@hotmail.com>
Suggested-by: David Binderman <dcb314@hotmail.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:35 +00:00
|
|
|
while (fgets(temp, sizeof(temp), fp)) {
|
2020-01-16 13:32:41 -08:00
|
|
|
char *token = strtok(temp, ":\t");
|
|
|
|
int fields = 0;
|
|
|
|
|
|
|
|
while (token) {
|
|
|
|
token_array[fields++] = token;
|
|
|
|
token = strtok(NULL, ":\t");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Field 3 is llc occ resc value */
|
2024-10-24 14:18:51 -07:00
|
|
|
sum_llc_occu_resc += strtoul(token_array[3], NULL, 0);
|
2020-01-16 13:32:41 -08:00
|
|
|
runs++;
|
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
|
2023-12-15 17:04:58 +02:00
|
|
|
return show_results_info(sum_llc_occu_resc, no_of_bits, span,
|
2024-10-24 14:18:51 -07:00
|
|
|
MAX_DIFF, MAX_DIFF_PERCENT, runs, true);
|
2020-01-16 13:32:41 -08:00
|
|
|
}
|
|
|
|
|
2024-02-27 08:21:43 +01:00
|
|
|
static void cmt_test_cleanup(void)
|
2020-01-16 13:32:41 -08:00
|
|
|
{
|
|
|
|
remove(RESULT_FILE_NAME);
|
|
|
|
}
|
|
|
|
|
2023-12-15 17:05:11 +02:00
|
|
|
static int cmt_run_test(const struct resctrl_test *test, const struct user_params *uparams)
|
2020-01-16 13:32:41 -08:00
|
|
|
{
|
selftests/resctrl: Make benchmark parameter passing robust
The benchmark used during the CMT, MBM, and MBA tests can be provided by
the user via (-b) parameter, if not provided the default "fill_buf"
benchmark is used. The user is additionally able to override
any of the "fill_buf" default parameters when running the tests with
"-b fill_buf <fill_buf parameters>".
The "fill_buf" parameters are managed as an array of strings. Using an
array of strings is complex because it requires transformations to/from
strings at every producer and consumer. This is made worse for the
individual tests where the default benchmark parameters values may not
be appropriate and additional data wrangling is required. For example,
the CMT test duplicates the entire array of strings in order to replace
one of the parameters.
More issues appear when combining the usage of an array of strings with
the use case of user overriding default parameters by specifying
"-b fill_buf <parameters>". This use case is fragile with opportunities
to trigger a SIGSEGV because of opportunities for NULL pointers to exist
in the array of strings. For example, by running below (thus by specifying
"fill_buf" should be used but all parameters are NULL):
$ sudo resctrl_tests -t mbm -b fill_buf
Replace the "array of strings" parameters used for "fill_buf" with
new struct fill_buf_param that contains the "fill_buf" parameters that
can be used directly without transformations to/from strings. Two
instances of struct fill_buf_param may exist at any point in time:
* If the user provides new parameters to "fill_buf", the
user parameter structure (struct user_params) will point to a
fully initialized and immutable struct fill_buf_param
containing the user provided parameters.
* If "fill_buf" is the benchmark that should be used by a test,
then the test parameter structure (struct resctrl_val_param)
will point to a fully initialized struct fill_buf_param. The
latter may contain (a) the user provided parameters verbatim,
(b) user provided parameters adjusted to be appropriate for
the test, or (c) the default parameters for "fill_buf" that
is appropriate for the test if the user did not provide
"fill_buf" parameters nor an alternate benchmark.
The existing behavior of CMT test is to use test defined value for the
buffer size even if the user provides another value via command line.
This behavior is maintained since the test requires that the buffer size
matches the size of the cache allocated, and the amount of cache
allocated can instead be changed by the user with the "-n" command line
parameter.
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-10-24 14:18:47 -07:00
|
|
|
struct fill_buf_param fill_buf = {};
|
2023-12-15 17:04:55 +02:00
|
|
|
unsigned long cache_total_size = 0;
|
2023-12-15 17:05:10 +02:00
|
|
|
int n = uparams->bits ? : 5;
|
2023-07-17 16:15:05 +03:00
|
|
|
unsigned long long_mask;
|
|
|
|
int count_of_bits;
|
2023-09-04 12:53:35 +03:00
|
|
|
size_t span;
|
selftests/resctrl: Make benchmark parameter passing robust
The benchmark used during the CMT, MBM, and MBA tests can be provided by
the user via (-b) parameter, if not provided the default "fill_buf"
benchmark is used. The user is additionally able to override
any of the "fill_buf" default parameters when running the tests with
"-b fill_buf <fill_buf parameters>".
The "fill_buf" parameters are managed as an array of strings. Using an
array of strings is complex because it requires transformations to/from
strings at every producer and consumer. This is made worse for the
individual tests where the default benchmark parameters values may not
be appropriate and additional data wrangling is required. For example,
the CMT test duplicates the entire array of strings in order to replace
one of the parameters.
More issues appear when combining the usage of an array of strings with
the use case of user overriding default parameters by specifying
"-b fill_buf <parameters>". This use case is fragile with opportunities
to trigger a SIGSEGV because of opportunities for NULL pointers to exist
in the array of strings. For example, by running below (thus by specifying
"fill_buf" should be used but all parameters are NULL):
$ sudo resctrl_tests -t mbm -b fill_buf
Replace the "array of strings" parameters used for "fill_buf" with
new struct fill_buf_param that contains the "fill_buf" parameters that
can be used directly without transformations to/from strings. Two
instances of struct fill_buf_param may exist at any point in time:
* If the user provides new parameters to "fill_buf", the
user parameter structure (struct user_params) will point to a
fully initialized and immutable struct fill_buf_param
containing the user provided parameters.
* If "fill_buf" is the benchmark that should be used by a test,
then the test parameter structure (struct resctrl_val_param)
will point to a fully initialized struct fill_buf_param. The
latter may contain (a) the user provided parameters verbatim,
(b) user provided parameters adjusted to be appropriate for
the test, or (c) the default parameters for "fill_buf" that
is appropriate for the test if the user did not provide
"fill_buf" parameters nor an alternate benchmark.
The existing behavior of CMT test is to use test defined value for the
buffer size even if the user provides another value via command line.
This behavior is maintained since the test requires that the buffer size
matches the size of the cache allocated, and the amount of cache
allocated can instead be changed by the user with the "-n" command line
parameter.
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-10-24 14:18:47 -07:00
|
|
|
int ret;
|
2020-01-16 13:32:41 -08:00
|
|
|
|
2023-12-15 17:04:53 +02:00
|
|
|
ret = get_full_cbm("L3", &long_mask);
|
2020-01-16 13:32:41 -08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2023-12-15 17:05:10 +02:00
|
|
|
ret = get_cache_size(uparams->cpu, "L3", &cache_total_size);
|
2020-01-16 13:32:41 -08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
2023-12-15 17:04:55 +02:00
|
|
|
ksft_print_msg("Cache size :%lu\n", cache_total_size);
|
2020-01-16 13:32:41 -08:00
|
|
|
|
|
|
|
count_of_bits = count_bits(long_mask);
|
|
|
|
|
|
|
|
if (n < 1 || n > count_of_bits) {
|
2021-03-17 02:22:42 +00:00
|
|
|
ksft_print_msg("Invalid input value for numbr_of_bits n!\n");
|
|
|
|
ksft_print_msg("Please enter value in range 1 to %d\n", count_of_bits);
|
2020-01-16 13:32:41 -08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct resctrl_val_param param = {
|
|
|
|
.ctrlgrp = "c1",
|
|
|
|
.filename = RESULT_FILE_NAME,
|
|
|
|
.mask = ~(long_mask << n) & long_mask,
|
|
|
|
.num_of_runs = 0,
|
2024-06-10 18:14:51 +03:00
|
|
|
.init = cmt_init,
|
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
|
|
|
.setup = cmt_setup,
|
2024-06-10 18:14:50 +03:00
|
|
|
.measure = cmt_measure,
|
2020-01-16 13:32:41 -08:00
|
|
|
};
|
|
|
|
|
2023-12-15 17:04:55 +02:00
|
|
|
span = cache_portion_size(cache_total_size, param.mask, long_mask);
|
2023-09-04 12:53:37 +03:00
|
|
|
|
selftests/resctrl: Make benchmark parameter passing robust
The benchmark used during the CMT, MBM, and MBA tests can be provided by
the user via (-b) parameter, if not provided the default "fill_buf"
benchmark is used. The user is additionally able to override
any of the "fill_buf" default parameters when running the tests with
"-b fill_buf <fill_buf parameters>".
The "fill_buf" parameters are managed as an array of strings. Using an
array of strings is complex because it requires transformations to/from
strings at every producer and consumer. This is made worse for the
individual tests where the default benchmark parameters values may not
be appropriate and additional data wrangling is required. For example,
the CMT test duplicates the entire array of strings in order to replace
one of the parameters.
More issues appear when combining the usage of an array of strings with
the use case of user overriding default parameters by specifying
"-b fill_buf <parameters>". This use case is fragile with opportunities
to trigger a SIGSEGV because of opportunities for NULL pointers to exist
in the array of strings. For example, by running below (thus by specifying
"fill_buf" should be used but all parameters are NULL):
$ sudo resctrl_tests -t mbm -b fill_buf
Replace the "array of strings" parameters used for "fill_buf" with
new struct fill_buf_param that contains the "fill_buf" parameters that
can be used directly without transformations to/from strings. Two
instances of struct fill_buf_param may exist at any point in time:
* If the user provides new parameters to "fill_buf", the
user parameter structure (struct user_params) will point to a
fully initialized and immutable struct fill_buf_param
containing the user provided parameters.
* If "fill_buf" is the benchmark that should be used by a test,
then the test parameter structure (struct resctrl_val_param)
will point to a fully initialized struct fill_buf_param. The
latter may contain (a) the user provided parameters verbatim,
(b) user provided parameters adjusted to be appropriate for
the test, or (c) the default parameters for "fill_buf" that
is appropriate for the test if the user did not provide
"fill_buf" parameters nor an alternate benchmark.
The existing behavior of CMT test is to use test defined value for the
buffer size even if the user provides another value via command line.
This behavior is maintained since the test requires that the buffer size
matches the size of the cache allocated, and the amount of cache
allocated can instead be changed by the user with the "-n" command line
parameter.
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-10-24 14:18:47 -07:00
|
|
|
if (uparams->fill_buf) {
|
|
|
|
fill_buf.buf_size = span;
|
|
|
|
fill_buf.memflush = uparams->fill_buf->memflush;
|
|
|
|
param.fill_buf = &fill_buf;
|
|
|
|
} else if (!uparams->benchmark_cmd[0]) {
|
|
|
|
fill_buf.buf_size = span;
|
|
|
|
fill_buf.memflush = true;
|
|
|
|
param.fill_buf = &fill_buf;
|
2023-09-04 12:53:37 +03:00
|
|
|
}
|
2020-01-16 13:32:41 -08:00
|
|
|
|
|
|
|
remove(RESULT_FILE_NAME);
|
|
|
|
|
selftests/resctrl: Make benchmark parameter passing robust
The benchmark used during the CMT, MBM, and MBA tests can be provided by
the user via (-b) parameter, if not provided the default "fill_buf"
benchmark is used. The user is additionally able to override
any of the "fill_buf" default parameters when running the tests with
"-b fill_buf <fill_buf parameters>".
The "fill_buf" parameters are managed as an array of strings. Using an
array of strings is complex because it requires transformations to/from
strings at every producer and consumer. This is made worse for the
individual tests where the default benchmark parameters values may not
be appropriate and additional data wrangling is required. For example,
the CMT test duplicates the entire array of strings in order to replace
one of the parameters.
More issues appear when combining the usage of an array of strings with
the use case of user overriding default parameters by specifying
"-b fill_buf <parameters>". This use case is fragile with opportunities
to trigger a SIGSEGV because of opportunities for NULL pointers to exist
in the array of strings. For example, by running below (thus by specifying
"fill_buf" should be used but all parameters are NULL):
$ sudo resctrl_tests -t mbm -b fill_buf
Replace the "array of strings" parameters used for "fill_buf" with
new struct fill_buf_param that contains the "fill_buf" parameters that
can be used directly without transformations to/from strings. Two
instances of struct fill_buf_param may exist at any point in time:
* If the user provides new parameters to "fill_buf", the
user parameter structure (struct user_params) will point to a
fully initialized and immutable struct fill_buf_param
containing the user provided parameters.
* If "fill_buf" is the benchmark that should be used by a test,
then the test parameter structure (struct resctrl_val_param)
will point to a fully initialized struct fill_buf_param. The
latter may contain (a) the user provided parameters verbatim,
(b) user provided parameters adjusted to be appropriate for
the test, or (c) the default parameters for "fill_buf" that
is appropriate for the test if the user did not provide
"fill_buf" parameters nor an alternate benchmark.
The existing behavior of CMT test is to use test defined value for the
buffer size even if the user provides another value via command line.
This behavior is maintained since the test requires that the buffer size
matches the size of the cache allocated, and the amount of cache
allocated can instead be changed by the user with the "-n" command line
parameter.
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-10-24 14:18:47 -07:00
|
|
|
ret = resctrl_val(test, uparams, ¶m);
|
2020-01-16 13:32:41 -08:00
|
|
|
if (ret)
|
selftests/resctrl: Make benchmark parameter passing robust
The benchmark used during the CMT, MBM, and MBA tests can be provided by
the user via (-b) parameter, if not provided the default "fill_buf"
benchmark is used. The user is additionally able to override
any of the "fill_buf" default parameters when running the tests with
"-b fill_buf <fill_buf parameters>".
The "fill_buf" parameters are managed as an array of strings. Using an
array of strings is complex because it requires transformations to/from
strings at every producer and consumer. This is made worse for the
individual tests where the default benchmark parameters values may not
be appropriate and additional data wrangling is required. For example,
the CMT test duplicates the entire array of strings in order to replace
one of the parameters.
More issues appear when combining the usage of an array of strings with
the use case of user overriding default parameters by specifying
"-b fill_buf <parameters>". This use case is fragile with opportunities
to trigger a SIGSEGV because of opportunities for NULL pointers to exist
in the array of strings. For example, by running below (thus by specifying
"fill_buf" should be used but all parameters are NULL):
$ sudo resctrl_tests -t mbm -b fill_buf
Replace the "array of strings" parameters used for "fill_buf" with
new struct fill_buf_param that contains the "fill_buf" parameters that
can be used directly without transformations to/from strings. Two
instances of struct fill_buf_param may exist at any point in time:
* If the user provides new parameters to "fill_buf", the
user parameter structure (struct user_params) will point to a
fully initialized and immutable struct fill_buf_param
containing the user provided parameters.
* If "fill_buf" is the benchmark that should be used by a test,
then the test parameter structure (struct resctrl_val_param)
will point to a fully initialized struct fill_buf_param. The
latter may contain (a) the user provided parameters verbatim,
(b) user provided parameters adjusted to be appropriate for
the test, or (c) the default parameters for "fill_buf" that
is appropriate for the test if the user did not provide
"fill_buf" parameters nor an alternate benchmark.
The existing behavior of CMT test is to use test defined value for the
buffer size even if the user provides another value via command line.
This behavior is maintained since the test requires that the buffer size
matches the size of the cache allocated, and the amount of cache
allocated can instead be changed by the user with the "-n" command line
parameter.
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2024-10-24 14:18:47 -07:00
|
|
|
return ret;
|
2020-01-16 13:32:41 -08:00
|
|
|
|
2023-09-04 12:53:35 +03:00
|
|
|
ret = check_results(¶m, span, n);
|
2024-12-16 16:18:54 +01:00
|
|
|
if (ret && (get_vendor() == ARCH_INTEL) && !snc_kernel_support())
|
|
|
|
ksft_print_msg("Kernel doesn't support Sub-NUMA Clustering but it is enabled on the system.\n");
|
2020-01-16 13:32:41 -08:00
|
|
|
|
2023-04-13 16:22:59 +09:00
|
|
|
return ret;
|
2020-01-16 13:32:41 -08:00
|
|
|
}
|
2023-12-15 17:05:11 +02:00
|
|
|
|
|
|
|
static bool cmt_feature_check(const struct resctrl_test *test)
|
|
|
|
{
|
|
|
|
return test_resource_feature_check(test) &&
|
2024-02-16 09:35:28 +01:00
|
|
|
resctrl_mon_feature_exists("L3_MON", "llc_occupancy");
|
2023-12-15 17:05:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
struct resctrl_test cmt_test = {
|
|
|
|
.name = "CMT",
|
|
|
|
.resource = "L3",
|
|
|
|
.feature_check = cmt_feature_check,
|
|
|
|
.run_test = cmt_run_test,
|
2024-02-27 08:21:41 +01:00
|
|
|
.cleanup = cmt_test_cleanup,
|
2023-12-15 17:05:11 +02:00
|
|
|
};
|