Skip to content

Commit f306913

Browse files
rchatreshuahkh
authored andcommitted
selftests/resctrl: Remove "once" parameter required to be false
The CMT, MBM, and MBA tests rely on a benchmark that runs while the test makes changes to needed configuration (for example memory bandwidth allocation) and takes needed measurements. By default the "fill_buf" benchmark is used and by default (via its "once = false" setting) "fill_buf" is configured to run until terminated after the test completes. An unintended consequence of enabling the user to override the benchmark also enables the user to change parameters to the "fill_buf" benchmark. This enables the user to set "fill_buf" to only cycle through the buffer once (by setting "once = true") and thus breaking the CMT, MBA, and MBM tests that expect workload/interference to be reflected by their measurements. Prevent user space from changing the "once" parameter and ensure that it is always false for the CMT, MBA, and MBM tests. Suggested-by: Ilpo Järvinen <[email protected]> Signed-off-by: Reinette Chatre <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent efffa8c commit f306913

File tree

4 files changed

+13
-16
lines changed

4 files changed

+13
-16
lines changed

tools/testing/selftests/resctrl/fill_buf.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ unsigned char *alloc_buffer(size_t buf_size, int memflush)
151151
return buf;
152152
}
153153

154-
int run_fill_buf(size_t buf_size, int memflush, int op, bool once)
154+
int run_fill_buf(size_t buf_size, int memflush, int op)
155155
{
156156
unsigned char *buf;
157157

@@ -160,9 +160,10 @@ int run_fill_buf(size_t buf_size, int memflush, int op, bool once)
160160
return -1;
161161

162162
if (op == 0)
163-
fill_cache_read(buf, buf_size, once);
163+
fill_cache_read(buf, buf_size, false);
164164
else
165-
fill_cache_write(buf, buf_size, once);
165+
fill_cache_write(buf, buf_size, false);
166+
166167
free(buf);
167168

168169
return 0;

tools/testing/selftests/resctrl/resctrl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu,
142142
unsigned char *alloc_buffer(size_t buf_size, int memflush);
143143
void mem_flush(unsigned char *buf, size_t buf_size);
144144
void fill_cache_read(unsigned char *buf, size_t buf_size, bool once);
145-
int run_fill_buf(size_t buf_size, int memflush, int op, bool once);
145+
int run_fill_buf(size_t buf_size, int memflush, int op);
146146
int initialize_mem_bw_imc(void);
147147
int measure_mem_bw(const struct user_params *uparams,
148148
struct resctrl_val_param *param, pid_t bm_pid,

tools/testing/selftests/resctrl/resctrl_tests.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,13 @@ int main(int argc, char **argv)
266266
uparams.benchmark_cmd[1] = span_str;
267267
uparams.benchmark_cmd[2] = "1";
268268
uparams.benchmark_cmd[3] = "0";
269-
uparams.benchmark_cmd[4] = "false";
270-
uparams.benchmark_cmd[5] = NULL;
269+
/*
270+
* Fourth parameter was previously used to indicate
271+
* how long "fill_buf" should run for, with "false"
272+
* ("fill_buf" will keep running until terminated)
273+
* the only option that works.
274+
*/
275+
uparams.benchmark_cmd[4] = NULL;
271276
}
272277

273278
ksft_set_plan(tests);

tools/testing/selftests/resctrl/resctrl_val.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,6 @@ static void run_benchmark(int signum, siginfo_t *info, void *ucontext)
625625
int operation, ret, memflush;
626626
char **benchmark_cmd;
627627
size_t span;
628-
bool once;
629628
FILE *fp;
630629

631630
benchmark_cmd = info->si_ptr;
@@ -645,16 +644,8 @@ static void run_benchmark(int signum, siginfo_t *info, void *ucontext)
645644
span = strtoul(benchmark_cmd[1], NULL, 10);
646645
memflush = atoi(benchmark_cmd[2]);
647646
operation = atoi(benchmark_cmd[3]);
648-
if (!strcmp(benchmark_cmd[4], "true")) {
649-
once = true;
650-
} else if (!strcmp(benchmark_cmd[4], "false")) {
651-
once = false;
652-
} else {
653-
ksft_print_msg("Invalid once parameter\n");
654-
parent_exit(ppid);
655-
}
656647

657-
if (run_fill_buf(span, memflush, operation, once))
648+
if (run_fill_buf(span, memflush, operation))
658649
fprintf(stderr, "Error in running fill buffer\n");
659650
} else {
660651
/* Execute specified benchmark */

0 commit comments

Comments
 (0)