diff mbox series

[v2,06/24] selftests/resctrl: Express span in bytes

Message ID 20230418114506.46788-7-ilpo.jarvinen@linux.intel.com
State New
Headers show
Series selftests/resctrl: Fixes, cleanups, and rewritten CAT test | expand

Commit Message

Ilpo Järvinen April 18, 2023, 11:44 a.m. UTC
Make MBA and MBM tests to use megabytes to represent span. CMT test
uses bytes.

Convert MBA and MBM tests to use bytes like CMT test to remove the
inconsistency between the tests. This also allows removing test
dependent buffer sizing from run_benchmark().

Co-developed-by: Fenghua Yu <fenghua.yu@intel.com>
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 tools/testing/selftests/resctrl/mbm_test.c      | 2 +-
 tools/testing/selftests/resctrl/resctrl_tests.c | 2 +-
 tools/testing/selftests/resctrl/resctrlfs.c     | 9 ++-------
 3 files changed, 4 insertions(+), 9 deletions(-)

Comments

Reinette Chatre April 22, 2023, 12:12 a.m. UTC | #1
Hi Ilpo,

On 4/18/2023 4:44 AM, Ilpo Järvinen wrote:
> Make MBA and MBM tests to use megabytes to represent span. CMT test
> uses bytes.
> 
> Convert MBA and MBM tests to use bytes like CMT test to remove the
> inconsistency between the tests. This also allows removing test
> dependent buffer sizing from run_benchmark().

It is not clear to me how this patch achieves this goal since after
it show_mba_info() still displays results in MB.

Reinette
Ilpo Järvinen April 24, 2023, 3:31 p.m. UTC | #2
On Fri, 21 Apr 2023, Reinette Chatre wrote:
> On 4/18/2023 4:44 AM, Ilpo Järvinen wrote:
> > Make MBA and MBM tests to use megabytes to represent span. CMT test
> > uses bytes.
> > 
> > Convert MBA and MBM tests to use bytes like CMT test to remove the
> > inconsistency between the tests. This also allows removing test
> > dependent buffer sizing from run_benchmark().
> 
> It is not clear to me how this patch achieves this goal since after
> it show_mba_info() still displays results in MB.

This was more for internal consistency as there was the test type 
dependent span calculation in run_benchmark(). I can fix the changelog to 
reflect that, however, what you think would be the best approach in 
show_bw_info(), should I leave the print to use MB (converting the 
internal representation back from bytes to MB there)?
diff mbox series

Patch

diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c
index 3c389ccfea41..ea2ea5721e76 100644
--- a/tools/testing/selftests/resctrl/mbm_test.c
+++ b/tools/testing/selftests/resctrl/mbm_test.c
@@ -40,7 +40,7 @@  show_bw_info(unsigned long *bw_imc, unsigned long *bw_resc, unsigned long span)
 	ksft_print_msg("%s Check MBM diff within %d%%\n",
 		       ret ? "Fail:" : "Pass:", MAX_DIFF_PERCENT);
 	ksft_print_msg("avg_diff_per: %d%%\n", avg_diff_per);
-	ksft_print_msg("Span (MB): %lu\n", span);
+	ksft_print_msg("Span in bytes: %lu\n", span);
 	ksft_print_msg("avg_bw_imc: %lu\n", avg_bw_imc);
 	ksft_print_msg("avg_bw_resc: %lu\n", avg_bw_resc);
 
diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c
index 6bc0eda25e5d..f1ed2c89f228 100644
--- a/tools/testing/selftests/resctrl/resctrl_tests.c
+++ b/tools/testing/selftests/resctrl/resctrl_tests.c
@@ -185,7 +185,7 @@  int main(int argc, char **argv)
 	char *benchmark_cmd[BENCHMARK_ARGS], bw_report[64], bm_type[64];
 	char benchmark_cmd_area[BENCHMARK_ARGS][BENCHMARK_ARG_SIZE];
 	int c, cpu_no = 1, argc_new = argc, i, no_of_bits = 0;
-	unsigned long span = 250;
+	unsigned long span = 250 * MB;
 	int ben_ind, ben_count, tests = 0;
 	bool cat_test = true;
 
diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c
index 45f785213143..09e0a69c81c4 100644
--- a/tools/testing/selftests/resctrl/resctrlfs.c
+++ b/tools/testing/selftests/resctrl/resctrlfs.c
@@ -296,7 +296,7 @@  int taskset_benchmark(pid_t bm_pid, int cpu_no)
 void run_benchmark(int signum, siginfo_t *info, void *ucontext)
 {
 	int operation, ret, malloc_and_init_memory, memflush;
-	unsigned long span, buffer_span;
+	unsigned long span;
 	char **benchmark_cmd;
 	char resctrl_val[64];
 	FILE *fp;
@@ -319,12 +319,7 @@  void run_benchmark(int signum, siginfo_t *info, void *ucontext)
 		operation = atoi(benchmark_cmd[4]);
 		sprintf(resctrl_val, "%s", benchmark_cmd[5]);
 
-		if (strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR)))
-			buffer_span = span * MB;
-		else
-			buffer_span = span;
-
-		if (run_fill_buf(buffer_span, malloc_and_init_memory, memflush,
+		if (run_fill_buf(span, malloc_and_init_memory, memflush,
 				 operation, resctrl_val))
 			fprintf(stderr, "Error in running fill buffer\n");
 	} else {