Skip to content

Commit ba66932

Browse files
rchatregregkh
authored andcommitted
selftests/resctrl: Print accurate buffer size as part of MBM results
[ Upstream commit 1b48403 ] By default the MBM test uses the "fill_buf" benchmark to keep reading from a buffer with size DEFAULT_SPAN while measuring memory bandwidth. User space can provide an alternate benchmark or amend the size of the buffer "fill_buf" should use. Analysis of the MBM measurements do not require that a buffer be used and thus do not require knowing the size of the buffer if it was used during testing. Even so, the buffer size is printed as informational as part of the MBM test results. What is printed as buffer size is hardcoded as DEFAULT_SPAN, even if the test relied on another benchmark (that may or may not use a buffer) or if user space amended the buffer size. Ensure that accurate buffer size is printed when using "fill_buf" benchmark and omit the buffer size information if another benchmark is used. Fixes: ecdbb91 ("selftests/resctrl: Add MBM test") 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 3231a76 commit ba66932

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

tools/testing/selftests/resctrl/mbm_test.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ show_bw_info(unsigned long *bw_imc, unsigned long *bw_resc, size_t span)
4040
ksft_print_msg("%s Check MBM diff within %d%%\n",
4141
ret ? "Fail:" : "Pass:", MAX_DIFF_PERCENT);
4242
ksft_print_msg("avg_diff_per: %d%%\n", avg_diff_per);
43-
ksft_print_msg("Span (MB): %zu\n", span / MB);
43+
if (span)
44+
ksft_print_msg("Span (MB): %zu\n", span / MB);
4445
ksft_print_msg("avg_bw_imc: %lu\n", avg_bw_imc);
4546
ksft_print_msg("avg_bw_resc: %lu\n", avg_bw_resc);
4647

@@ -138,15 +139,26 @@ static int mbm_run_test(const struct resctrl_test *test, const struct user_param
138139
.setup = mbm_setup,
139140
.measure = mbm_measure,
140141
};
142+
char *endptr = NULL;
143+
size_t span = 0;
141144
int ret;
142145

143146
remove(RESULT_FILE_NAME);
144147

148+
if (uparams->benchmark_cmd[0] && strcmp(uparams->benchmark_cmd[0], "fill_buf") == 0) {
149+
if (uparams->benchmark_cmd[1] && *uparams->benchmark_cmd[1] != '\0') {
150+
errno = 0;
151+
span = strtoul(uparams->benchmark_cmd[1], &endptr, 10);
152+
if (errno || *endptr != '\0')
153+
return -EINVAL;
154+
}
155+
}
156+
145157
ret = resctrl_val(test, uparams, uparams->benchmark_cmd, &param);
146158
if (ret)
147159
return ret;
148160

149-
ret = check_results(DEFAULT_SPAN);
161+
ret = check_results(span);
150162
if (ret && (get_vendor() == ARCH_INTEL))
151163
ksft_print_msg("Intel MBM may be inaccurate when Sub-NUMA Clustering is enabled. Check BIOS configuration.\n");
152164

0 commit comments

Comments
 (0)