selftests/resctrl: Small cleanups
Subsystems (2)
cover selftests/resctrl: Small cleanups
Fenghua Yu (1):
selftests/resctrl: Don't hard code divisor in MBM results
Ilpo Järvinen (2):
selftests/resctrl: Change initialize_llc_perf() return type to void selftests/resctrl: Use remount_resctrlfs() consistently with boolean
Signed-off-by: Fenghua Yu (1):
selftests/resctrl: Change name from CBM_MASK_PATH to INFO_PATH
tools/testing/selftests/resctrl/cache.c | 11 +++-------- tools/testing/selftests/resctrl/cat_test.c | 2 +- tools/testing/selftests/resctrl/cmt_test.c | 7 +++---- tools/testing/selftests/resctrl/mba_test.c | 2 +- tools/testing/selftests/resctrl/mbm_test.c | 6 +++--- tools/testing/selftests/resctrl/resctrl.h | 4 ++-- tools/testing/selftests/resctrl/resctrlfs.c | 2 +- 7 files changed, 14 insertions(+), 20 deletions(-)
Signature · 1 line
2.30.2
PATCH 1/4 selftests/resctrl: Change initialize_llc_perf() return type to void
initialize_llc_perf() unconditionally does return 0 so no point in having it's return type as int. Hence, change it's return type from int to void.
--- tools/testing/selftests/resctrl/cache.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
tools/testing/selftests/resctrl/cache.c +3 -8
@@ -48,7 +48,7 @@ static int perf_event_open_llc_miss(pid_t pid, int cpu_no)return 0 ; } -static int initialize_llc_perf (void ) +static void initialize_llc_perf (void ) {memset (&pea_llc_miss,0 ,sizeof (struct perf_event_attr ));memset (&rf_cqm,0 ,sizeof (struct read_format ));
@@ -59,8 +59,6 @@ static int initialize_llc_perf(void) pea_llc_miss.config =PERF_COUNT_HW_CACHE_MISSES ; rf_cqm.nr =1 ; - -return 0 ; }static int reset_enable_llc_perf (pid_t pid,int cpu_no)
@@ -234,11 +232,8 @@ int cat_val(struct resctrl_val_param *param)if (ret)return ret; -if (!strncmp (resctrl_val,CAT_STR ,sizeof (CAT_STR ))) { - ret =initialize_llc_perf (); -if (ret) -return ret; - } +if (!strncmp (resctrl_val,CAT_STR ,sizeof (CAT_STR ))) +initialize_llc_perf ();/* Test runs until the callback setup() tells the test to stop. */ while (1 ) {
Signature · 1 line
2.30.2
Reinette Chatre
maintainerRe: [PATCH 1/4] selftests/resctrl: Change initialize_llc_perf() return type to void
Hi Ilpo,
Quoted 4 lines · Ilpo Järvinen
initialize_llc_perf()unconditionally does return 0 so no point in having it's return type as int. Hence, change it's return type from int to void.
Thank you very much for contributing to resctrl. As a new resctrl contributor I would like to share that resctrl follows the x86 style guidance and to be consistent this is for the most part true for the resctrl selftest area.
To that point, changelogs are easier to read if the context, problem, and solution are clearly separated by placing them in separate paragraphs. See "Changelog" in
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/maintainer-tip.rst
Please compare to a changelog as follows:
"initialize_llc_perf() unconditionally returns 0.
initialize_llc_perf() performs memory initialization, none of which can fail.
Change the return type from int to void to accurately reflect that there is no checking of return value needed. "
For such a small change as this, the changelog could possibly be simplified but the context, problem, and solution should always be clear to the reader. This may be significant changelog feedback for such a small change. This is because it is your first patch to this area and my goal is to point out the style that will help your future resctrl contributions to have the pattern that x86 maintainers expect.
Reinette
PATCH 2/4 selftests/resctrl: Don't hard code divisor in MBM results
In reply to Ilpo JärvinenFrom: Fenghua Yu <[email protected]>
Presently, while calculating MBM results, the divisor is hard coded as 4. It's hard coded to 4 because "NUM_OF_RUNS" is defined as 5 and the test does not count first result and hence 4. So, instead of hard coding the value to 4, change it to NUM_OF_RUNS - 1.
--- tools/testing/selftests/resctrl/mbm_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/resctrl/mbm_test.c +2 -2
@@ -31,8 +31,8 @@ show_bw_info(unsigned long *bw_imc, unsigned long *bw_resc, int span) sum_bw_resc += bw_resc[runs]; } - avg_bw_imc = sum_bw_imc /4 ; - avg_bw_resc = sum_bw_resc /4 ; + avg_bw_imc = sum_bw_imc / (NUM_OF_RUNS -1 ); + avg_bw_resc = sum_bw_resc / (NUM_OF_RUNS -1 ); avg_diff = (float )labs (avg_bw_resc - avg_bw_imc) / avg_bw_imc; avg_diff_per = (int )(avg_diff *100 );
Signature · 1 line
2.30.2
Reinette Chatre
maintainerRe: [PATCH 2/4] selftests/resctrl: Don't hard code divisor in MBM results
Hi Ilpo,
The subject is "Don't hard code divisor ..." yet it seems to me that the hard coding persists. It is just changed from a magic constant to a macro.
Quoted 3 lines · Ilpo Järvinen
From: Fenghua Yu <[email protected]>
Presently, while calculating MBM results, the divisor is hard coded as 4.
"Presently" can be removed. Here and in the rest of the series the usage of "presently" and "currently" can usually be removed to improve clarity.
Quoted 3 lines
It's hard coded to 4 because "
NUM_OF_RUNS" is defined as 5 and the test does not count first result and hence 4. So, instead of hard coding the value to 4, change it toNUM_OF_RUNS- 1.
Are there any plans surrounding using struct resctrl_val_param::num_of_runs instead?
Quoted 2 lines
Signed-off-by Fenghua Yu <[email protected]>
Missing your Signed-off-by?
Quoted 9 lines
--- tools/testing/selftests/resctrl/mbm_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/testing/selftests/resctrl/mbm_test.c +0
-0
tools/testing/selftests/resctrl/mbm_test.c show_bw_info(unsigned long *bw_imc, unsigned long *bw_resc, int span) · line 38
Quoted 10 lines
tools/testing/selftests/resctrl/mbm_test.c +2
-2@@ -31,8 +31,8 @@ show_bw_info(unsigned long *bw_imc, unsigned long *bw_resc, int span) sum_bw_resc += bw_resc[runs]; } - avg_bw_imc = sum_bw_imc /4 ; - avg_bw_resc = sum_bw_resc /4 ; + avg_bw_imc = sum_bw_imc / (NUM_OF_RUNS -1 ); + avg_bw_resc = sum_bw_resc / (NUM_OF_RUNS -1 ); avg_diff = (float )labs (avg_bw_resc - avg_bw_imc) / avg_bw_imc; avg_diff_per = (int )(avg_diff *100 );
Reinette
Re: [PATCH 2/4] selftests/resctrl: Don't hard code divisor in MBM results
Quoted 5 lines · Reinette Chatre
Hi Ilpo,
The subject is "Don't hard code divisor ..." yet it seems to me that the hard coding persists. It is just changed from a magic constant to a macro.
Yeah, it was a bad wording.
Quoted 8 lines · Ilpo Järvinen
Quoted 3 lines
From: Fenghua Yu <[email protected]>
Presently, while calculating MBM results, the divisor is hard coded as 4.
"Presently" can be removed. Here and in the rest of the series the usage of "presently" and "currently" can usually be removed to improve clarity.
Quoted 6 lines
Quoted 3 lines
It's hard coded to 4 because "
NUM_OF_RUNS" is defined as 5 and the test does not count first result and hence 4. So, instead of hard coding the value to 4, change it toNUM_OF_RUNS- 1.Are there any plans surrounding using struct
resctrl_val_param::num_of_runsinstead?
Actually no.
What I'd want to do is that the functions which call these result calculator functions would specify the number of tests they passed into the result calculator. It seems safer because the results are read back from a file which could have changed (or got deleted due to an ipc bug prematurely cleaning up the file) and would better take account those cases where the first value is skipped when reading the results.
I think I'll drop this patch for now.
Signature · 1 line
i.
Reinette Chatre
maintainerRe: [PATCH 2/4] selftests/resctrl: Don't hard code divisor in MBM results
Hi Ilpo,
Quoted 13 lines · Ilpo Järvinen
Quoted 12 lines · Reinette Chatre
Quoted 3 lines · Ilpo Järvinen
From: Fenghua Yu <[email protected]>
Presently, while calculating MBM results, the divisor is hard coded as 4.
"Presently" can be removed. Here and in the rest of the series the usage of "presently" and "currently" can usually be removed to improve clarity.
Quoted 3 lines
It's hard coded to 4 because "
NUM_OF_RUNS" is defined as 5 and the test does not count first result and hence 4. So, instead of hard coding the value to 4, change it toNUM_OF_RUNS- 1.
Quoted 8 lines
Quoted 2 lines
Are there any plans surrounding using struct
resctrl_val_param::num_of_runsinstead?Actually no.
What I'd want to do is that the functions which call these result calculator functions would specify the number of tests they passed into the result calculator. It seems safer because the results are read
Would it not simplify things to pass the test parameters (struct resctrl_val_param) to the result calculator? That contains the number of tests run and would reign in the hard coding.
Quoted 4 lines
back from a file which could have changed (or got deleted due to an ipc bug prematurely cleaning up the file) and would better take account those cases where the first value is skipped when reading the results.
This sounds good. Thank you.
Reinette
PATCH 3/4 selftests/resctrl: Change name from CBM_MASK_PATH to INFO_PATH
In reply to Ilpo JärvinenFrom: "Signed-off-by: Fenghua Yu" <[email protected]>
CBM_MASK_PATH is actually the path to resctrl/info, so change the macro name to correctly indicate what it represents.
--- tools/testing/selftests/resctrl/resctrl.h | 2 +- tools/testing/selftests/resctrl/resctrlfs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/resctrl/resctrl.h +1 -1
@@ -28,7 +28,7 @@#define MB (1024 * 1024)#define RESCTRL_PATH "/sys/fs/resctrl"#define PHYS_ID_PATH "/sys/devices/system/cpu/cpu" -#define CBM_MASK_PATH "/sys/fs/resctrl/info" +#define INFO_PATH "/sys/fs/resctrl/info"#define L3_PATH "/sys/fs/resctrl/info/L3"#define MB_PATH "/sys/fs/resctrl/info/MB"#define L3_MON_PATH "/sys/fs/resctrl/info/L3_MON"
tools/testing/selftests/resctrl/resctrlfs.c +1 -1
@@ -210,7 +210,7 @@ int get_cbm_mask(char *cache_type, char *cbm_mask)if (!cbm_mask)return -1 ; -sprintf (cbm_mask_path,"%s/%s/cbm_mask" ,CBM_MASK_PATH , cache_type); +sprintf (cbm_mask_path,"%s/%s/cbm_mask" ,INFO_PATH , cache_type); fp =fopen (cbm_mask_path,"r" );if (!fp) {
Signature · 1 line
2.30.2
Re: [PATCH 3/4] selftests/resctrl: Change name from CBM_MASK_PATH to INFO_PATH
Quoted 1 line · Ilpo Järvinen
From: "Signed-off-by: Fenghua Yu" <[email protected]>
I seem to have managed to do a little copy paste error there. I can resubmit the series if needed.
Signature · 1 line
i.
Quoted 36 lines
CBM_MASK_PATHis actually the path to resctrl/info, so change the macro name to correctly indicate what it represents.Signed-off-by Fenghua Yu <[email protected]>--- tools/testing/selftests/resctrl/resctrl.h | 2 +- tools/testing/selftests/resctrl/resctrlfs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)tools/testing/selftests/resctrl/resctrl.h +1
-1@@ -28,7 +28,7 @@#define MB (1024 * 1024)#define RESCTRL_PATH "/sys/fs/resctrl"#define PHYS_ID_PATH "/sys/devices/system/cpu/cpu" -#define CBM_MASK_PATH "/sys/fs/resctrl/info" +#define INFO_PATH "/sys/fs/resctrl/info"#define L3_PATH "/sys/fs/resctrl/info/L3"#define MB_PATH "/sys/fs/resctrl/info/MB"#define L3_MON_PATH "/sys/fs/resctrl/info/L3_MON"tools/testing/selftests/resctrl/resctrlfs.c +1
-1@@ -210,7 +210,7 @@ int get_cbm_mask(char *cache_type, char *cbm_mask)if (!cbm_mask)return -1 ; -sprintf (cbm_mask_path,"%s/%s/cbm_mask" ,CBM_MASK_PATH , cache_type); +sprintf (cbm_mask_path,"%s/%s/cbm_mask" ,INFO_PATH , cache_type); fp =fopen (cbm_mask_path,"r" );if (!fp) {
Reinette Chatre
maintainerRe: [PATCH 3/4] selftests/resctrl: Change name from CBM_MASK_PATH to INFO_PATH
Hi Ilpo,
Quoted 5 lines · Ilpo Järvinen
Quoted 1 line · Ilpo Järvinen
From: "Signed-off-by: Fenghua Yu" <[email protected]>
I seem to have managed to do a little copy paste error there. I can resubmit the series if needed.
Yes please.
Quoted 6 lines
-- i.
Quoted 4 lines
CBM_MASK_PATHis actually the path to resctrl/info, so change the macro name to correctly indicate what it represents.Signed-off-by Fenghua Yu <[email protected]>
Missing your Signed-off-by?
Reinette
PATCH 4/4 selftests/resctrl: Use remount_resctrlfs() consistently with boolean
In reply to Ilpo Järvinenremount_resctrlfs() accepts a boolean value as an argument and presently, some tests pass 0/1 and some tests pass true/false. Make all the callers of remount_resctrlfs() use true/false so that it's usage is consistent across tests.
--- tools/testing/selftests/resctrl/cat_test.c | 2 +- tools/testing/selftests/resctrl/cmt_test.c | 7 +++---- tools/testing/selftests/resctrl/mba_test.c | 2 +- tools/testing/selftests/resctrl/mbm_test.c | 2 +- tools/testing/selftests/resctrl/resctrl.h | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-)
tools/testing/selftests/resctrl/cat_test.c +1 -1
@@ -145,7 +145,7 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type)struct resctrl_val_param param = { .resctrl_val =CAT_STR , .cpu_no = cpu_no, - .mum_resctrlfs =0 , + .mum_resctrlfs = false, .setup = cat_setup, };
tools/testing/selftests/resctrl/cmt_test.c +3 -4
@@ -82,12 +82,11 @@ void cmt_test_cleanup(void)int cmt_resctrl_val (int cpu_no,int n,char **benchmark_cmd) { -int ret, mum_resctrlfs; +int ret; cache_size =0 ; - mum_resctrlfs =1 ; - ret =remount_resctrlfs (mum_resctrlfs); + ret =remount_resctrlfs (true);if (ret)return ret;
@@ -118,7 +117,7 @@ int cmt_resctrl_val(int cpu_no, int n, char **benchmark_cmd) .ctrlgrp = "c1", .mongrp = "m1", .cpu_no = cpu_no, - .mum_resctrlfs = 0, + .mum_resctrlfs = false, .filename = RESULT_FILE_NAME, .mask = ~(long_mask << n) & long_mask, .span = cache_size * n / count_of_bits,
tools/testing/selftests/resctrl/mba_test.c +1 -1
@@ -149,7 +149,7 @@ int mba_schemata_change(int cpu_no, char *bw_report, char **benchmark_cmd) .ctrlgrp = "c1", .mongrp = "m1", .cpu_no = cpu_no, - .mum_resctrlfs = 1, + .mum_resctrlfs = true, .filename = RESULT_FILE_NAME, .bw_report = bw_report, .setup = mba_setup
tools/testing/selftests/resctrl/mbm_test.c +1 -1
@@ -122,7 +122,7 @@ int mbm_bw_change(int span, int cpu_no, char *bw_report, char **benchmark_cmd) .mongrp = "m1", .span = span, .cpu_no = cpu_no, - .mum_resctrlfs = 1, + .mum_resctrlfs = true, .filename = RESULT_FILE_NAME, .bw_report = bw_report, .setup = mbm_setup
tools/testing/selftests/resctrl/resctrl.h +1 -1
@@ -62,7 +62,7 @@ struct resctrl_val_param {char mongrp[64 ];int cpu_no;unsigned long span; -int mum_resctrlfs; +bool mum_resctrlfs;char filename[64 ];char *bw_report;unsigned long mask;
Signature · 1 line
2.30.2