selftests/resctrl: resctrl_val() related cleanups & improvements
Subsystems (2)
v3 cover selftests/resctrl: resctrl_val() related cleanups & improvements
Hi all,
This series does a number of cleanups into resctrl_val() and generalizes it by removing test name specific handling from the function.
One of the changes improves MBA/MBM measurement by narrowing down the period the resctrl FS derived memory bandwidth numbers are measured over. My feel is it didn't cause noticeable difference into the numbers because they're generally good anyway except for the small number of outliers. To see the impact on outliers, I'd need to setup a test to run large number of replications and do a statistical analysis, which I've not spent my time on. Even without the statistical analysis, the new way to measure seems obviously better and makes sense even if I cannot see a major improvement with the setup I'm using.
This series has some conflicts with SNC series from Maciej (Maciej has privately agreed to base his series on top of this series) and also with the MBA/MBM series from Babu.
--
i.
v3:
- Rename init functions to <testname>_init()
- Replace for loops with READ+WRITE statements for clarity
- Don't drop Return: entry from perf_open_imc_mem_bw() func comment
- New patch: Fix closing of IMC fds in case of error
- New patch: Make "bandwidth" consistent in comments & prints
- New patch: Simplify mem bandwidth file code
- Remove wrong comment
- Changed grp_name check to return -1 on fail (internal sanity check)
v2:
- Resolved conflicts with kselftest/next
- Spaces -> tabs correction
Ilpo Järvinen (16):
selftests/resctrl: Open get_mem_bw_imc() fd for loops selftests/resctrl: Calculate resctrl FS derived mem bw over sleep(1)
only
selftests/resctrl: Fix closing IMC fds on error selftests/resctrl: Make "bandwidth" consistent in comments & prints selftests/resctrl: Consolidate get_domain_id() into resctrl_val() selftests/resctrl: Use correct type for pids selftests/resctrl: Cleanup bm_pid and ppid usage & limit scope selftests/resctrl: Rename measure_vals() to measure_mem_bw_vals() &
document
selftests/resctrl: Simplify mem bandwidth file code for MBA & MBM
tests
selftests/resctrl: Add ->measure() callback to resctrl_val_param selftests/resctrl: Add ->init() callback into resctrl_val_param selftests/resctrl: Simplify bandwidth report type handling selftests/resctrl: Make some strings passed to resctrlfs functions
const
selftests/resctrl: Convert ctrlgrp & mongrp to pointers selftests/resctrl: Remove mongrp from MBA test selftests/resctrl: Remove test name comparing from
write_bm_pid_to_resctrl()
tools/testing/selftests/resctrl/cache.c | 6 +- tools/testing/selftests/resctrl/cat_test.c | 5 +- tools/testing/selftests/resctrl/cmt_test.c | 21 +- tools/testing/selftests/resctrl/mba_test.c | 26 +- tools/testing/selftests/resctrl/mbm_test.c | 25 +- tools/testing/selftests/resctrl/resctrl.h | 49 ++- tools/testing/selftests/resctrl/resctrl_val.c | 295 +++++++----------- tools/testing/selftests/resctrl/resctrlfs.c | 64 ++-- 8 files changed, 238 insertions(+), 253 deletions(-)
Signature · 1 line
2.39.2
PATCH v3 1/16 selftests/resctrl: Open get_mem_bw_imc() fd for loops
get_mem_bw_imc() handles fds in a for loop but close() is based on two fixed indexes READ and WRITE.
Open code all for loops to READ+WRITE entries for clarity.
---
v3:
- Rework entirely, use open coding instead of for loops for clarity
--- tools/testing/selftests/resctrl/resctrl_val.c | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-)
tools/testing/selftests/resctrl/resctrl_val.c +12 -10
@@ -306,26 +306,28 @@ static int initialize_mem_bw_imc(void)static int get_mem_bw_imc (int cpu_no,char *bw_report,float *bw_imc) {float reads, writes, of_mul_read, of_mul_write; -int imc, j, ret; +int imc, ret;/* Start all iMC counters to log values (both read and write) */ reads =0 , writes =0 , of_mul_read =1 , of_mul_write =1 ;for (imc =0 ; imc < imcs; imc++) { -for (j =0 ; j <2 ; j++) { - ret =open_perf_event (imc, cpu_no, j); -if (ret) -return -1 ; - } -for (j =0 ; j <2 ; j++) -membw_ioctl_perf_event_ioc_reset_enable (imc, j); + ret =open_perf_event (imc, cpu_no,READ ); +if (ret) +return -1 ; + ret =open_perf_event (imc, cpu_no,WRITE ); +if (ret) +return -1 ; + +membw_ioctl_perf_event_ioc_reset_enable (imc,READ ); +membw_ioctl_perf_event_ioc_reset_enable (imc,WRITE ); }sleep (1 );/* Stop counters after a second to get results (both read and write) */ for (imc =0 ; imc < imcs; imc++) { -for (j =0 ; j <2 ; j++) -membw_ioctl_perf_event_ioc_disable (imc, j); +membw_ioctl_perf_event_ioc_disable (imc,READ ); +membw_ioctl_perf_event_ioc_disable (imc,WRITE ); }/*
Signature · 1 line
2.39.2
Reinette Chatre
maintainerRe: [PATCH v3 01/16] selftests/resctrl: Open get_mem_bw_imc() fd for loops
Hi Ilpo,
Quoted 36 lines · Ilpo Järvinen
get_mem_bw_imc()handles fds in a for loop butclose()is based on two fixed indexes READ and WRITE.Open code all for loops to READ+WRITE entries for clarity.
Suggested-by Reinette Chatre <[email protected]>Signed-off-by Ilpo Järvinen <[email protected]>---
v3:
- Rework entirely, use open coding instead of for loops for clarity--- tools/testing/selftests/resctrl/resctrl_val.c | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-)tools/testing/selftests/resctrl/resctrl_val.c +1
-8@@ -306,26 +306,28 @@ static int initialize_mem_bw_imc(void)static int get_mem_bw_imc (int cpu_no,char *bw_report,float *bw_imc) {float reads, writes, of_mul_read, of_mul_write; -int imc, j, ret; +int imc, ret;/* Start all iMC counters to log values (both read and write) */ reads =0 , writes =0 , of_mul_read =1 , of_mul_write =1 ;for (imc =0 ; imc < imcs; imc++) { -for (j =0 ; j <2 ; j++) { - ret =open_perf_event (imc, cpu_no, j); -if (ret) -return -1 ; - } -for (j =0 ; j <2 ; j++) -membw_ioctl_perf_event_ioc_reset_enable (imc, j);
tools/testing/selftests/resctrl/resctrl_val.c static int initialize_mem_bw_imc(void) · line 323
Quoted 10 lines
tools/testing/selftests/resctrl/resctrl_val.c +9
-0+ ret =open_perf_event (imc, cpu_no,READ ); +if (ret) +return -1 ; + ret =open_perf_event (imc, cpu_no,WRITE ); +if (ret) +return -1 ; + +membw_ioctl_perf_event_ioc_reset_enable (imc,READ ); +membw_ioctl_perf_event_ioc_reset_enable (imc,WRITE ); }
The above highlights how the error checking is broken here and
leaving this code like this until the later fix arrives is confusing (to me). Could you please squash "selftests/resctrl: Fix closing IMC fds on error" into this patch?
Even so, I do not think that this addresses all the issues with error handling surrounding these fds.
If I understand correctly these fds are currently (and remains to be after this series) closed within get_mem_bw_imc(). In this series there seems to be many occasions where open_perf_event() succeeds but later failures encountered before get_mem_bw_imc() results in these fds not being cleaned up. What do you think of having a perf_close_imc_mem_bw() to match with perf_open_imc_mem_bw() that closes the fds and can be called from within get_mem_bw_imc() as well as earlier if a failure is encountered between perf_open_imc_mem_bw()
and get_mem_bw_imc()?
Reinette
PATCH v3 2/16 selftests/resctrl: Calculate resctrl FS derived mem bw over sleep(1) only
In reply to Ilpo JärvinenFor MBM/MBA tests, measure_vals() calls get_mem_bw_imc() that performs the measurement over a duration of sleep(1) call. The memory bandwidth numbers from IMC are derived over this duration. The resctrl FS derived memory bandwidth, however, is calculated inside measure_vals() and only takes delta between the previous value and the current one which besides the actual test, also samples inter-test noise.
Rework the logic in measure_vals() and get_mem_bw_imc() such that the resctrl FS memory bandwidth section covers much shorter duration closely matching that of the IMC perf counters to improve measurement accuracy.
---
v3:
- Don't drop Return: entry from perf_open_imc_mem_bw() func comment
--- tools/testing/selftests/resctrl/resctrl_val.c | 71 +++++++++++++------ 1 file changed, 50 insertions(+), 21 deletions(-)
tools/testing/selftests/resctrl/resctrl_val.c +50 -21
@@ -294,22 +294,15 @@ static int initialize_mem_bw_imc(void) }/* -* get_mem_bw_imc: Memory band width as reported by iMC counters -* @cpu_no: CPU number that the benchmark PID is binded to -* @bw_report: Bandwidth report type (reads, writes) -* -* Memory B/W utilized by a process on a socket can be calculated using -* iMC counters. Perf events are used to read these counters. +* perf_open_imc_mem_bw - Open perf fds for IMCs +* @cpu_no: CPU number that the benchmark PID is binded to * * Return: = 0 on success. < 0 on failure. */ -static int get_mem_bw_imc (int cpu_no,char *bw_report,float *bw_imc) +static int perf_open_imc_mem_bw (int cpu_no) { -float reads, writes, of_mul_read, of_mul_write;int imc, ret; -/* Start all iMC counters to log values (both read and write) */ - reads =0 , writes =0 , of_mul_read =1 , of_mul_write =1 ;for (imc =0 ; imc < imcs; imc++) { ret =open_perf_event (imc, cpu_no,READ );if (ret)
@@ -317,7 +310,22 @@ static int get_mem_bw_imc(int cpu_no, char *bw_report, float *bw_imc) ret =open_perf_event (imc, cpu_no,WRITE );if (ret)return -1 ; + } + +return 0 ; +} +/* +* do_mem_bw_test - Perform memory bandwidth test +* +* Runs memory bandwidth test over one second period. Also, handles starting +* and stopping of the IMC perf counters around the test. +*/ +static void do_imc_mem_bw_test (void ) +{ +int imc; + +for (imc =0 ; imc < imcs; imc++) {membw_ioctl_perf_event_ioc_reset_enable (imc,READ );membw_ioctl_perf_event_ioc_reset_enable (imc,WRITE ); }
@@ -329,6 +337,24 @@ static int get_mem_bw_imc(int cpu_no, char *bw_report, float *bw_imc)membw_ioctl_perf_event_ioc_disable (imc,READ );membw_ioctl_perf_event_ioc_disable (imc,WRITE ); } +} + +/* +* get_mem_bw_imc - Memory band width as reported by iMC counters +* @bw_report: Bandwidth report type (reads, writes) +* +* Memory B/W utilized by a process on a socket can be calculated using +* iMC counters. Perf events are used to read these counters. +* +* Return: = 0 on success. < 0 on failure. +*/ +static int get_mem_bw_imc (char *bw_report,float *bw_imc) +{ +float reads, writes, of_mul_read, of_mul_write; +int imc; + +/* Start all iMC counters to log values (both read and write) */ + reads =0 , writes =0 , of_mul_read =1 , of_mul_write =1 ;/* * Get results which are stored in struct type imc_counter_config
@@ -600,10 +626,9 @@ static void initialize_llc_occu_resctrl(const char *ctrlgrp, const char *mongrp, }static int measure_vals (const struct user_params *uparams, -struct resctrl_val_param *param, -unsigned long *bw_resc_start) +struct resctrl_val_param *param) { -unsigned long bw_resc, bw_resc_end; +unsigned long bw_resc, bw_resc_start, bw_resc_end;float bw_imc;int ret;
@@ -614,22 +639,27 @@ static int measure_vals(const struct user_params *uparams,* Compare the two values to validate resctrl value. * It takes 1sec to measure the data. */ - ret =get_mem_bw_imc (uparams->cpu, param->bw_report, &bw_imc); + ret =perf_open_imc_mem_bw (uparams->cpu); +if (ret <0 ) +return ret; + + ret =get_mem_bw_resctrl (&bw_resc_start);if (ret <0 )return ret; +do_imc_mem_bw_test (); + ret =get_mem_bw_resctrl (&bw_resc_end);if (ret <0 )return ret; - bw_resc = (bw_resc_end - *bw_resc_start) /MB ; - ret =print_results_bw (param->filename, bm_pid, bw_imc, bw_resc); -if (ret) + ret =get_mem_bw_imc (param->bw_report, &bw_imc); +if (ret <0 )return ret; - *bw_resc_start = bw_resc_end; + bw_resc = (bw_resc_end - bw_resc_start) /MB ; -return 0 ; +return print_results_bw (param->filename, bm_pid, bw_imc, bw_resc); }/*
@@ -703,7 +733,6 @@ int resctrl_val(const struct resctrl_test *test, struct resctrl_val_param *param) {char *resctrl_val = param->resctrl_val; -unsigned long bw_resc_start =0 ;struct sigaction sigact;int ret =0 , pipefd[2 ];char pipe_message =0 ;
@@ -845,7 +874,7 @@ int resctrl_val(const struct resctrl_test *test,if (!strncmp (resctrl_val,MBM_STR ,sizeof (MBM_STR )) || !strncmp (resctrl_val,MBA_STR ,sizeof (MBA_STR ))) { - ret =measure_vals (uparams, param, &bw_resc_start); + ret =measure_vals (uparams, param);if (ret)break ; }else if (!strncmp (resctrl_val,CMT_STR ,sizeof (CMT_STR ))) {
Signature · 1 line
2.39.2
Reinette Chatre
maintainerRe: [PATCH v3 02/16] selftests/resctrl: Calculate resctrl FS derived mem bw over sleep(1) only
Hi Ilpo,
Quoted 11 lines · Ilpo Järvinen
For MBM/MBA tests,
measure_vals()callsget_mem_bw_imc()that performs the measurement over a duration of sleep(1) call. The memory bandwidth numbers from IMC are derived over this duration. The resctrl FS derived memory bandwidth, however, is calculated insidemeasure_vals()and only takes delta between the previous value and the current one which besides the actual test, also samples inter-test noise.Rework the logic in
measure_vals()andget_mem_bw_imc()such that the resctrl FS memory bandwidth section covers much shorter duration closely matching that of the IMC perf counters to improve measurement accuracy.
I do not know how much latency this adds but I think for the resctrl data to reach this stated goal to closely match the IMC perf counters it can keep the file descriptor open during the test and only read data from the appropriate file instead of encurring the fopen()/fclose() cost at each measurement.
Reinette
PATCH v3 3/16 selftests/resctrl: Fix closing IMC fds on error
In reply to Ilpo JärvinenIf perf_open_imc_mem_bw() fails to open for a perf fd after the first one, the already opened fds remain open and error is directly returned.
Close the fds inside perf_open_imc_mem_bw() if an error occurs.
---
v3:
- New patch
--- tools/testing/selftests/resctrl/resctrl_val.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
tools/testing/selftests/resctrl/resctrl_val.c +12 -2
@@ -306,13 +306,23 @@ static int perf_open_imc_mem_bw(int cpu_no)for (imc =0 ; imc < imcs; imc++) { ret =open_perf_event (imc, cpu_no,READ );if (ret) -return -1 ; + goto close_fds; ret =open_perf_event (imc, cpu_no,WRITE );if (ret) -return -1 ; + goto close_read_fd; }return 0 ; + +close_read_fd: +close (imc_counters_config[imc][READ ].fd); +close_fds: +while (imc--) { +close (imc_counters_config[imc][READ ].fd); +close (imc_counters_config[imc][WRITE ].fd); + } + +return -1 ; }/*
Signature · 1 line
2.39.2
PATCH v3 4/16 selftests/resctrl: Make "bandwidth" consistent in comments & prints
In reply to Ilpo JärvinenResctrl selftests refer to "bandwidth" currently in two other forms in the code ("B/W" and "band width").
Use "bandwidth" consistently everywhere. While at it, fix also one "over flow" -> "overflow" on a line that is touched by the change.
---
v3:
- New patch
--- tools/testing/selftests/resctrl/resctrl_val.c | 14 +++++++------- tools/testing/selftests/resctrl/resctrlfs.c | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-)
tools/testing/selftests/resctrl/resctrl_val.c +7 -7
@@ -350,11 +350,11 @@ static void do_imc_mem_bw_test(void) }/* -* get_mem_bw_imc - Memory band width as reported by iMC counters +* get_mem_bw_imc - Memory bandwidth as reported by iMC counters * @bw_report: Bandwidth report type (reads, writes) * -* Memory B/W utilized by a process on a socket can be calculated using -* iMC counters. Perf events are used to read these counters. +* Memory bandwidth utilized by a process on a socket can be calculated +* using iMC counters. Perf events are used to read these counters. * * Return: = 0 on success. < 0 on failure. */
@@ -368,7 +368,7 @@ static int get_mem_bw_imc(char *bw_report, float *bw_imc)/* * Get results which are stored in struct type imc_counter_config -* Take over flow into consideration before calculating total b/w +* Take overflow into consideration before calculating total bandwidth. */ for (imc =0 ; imc < imcs; imc++) { struct imc_counter_config *r =
@@ -378,14 +378,14 @@ static int get_mem_bw_imc(char *bw_report, float *bw_imc)if (read (r->fd, &r->return_value,sizeof (struct membw_read_format )) ==-1 ) { -ksft_perror ("Couldn't get read b/w through iMC" ); +ksft_perror ("Couldn't get read bandwidth through iMC" );return -1 ; }if (read (w->fd, &w->return_value,sizeof (struct membw_read_format )) ==-1 ) { -ksft_perror ("Couldn't get write bw through iMC" ); +ksft_perror ("Couldn't get write bandwidth through iMC" );return -1 ; }
@@ -488,7 +488,7 @@ static int get_mem_bw_resctrl(unsigned long *mbm_total) fp =fopen (mbm_total_path,"r" );if (!fp) { -ksft_perror ("Failed to open total bw file" ); +ksft_perror ("Failed to open total memory bandwidth file" );return -1 ; }
tools/testing/selftests/resctrl/resctrlfs.c +1 -1
@@ -850,7 +850,7 @@ int validate_bw_report_request(char *bw_report)if (strcmp (bw_report,"total" ) ==0 )return 0 ; -fprintf (stderr,"Requested iMC B/W report type unavailable\n" ); +fprintf (stderr,"Requested iMC bandwidth report type unavailable\n" );return -1 ; }
Signature · 1 line
2.39.2
PATCH v3 5/16 selftests/resctrl: Consolidate get_domain_id() into resctrl_val()
In reply to Ilpo JärvinenBoth initialize_mem_bw_resctrl() and initialize_llc_occu_resctrl() that are called from resctrl_val() need to determine domain ID to construct resctrl fs related paths. Both functions do it by taking CPU ID which neither needs for any other purpose than determining the domain ID.
Consolidate determining the domain ID into resctrl_val() and pass the domain ID instead of CPU ID to initialize_mem_bw_resctrl() and initialize_llc_occu_resctrl().
--- tools/testing/selftests/resctrl/resctrl_val.c | 33 ++++++++----------- 1 file changed, 13 insertions(+), 20 deletions(-)
tools/testing/selftests/resctrl/resctrl_val.c +13 -20
@@ -446,19 +446,12 @@ void set_mbm_path(const char *ctrlgrp, const char *mongrp, int domain_id)* initialize_mem_bw_resctrl: Appropriately populate "mbm_total_path" * @ctrlgrp: Name of the control monitor group (con_mon grp) * @mongrp: Name of the monitor group (mon grp) -* @cpu_no: CPU number that the benchmark PID is binded to +* @domain_id: Domain ID (cache ID; for MB, L3 cache ID) * @resctrl_val: Resctrl feature (Eg: mbm, mba.. etc) */ static void initialize_mem_bw_resctrl (const char *ctrlgrp,const char *mongrp, -int cpu_no,char *resctrl_val) +int domain_id,char *resctrl_val) { -int domain_id; - -if (get_domain_id ("MB" , cpu_no, &domain_id) <0 ) { -ksft_print_msg ("Could not get domain ID\n" ); -return ; - } -if (!strncmp (resctrl_val,MBM_STR ,sizeof (MBM_STR )))set_mbm_path (ctrlgrp, mongrp, domain_id);
@@ -618,19 +611,12 @@ static void set_cmt_path(const char *ctrlgrp, const char *mongrp, char sock_num)* initialize_llc_occu_resctrl: Appropriately populate "llc_occup_path" * @ctrlgrp: Name of the control monitor group (con_mon grp) * @mongrp: Name of the monitor group (mon grp) -* @cpu_no: CPU number that the benchmark PID is binded to +* @domain_id: Domain ID (cache ID; for MB, L3 cache ID) * @resctrl_val: Resctrl feature (Eg: cat, cmt.. etc) */ static void initialize_llc_occu_resctrl (const char *ctrlgrp,const char *mongrp, -int cpu_no,char *resctrl_val) +int domain_id,char *resctrl_val) { -int domain_id; - -if (get_domain_id ("L3" , cpu_no, &domain_id) <0 ) { -ksft_print_msg ("Could not get domain ID\n" ); -return ; - } -if (!strncmp (resctrl_val,CMT_STR ,sizeof (CMT_STR )))set_cmt_path (ctrlgrp, mongrp, domain_id); }
@@ -747,10 +733,17 @@ int resctrl_val(const struct resctrl_test *test,int ret =0 , pipefd[2 ];char pipe_message =0 ;union sigval value; +int domain_id;if (strcmp (param->filename,"" ) ==0 )sprintf (param->filename,"stdio" ); + ret =get_domain_id (test->resource, uparams->cpu, &domain_id); +if (ret <0 ) { +ksft_print_msg ("Could not get domain ID\n" ); +return ret; + } +if (!strncmp (resctrl_val,MBA_STR ,sizeof (MBA_STR )) || !strncmp (resctrl_val,MBM_STR ,sizeof (MBM_STR ))) { ret =validate_bw_report_request (param->bw_report);
@@ -845,10 +838,10 @@ int resctrl_val(const struct resctrl_test *test, goto out;initialize_mem_bw_resctrl (param->ctrlgrp, param->mongrp, - uparams->cpu, resctrl_val); + domain_id, resctrl_val); }else if (!strncmp (resctrl_val,CMT_STR ,sizeof (CMT_STR )))initialize_llc_occu_resctrl (param->ctrlgrp, param->mongrp, - uparams->cpu, resctrl_val); + domain_id, resctrl_val);/* Parent waits for child to be ready. */ close (pipefd[1 ]);
Signature · 1 line
2.39.2
PATCH v3 6/16 selftests/resctrl: Use correct type for pids
In reply to Ilpo JärvinenA few functions receive PIDs through int arguments. PIDs variables should be of type pid_t, not int.
Convert pid arguments from int to pid_t.
--- tools/testing/selftests/resctrl/cache.c | 6 +++--- tools/testing/selftests/resctrl/resctrl.h | 4 ++-- tools/testing/selftests/resctrl/resctrl_val.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-)
tools/testing/selftests/resctrl/cache.c +3 -3
@@ -101,7 +101,7 @@ static int get_llc_occu_resctrl(unsigned long *llc_occupancy)* * Return: 0 on success, < 0 on error. */ -static int print_results_cache (const char *filename,int bm_pid,__u64 llc_value) +static int print_results_cache (const char *filename,pid_t bm_pid,__u64 llc_value) {FILE *fp;
@@ -133,7 +133,7 @@ static int print_results_cache(const char *filename, int bm_pid, __u64 llc_value* Return: =0 on success. <0 on failure. */ int perf_event_measure (int pe_fd,struct perf_event_read *pe_read, -const char *filename,int bm_pid) +const char *filename,pid_t bm_pid) {int ret;
@@ -161,7 +161,7 @@ int perf_event_measure(int pe_fd, struct perf_event_read *pe_read,* * Return: =0 on success. <0 on failure. */ -int measure_llc_resctrl (const char *filename,int bm_pid) +int measure_llc_resctrl (const char *filename,pid_t bm_pid) {unsigned long llc_occu_resc =0 ;int ret;
tools/testing/selftests/resctrl/resctrl.h +2 -2
@@ -174,8 +174,8 @@ void perf_event_initialize_read_format(struct perf_event_read *pe_read);int perf_open (struct perf_event_attr *pea,pid_t pid,int cpu_no);int perf_event_reset_enable (int pe_fd);int perf_event_measure (int pe_fd,struct perf_event_read *pe_read, -const char *filename,int bm_pid); -int measure_llc_resctrl (const char *filename,int bm_pid); +const char *filename,pid_t bm_pid); +int measure_llc_resctrl (const char *filename,pid_t bm_pid);void show_cache_info (int no_of_bits,__u64 avg_llc_val,size_t cache_span,bool lines);/*
tools/testing/selftests/resctrl/resctrl_val.c +1 -1
@@ -563,7 +563,7 @@ void signal_handler_unregister(void)* * Return: 0 on success, < 0 on error. */ -static int print_results_bw (char *filename,int bm_pid,float bw_imc, +static int print_results_bw (char *filename,pid_t bm_pid,float bw_imc,unsigned long bw_resc) {unsigned long diff =fabs (bw_imc - bw_resc);
Signature · 1 line
2.39.2
PATCH v3 7/16 selftests/resctrl: Cleanup bm_pid and ppid usage & limit scope
In reply to Ilpo Järvinen'bm_pid' and 'ppid' are global variables. As they are used by different processes and in signal handler, they cannot be entirely converted into local variables.
The scope of those variables can still be reduced into resctrl_val.c only. As PARENT_EXIT() macro is using 'ppid', make it a function in resctrl_val.c and pass ppid to it as an argument because it is easier to understand than using the global variable directly.
Pass 'bm_pid' into measure_val() instead of relying on the global variable which helps to make the call signatures of measure_val() and measure_llc_resctrl() more similar to each other.
--- tools/testing/selftests/resctrl/resctrl.h | 9 -------- tools/testing/selftests/resctrl/resctrl_val.c | 23 ++++++++++++------- 2 files changed, 15 insertions(+), 17 deletions(-)
tools/testing/selftests/resctrl/resctrl.h +0 -9
@@ -43,13 +43,6 @@#define DEFAULT_SPAN (250 * MB) -#define PARENT_EXIT () \ - do { \ - kill(ppid, SIGKILL); \ - umount_resctrlfs(); \ - exit(EXIT_FAILURE); \ - } while (0) -/* * user_params: User supplied parameters * @cpu: CPU number to which the benchmark will be bound to
@@ -127,8 +120,6 @@ struct perf_event_read {*/ extern volatile int *value_sink; -extern pid_t bm_pid, ppid; -extern char llc_occup_path[1024 ];int get_vendor (void );
tools/testing/selftests/resctrl/resctrl_val.c +15 -8
@@ -496,7 +496,7 @@ static int get_mem_bw_resctrl(unsigned long *mbm_total)return 0 ; } -pid_t bm_pid, ppid; +static pid_t bm_pid, ppid;void ctrlc_handler (int signum,siginfo_t *info,void *ptr) {
@@ -554,6 +554,13 @@ void signal_handler_unregister(void) } } +static void parent_exit (pid_t ppid) +{ +kill (ppid,SIGKILL ); +umount_resctrlfs (); +exit (EXIT_FAILURE ); +} +/* * print_results_bw: the memory bandwidth results are stored in a file * @filename: file that stores the results
@@ -622,7 +629,7 @@ static void initialize_llc_occu_resctrl(const char *ctrlgrp, const char *mongrp, }static int measure_vals (const struct user_params *uparams, -struct resctrl_val_param *param) +struct resctrl_val_param *param,pid_t bm_pid) {unsigned long bw_resc, bw_resc_start, bw_resc_end;float bw_imc;
@@ -682,7 +689,7 @@ static void run_benchmark(int signum, siginfo_t *info, void *ucontext) fp =freopen ("/dev/null" ,"w" , stdout);if (!fp) {ksft_perror ("Unable to direct benchmark status to /dev/null" ); -PARENT_EXIT (); +parent_exit (ppid); }if (strcmp (benchmark_cmd[0 ],"fill_buf" ) ==0 ) {
@@ -696,7 +703,7 @@ static void run_benchmark(int signum, siginfo_t *info, void *ucontext) once = false; }else {ksft_print_msg ("Invalid once parameter\n" ); -PARENT_EXIT (); +parent_exit (ppid); }if (run_fill_buf (span, memflush, operation, once))
@@ -710,7 +717,7 @@ static void run_benchmark(int signum, siginfo_t *info, void *ucontext)fclose (stdout);ksft_print_msg ("Unable to run specified benchmark\n" ); -PARENT_EXIT (); +parent_exit (ppid); }/*
@@ -789,7 +796,7 @@ int resctrl_val(const struct resctrl_test *test,/* Register for "SIGUSR1" signal from parent */ if (sigaction (SIGUSR1 , &sigact,NULL )) {ksft_perror ("Can't register child for signal" ); -PARENT_EXIT (); +parent_exit (ppid); }/* Tell parent that child is ready */
@@ -807,7 +814,7 @@ int resctrl_val(const struct resctrl_test *test,sigsuspend (&sigact.sa_mask);ksft_perror ("Child is done" ); -PARENT_EXIT (); +parent_exit (ppid); }ksft_print_msg ("Benchmark PID: %d\n" , bm_pid);
@@ -877,7 +884,7 @@ int resctrl_val(const struct resctrl_test *test,if (!strncmp (resctrl_val,MBM_STR ,sizeof (MBM_STR )) || !strncmp (resctrl_val,MBA_STR ,sizeof (MBA_STR ))) { - ret =measure_vals (uparams, param); + ret =measure_vals (uparams, param, bm_pid);if (ret)break ; }else if (!strncmp (resctrl_val,CMT_STR ,sizeof (CMT_STR ))) {
Signature · 1 line
2.39.2
Reinette Chatre
maintainerRe: [PATCH v3 07/16] selftests/resctrl: Cleanup bm_pid and ppid usage & limit scope
Hi Ilpo,
Quoted 4 lines · Ilpo Järvinen
'
bm_pid' and 'ppid' are global variables. As they are used by different processes and in signal handler, they cannot be entirely converted into local variables.
Quoted 8 lines
The scope of those variables can still be reduced into
resctrl_val.conly. AsPARENT_EXIT()macro is using 'ppid', make it a function inresctrl_val.cand pass ppid to it as an argument because it is easier to understand than using the global variable directly.Pass '
bm_pid' intomeasure_val()instead of relying on the global variable which helps to make the call signatures ofmeasure_val()andmeasure_llc_resctrl()more similar to each other.
nitpick: measure_val() -> measure_vals() (two instances above and also in the changelog of next patch)
Quoted 3 lines
Signed-off-by Ilpo Järvinen <[email protected]>---
Reinette
PATCH v3 8/16 selftests/resctrl: Rename measure_vals() to measure_mem_bw_vals() & document
In reply to Ilpo Järvinenmeasure_val() is awfully generic name so rename it to measure_mem_bw() to describe better what it does and document the function parameters.
--- tools/testing/selftests/resctrl/resctrl_val.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
tools/testing/selftests/resctrl/resctrl_val.c +9 -3
@@ -628,8 +628,14 @@ static void initialize_llc_occu_resctrl(const char *ctrlgrp, const char *mongrp,set_cmt_path (ctrlgrp, mongrp, domain_id); } -static int measure_vals (const struct user_params *uparams, -struct resctrl_val_param *param,pid_t bm_pid) +/* +* measure_mem_bw - Measures memory bandwidth numbers while benchmark runs +* @uparams: User supplied parameters +* @param: parameters passed to resctrl_val() +* @bm_pid: PID that runs the benchmark +*/ +static int measure_mem_bw (const struct user_params *uparams, +struct resctrl_val_param *param,pid_t bm_pid) {unsigned long bw_resc, bw_resc_start, bw_resc_end;float bw_imc;
@@ -884,7 +890,7 @@ int resctrl_val(const struct resctrl_test *test,if (!strncmp (resctrl_val,MBM_STR ,sizeof (MBM_STR )) || !strncmp (resctrl_val,MBA_STR ,sizeof (MBA_STR ))) { - ret =measure_vals (uparams, param, bm_pid); + ret =measure_mem_bw (uparams, param, bm_pid);if (ret)break ; }else if (!strncmp (resctrl_val,CMT_STR ,sizeof (CMT_STR ))) {
Signature · 1 line
2.39.2
PATCH v3 9/16 selftests/resctrl: Simplify mem bandwidth file code for MBA & MBM tests
In reply to Ilpo Järvineninitialize_mem_bw_resctrl() and set_mbm_path() contain complicated set of conditions, each yielding different file to be opened to measure memory bandwidth through resctrl FS. In practice, only two of them are used. For MBA test, ctrlgrp is always provided, and for MBM test both ctrlgrp and mongrp are set.
The file used differ between MBA/MBM test, however, MBM test unnecessarily create monitor group because resctrl FS already provides monitoring interface underneath any ctrlgrp too, which is what the MBA selftest uses.
Consolidate memory bandwidth file used to the one used by the MBA selftest. Remove all unused branches opening other files to simplify the code.
---
v3:
- New patch
--- tools/testing/selftests/resctrl/resctrl_val.c | 45 ++----------------- 1 file changed, 4 insertions(+), 41 deletions(-)
tools/testing/selftests/resctrl/resctrl_val.c +4 -41
@@ -19,18 +19,10 @@#define MAX_TOKENS 5#define READ 0#define WRITE 1 -#define CON_MON_MBM_LOCAL_BYTES_PATH \ - "%s/%s/mon_groups/%s/mon_data/mon_L3_%02d/mbm_local_bytes"#define CON_MBM_LOCAL_BYTES_PATH \ "%s/%s/mon_data/mon_L3_%02d/mbm_local_bytes" -#define MON_MBM_LOCAL_BYTES_PATH \ - "%s/mon_groups/%s/mon_data/mon_L3_%02d/mbm_local_bytes" - -#define MBM_LOCAL_BYTES_PATH \ - "%s/mon_data/mon_L3_%02d/mbm_local_bytes" -#define CON_MON_LCC_OCCUP_PATH \ "%s/%s/mon_groups/%s/mon_data/mon_L3_%02d/llc_occupancy"
@@ -426,43 +418,15 @@ static int get_mem_bw_imc(char *bw_report, float *bw_imc)return 0 ; } -void set_mbm_path (const char *ctrlgrp,const char *mongrp,int domain_id) -{ -if (ctrlgrp && mongrp) -sprintf (mbm_total_path,CON_MON_MBM_LOCAL_BYTES_PATH , -RESCTRL_PATH , ctrlgrp, mongrp, domain_id); -else if (!ctrlgrp && mongrp) -sprintf (mbm_total_path,MON_MBM_LOCAL_BYTES_PATH ,RESCTRL_PATH , - mongrp, domain_id); -else if (ctrlgrp && !mongrp) -sprintf (mbm_total_path,CON_MBM_LOCAL_BYTES_PATH ,RESCTRL_PATH , - ctrlgrp, domain_id); -else if (!ctrlgrp && !mongrp) -sprintf (mbm_total_path,MBM_LOCAL_BYTES_PATH ,RESCTRL_PATH , - domain_id); -} -/* * initialize_mem_bw_resctrl: Appropriately populate "mbm_total_path" * @ctrlgrp: Name of the control monitor group (con_mon grp) -* @mongrp: Name of the monitor group (mon grp) * @domain_id: Domain ID (cache ID; for MB, L3 cache ID) -* @resctrl_val: Resctrl feature (Eg: mbm, mba.. etc) */ -static void initialize_mem_bw_resctrl (const char *ctrlgrp,const char *mongrp, -int domain_id,char *resctrl_val) +static void initialize_mem_bw_resctrl (const char *ctrlgrp,int domain_id) { -if (!strncmp (resctrl_val,MBM_STR ,sizeof (MBM_STR ))) -set_mbm_path (ctrlgrp, mongrp, domain_id); - -if (!strncmp (resctrl_val,MBA_STR ,sizeof (MBA_STR ))) { -if (ctrlgrp) -sprintf (mbm_total_path,CON_MBM_LOCAL_BYTES_PATH , -RESCTRL_PATH , ctrlgrp, domain_id); -else -sprintf (mbm_total_path,MBM_LOCAL_BYTES_PATH , -RESCTRL_PATH , domain_id); - } +sprintf (mbm_total_path,CON_MBM_LOCAL_BYTES_PATH ,RESCTRL_PATH , + ctrlgrp, domain_id); }/*
@@ -850,8 +814,7 @@ int resctrl_val(const struct resctrl_test *test,if (ret) goto out; -initialize_mem_bw_resctrl (param->ctrlgrp, param->mongrp, - domain_id, resctrl_val); +initialize_mem_bw_resctrl (param->ctrlgrp, domain_id); }else if (!strncmp (resctrl_val,CMT_STR ,sizeof (CMT_STR )))initialize_llc_occu_resctrl (param->ctrlgrp, param->mongrp, domain_id, resctrl_val);
Signature · 1 line
2.39.2
Reinette Chatre
maintainerRe: [PATCH v3 09/16] selftests/resctrl: Simplify mem bandwidth file code for MBA & MBM tests
Hi Ilpo,
Quoted 6 lines · Ilpo Järvinen
initialize_mem_bw_resctrl()andset_mbm_path()contain complicated set of conditions, each yielding different file to be opened to measure memory bandwidth through resctrl FS. In practice, only two of them are used. For MBA test, ctrlgrp is always provided, and for MBM test both ctrlgrp and mongrp are set.
Quoted 8 lines
The file used differ between MBA/MBM test, however, MBM test unnecessarily create monitor group because resctrl FS already provides monitoring interface underneath any ctrlgrp too, which is what the MBA selftest uses.
Consolidate memory bandwidth file used to the one used by the MBA selftest. Remove all unused branches opening other files to simplify the code.
This is a good change but it seems incomplete to me. As changelog states MBM creates monitor group unnecessarily, but from what I can tell it continues to do so after this change. It is also optimized in patch 16, which I think may end up being dropped as part of cleaning this up (here and for the CMT test).
Reinette
PATCH v3 10/16 selftests/resctrl: Add ->measure() callback to resctrl_val_param
In reply to Ilpo JärvinenThe measurement done in resctrl_val() varies depending on test type. The decision for how to measure is decided based on the string compare to test name which is quite inflexible.
Add ->measure() callback into the struct resctrl_val_param to allow each test to provide necessary code as a function which simplifies what resctrl_val() has to do.
---
v2:
- spaces -> tabs
--- tools/testing/selftests/resctrl/cmt_test.c | 8 ++++++++ tools/testing/selftests/resctrl/mba_test.c | 9 ++++++++- tools/testing/selftests/resctrl/mbm_test.c | 9 ++++++++- tools/testing/selftests/resctrl/resctrl.h | 6 ++++++ tools/testing/selftests/resctrl/resctrl_val.c | 18 +++++------------- 5 files changed, 35 insertions(+), 15 deletions(-)
tools/testing/selftests/resctrl/cmt_test.c +8 -0
@@ -29,6 +29,13 @@ static int cmt_setup(const struct resctrl_test *test,return 0 ; } +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); +} + 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,
@@ -133,6 +140,7 @@ static int cmt_run_test(const struct resctrl_test *test, const struct user_param .mask = ~(long_mask << n) & long_mask, .num_of_runs = 0, .setup = cmt_setup, + .measure = cmt_measure, }; span =cache_portion_size (cache_total_size, param.mask, long_mask);
tools/testing/selftests/resctrl/mba_test.c +8 -1
@@ -51,6 +51,12 @@ static int mba_setup(const struct resctrl_test *test,return 0 ; } +static int mba_measure (const struct user_params *uparams, +struct resctrl_val_param *param,pid_t bm_pid) +{ +return measure_mem_bw (uparams, param, bm_pid); +} +static bool show_mba_info (unsigned long *bw_imc,unsigned long *bw_resc) {int allocation, runs;
@@ -150,7 +156,8 @@ static int mba_run_test(const struct resctrl_test *test, const struct user_param .mongrp = "m1", .filename = RESULT_FILE_NAME, .bw_report = "reads", - .setup = mba_setup + .setup = mba_setup, + .measure = mba_measure, };int ret;
tools/testing/selftests/resctrl/mbm_test.c +8 -1
@@ -105,6 +105,12 @@ static int mbm_setup(const struct resctrl_test *test,return ret; } +static int mbm_measure (const struct user_params *uparams, +struct resctrl_val_param *param,pid_t bm_pid) +{ +return measure_mem_bw (uparams, param, bm_pid); +} +static void mbm_test_cleanup (void ) {remove (RESULT_FILE_NAME );
@@ -118,7 +124,8 @@ static int mbm_run_test(const struct resctrl_test *test, const struct user_param .mongrp = "m1", .filename = RESULT_FILE_NAME, .bw_report = "reads", - .setup = mbm_setup + .setup = mbm_setup, + .measure = mbm_measure, };int ret;
tools/testing/selftests/resctrl/resctrl.h +6 -0
@@ -87,6 +87,7 @@ struct resctrl_test {* @filename: Name of file to which the o/p should be written * @bw_report: Bandwidth report type (reads vs writes) * @setup: Call back function to setup test environment +* @measure: Callback that performs the measurement (a single test) */ struct resctrl_val_param {char *resctrl_val;
@@ -99,6 +100,9 @@ struct resctrl_val_param {int (*setup)(const struct resctrl_test *test,const struct user_params *uparams,struct resctrl_val_param *param); +int (*measure)(const struct user_params *uparams, +struct resctrl_val_param *param, +pid_t bm_pid); };struct perf_event_read {
@@ -145,6 +149,8 @@ unsigned char *alloc_buffer(size_t buf_size, int memflush);void mem_flush (unsigned char *buf,size_t buf_size);void fill_cache_read (unsigned char *buf,size_t buf_size,bool once);int run_fill_buf (size_t buf_size,int memflush,int op,bool once); +int measure_mem_bw (const struct user_params *uparams, +struct resctrl_val_param *param,pid_t bm_pid); int resctrl_val(const struct resctrl_test *test, const struct user_params *uparams, const char * const *benchmark_cmd,
tools/testing/selftests/resctrl/resctrl_val.c +5 -13
@@ -598,8 +598,8 @@ static void initialize_llc_occu_resctrl(const char *ctrlgrp, const char *mongrp,* @param: parameters passed to resctrl_val() * @bm_pid: PID that runs the benchmark */ -static int measure_mem_bw (const struct user_params *uparams, -struct resctrl_val_param *param,pid_t bm_pid) +int measure_mem_bw (const struct user_params *uparams, +struct resctrl_val_param *param,pid_t bm_pid) {unsigned long bw_resc, bw_resc_start, bw_resc_end;float bw_imc;
@@ -851,17 +851,9 @@ int resctrl_val(const struct resctrl_test *test,if (ret <0 )break ; -if (!strncmp (resctrl_val,MBM_STR ,sizeof (MBM_STR )) || - !strncmp (resctrl_val,MBA_STR ,sizeof (MBA_STR ))) { - ret =measure_mem_bw (uparams, param, bm_pid); -if (ret) -break ; - }else if (!strncmp (resctrl_val,CMT_STR ,sizeof (CMT_STR ))) { -sleep (1 ); - ret =measure_llc_resctrl (param->filename, bm_pid); -if (ret) -break ; - } + ret = param->measure (uparams, param, bm_pid); +if (ret) +break ; } out:
Signature · 1 line
2.39.2
PATCH v3 11/16 selftests/resctrl: Add ->init() callback into resctrl_val_param
In reply to Ilpo JärvinenThe struct resctrl_val_param is there to customize behavior inside resctrl_val() which is currently not used to full extent and there are number of strcmp()s for test name in resctrl_val done by resctrl_val().
Create ->init() hook into the struct resctrl_val_param to cleanly do per test initialization.
Remove also unused branches to setup paths and the related #defines for CMT test.
---
v3:
- Rename init functions to <testname>_init()
- Removed tabs intermixed with code
- Leave now common mbm bw filename setup into resctrl_val.c
--- tools/testing/selftests/resctrl/cmt_test.c | 12 +++ tools/testing/selftests/resctrl/mba_test.c | 14 ++++ tools/testing/selftests/resctrl/mbm_test.c | 14 ++++ tools/testing/selftests/resctrl/resctrl.h | 8 +- tools/testing/selftests/resctrl/resctrl_val.c | 76 +++---------------- 5 files changed, 59 insertions(+), 65 deletions(-)
tools/testing/selftests/resctrl/cmt_test.c +12 -0
@@ -16,6 +16,17 @@#define MAX_DIFF 2000000#define MAX_DIFF_PERCENT 15 +#define CON_MON_LCC_OCCUP_PATH \ + "%s/%s/mon_groups/%s/mon_data/mon_L3_%02d/llc_occupancy" + +static int cmt_init (const struct resctrl_val_param *param,int domain_id) +{ +sprintf (llc_occup_path,CON_MON_LCC_OCCUP_PATH ,RESCTRL_PATH , + param->ctrlgrp, param->mongrp, domain_id); + +return 0 ; +} +static int cmt_setup (const struct resctrl_test *test,const struct user_params *uparams,struct resctrl_val_param *p)
@@ -139,6 +150,7 @@ static int cmt_run_test(const struct resctrl_test *test, const struct user_param .filename = RESULT_FILE_NAME, .mask = ~(long_mask << n) & long_mask, .num_of_runs = 0, + .init = cmt_init, .setup = cmt_setup, .measure = cmt_measure, };
tools/testing/selftests/resctrl/mba_test.c +14 -0
@@ -17,6 +17,19 @@#define ALLOCATION_MIN 10#define ALLOCATION_STEP 10 +static int mba_init (const struct resctrl_val_param *param,int domain_id) +{ +int ret; + + ret =initialize_mem_bw_imc (); +if (ret) +return ret; + +initialize_mem_bw_resctrl (param, domain_id); + +return 0 ; +} +/* * Change schemata percentage from 100 to 10%. Write schemata to specified * con_mon grp, mon_grp in resctrl FS.
@@ -156,6 +169,7 @@ static int mba_run_test(const struct resctrl_test *test, const struct user_param .mongrp = "m1", .filename = RESULT_FILE_NAME, .bw_report = "reads", + .init = mba_init, .setup = mba_setup, .measure = mba_measure, };
tools/testing/selftests/resctrl/mbm_test.c +14 -0
@@ -86,6 +86,19 @@ static int check_results(size_t span)return ret; } +static int mbm_init (const struct resctrl_val_param *param,int domain_id) +{ +int ret; + + ret =initialize_mem_bw_imc (); +if (ret) +return ret; + +initialize_mem_bw_resctrl (param, domain_id); + +return 0 ; +} +static int mbm_setup (const struct resctrl_test *test,const struct user_params *uparams,struct resctrl_val_param *p)
@@ -124,6 +137,7 @@ static int mbm_run_test(const struct resctrl_test *test, const struct user_param .mongrp = "m1", .filename = RESULT_FILE_NAME, .bw_report = "reads", + .init = mbm_init, .setup = mbm_setup, .measure = mbm_measure, };
tools/testing/selftests/resctrl/resctrl.h +7 -1
@@ -86,7 +86,8 @@ struct resctrl_test {* @mongrp: Name of the monitor group (mon grp) * @filename: Name of file to which the o/p should be written * @bw_report: Bandwidth report type (reads vs writes) -* @setup: Call back function to setup test environment +* @init: Callback function to initialize test environment +* @setup: Callback function to setup per test run environment * @measure: Callback that performs the measurement (a single test) */ struct resctrl_val_param {
@@ -97,6 +98,8 @@ struct resctrl_val_param {char *bw_report;unsigned long mask;int num_of_runs; +int (*init)(const struct resctrl_val_param *param, +int domain_id);int (*setup)(const struct resctrl_test *test,const struct user_params *uparams,struct resctrl_val_param *param);
@@ -149,8 +152,11 @@ unsigned char *alloc_buffer(size_t buf_size, int memflush);void mem_flush (unsigned char *buf,size_t buf_size);void fill_cache_read (unsigned char *buf,size_t buf_size,bool once);int run_fill_buf (size_t buf_size,int memflush,int op,bool once); +int initialize_mem_bw_imc (void );int measure_mem_bw (const struct user_params *uparams,struct resctrl_val_param *param,pid_t bm_pid); +void initialize_mem_bw_resctrl (const struct resctrl_val_param *param, +int domain_id); int resctrl_val(const struct resctrl_test *test, const struct user_params *uparams, const char * const *benchmark_cmd,
tools/testing/selftests/resctrl/resctrl_val.c +12 -64
127 lines not on this page · raw message
Signature · 1 line
2.39.2
Reinette Chatre
maintainerRe: [PATCH v3 11/16] selftests/resctrl: Add ->init() callback into resctrl_val_param
Hi Ilpo,
Quoted 9 lines · Ilpo Järvinen
The struct
resctrl_val_paramis there to customize behavior insideresctrl_val()which is currently not used to full extent and there are number of strcmp()s for test name inresctrl_valdone byresctrl_val().Create ->init() hook into the struct
resctrl_val_paramto cleanly do per test initialization.Remove also unused branches to setup paths and the related #defines for CMT test.
All these code being moved have a similar pattern to earlier code that was deleted. It seems to me as though the CMT may also unnecessarily create a monitor group and have the same opportunity to remove some of the code being moved around here.
It is starting to look like resctrl_val_param->mongrp is not necessary.
Reinette
PATCH v3 12/16 selftests/resctrl: Simplify bandwidth report type handling
In reply to Ilpo Järvinenbw_report is only needed for selecting the correct value from the values IMC measured. It is a member in the resctrl_val_param struct and is always set to "reads". The value is then checked in resctrl_val() using validate_bw_report_request() that besides validating the input, assumes it can mutate the string which is questionable programming practice.
Simplify handling bw_report:
- Convert validate_bw_report_request() into get_bw_report_type() that inputs and returns const char *. Use NULL to indicate error.
- Validate the report types inside measure_mem_bw(), not in resctrl_val().
- As resctrl_val() no longer needs bw_report for anything, it can just be passed to measure_mem_bw() by the ->measure() hooks.
---
v2:
- Rebased on top of next to resolve conflict in resctrl.h
--- tools/testing/selftests/resctrl/mba_test.c | 3 +-- tools/testing/selftests/resctrl/mbm_test.c | 3 +-- tools/testing/selftests/resctrl/resctrl.h | 7 +++---- tools/testing/selftests/resctrl/resctrl_val.c | 19 +++++++++---------- tools/testing/selftests/resctrl/resctrlfs.c | 13 ++++++------- 5 files changed, 20 insertions(+), 25 deletions(-)
tools/testing/selftests/resctrl/mba_test.c +1 -2
@@ -67,7 +67,7 @@ static int mba_setup(const struct resctrl_test *test,static int mba_measure (const struct user_params *uparams,struct resctrl_val_param *param,pid_t bm_pid) { -return measure_mem_bw (uparams, param, bm_pid); +return measure_mem_bw (uparams, param, bm_pid,"reads" ); }static bool show_mba_info (unsigned long *bw_imc,unsigned long *bw_resc)
@@ -168,7 +168,6 @@ static int mba_run_test(const struct resctrl_test *test, const struct user_param .ctrlgrp = "c1", .mongrp = "m1", .filename = RESULT_FILE_NAME, - .bw_report = "reads", .init = mba_init, .setup = mba_setup, .measure = mba_measure,
tools/testing/selftests/resctrl/mbm_test.c +1 -2
@@ -121,7 +121,7 @@ static int mbm_setup(const struct resctrl_test *test,static int mbm_measure (const struct user_params *uparams,struct resctrl_val_param *param,pid_t bm_pid) { -return measure_mem_bw (uparams, param, bm_pid); +return measure_mem_bw (uparams, param, bm_pid,"reads" ); }static void mbm_test_cleanup (void )
@@ -136,7 +136,6 @@ static int mbm_run_test(const struct resctrl_test *test, const struct user_param .ctrlgrp = "c1", .mongrp = "m1", .filename = RESULT_FILE_NAME, - .bw_report = "reads", .init = mbm_init, .setup = mbm_setup, .measure = mbm_measure,
tools/testing/selftests/resctrl/resctrl.h +3 -4
@@ -85,7 +85,6 @@ struct resctrl_test {* @ctrlgrp: Name of the control monitor group (con_mon grp) * @mongrp: Name of the monitor group (mon grp) * @filename: Name of file to which the o/p should be written -* @bw_report: Bandwidth report type (reads vs writes) * @init: Callback function to initialize test environment * @setup: Callback function to setup per test run environment * @measure: Callback that performs the measurement (a single test)
@@ -95,7 +94,6 @@ struct resctrl_val_param {char ctrlgrp[64 ];char mongrp[64 ];char filename[64 ]; -char *bw_report;unsigned long mask;int num_of_runs; int (*init)(const struct resctrl_val_param *param,
@@ -135,7 +133,7 @@ int filter_dmesg(void);int get_domain_id (const char *resource,int cpu_no,int *domain_id);int mount_resctrlfs (void );int umount_resctrlfs (void ); -int validate_bw_report_request (char *bw_report); +const char *get_bw_report_type (const char *bw_report);bool resctrl_resource_exists (const char *resource);bool resctrl_mon_feature_exists (const char *resource,const char *feature);bool resource_info_file_exists (const char *resource,const char *file);
@@ -154,7 +152,8 @@ void fill_cache_read(unsigned char *buf, size_t buf_size, bool once);int run_fill_buf (size_t buf_size,int memflush,int op,bool once);int initialize_mem_bw_imc (void );int measure_mem_bw (const struct user_params *uparams, -struct resctrl_val_param *param,pid_t bm_pid); +struct resctrl_val_param *param,pid_t bm_pid, +const char *bw_report);void initialize_mem_bw_resctrl (const struct resctrl_val_param *param,int domain_id); int resctrl_val(const struct resctrl_test *test,
tools/testing/selftests/resctrl/resctrl_val.c +9 -10
@@ -338,7 +338,7 @@ static void do_imc_mem_bw_test(void)* * Return: = 0 on success. < 0 on failure. */ -static int get_mem_bw_imc (char *bw_report,float *bw_imc) +static int get_mem_bw_imc (const char *bw_report,float *bw_imc) {float reads, writes, of_mul_read, of_mul_write;int imc;
@@ -550,14 +550,20 @@ static int print_results_bw(char *filename, pid_t bm_pid, float bw_imc,* @uparams: User supplied parameters * @param: parameters passed to resctrl_val() * @bm_pid: PID that runs the benchmark +* @bw_report: Bandwidth report type (reads, writes) */ int measure_mem_bw (const struct user_params *uparams, -struct resctrl_val_param *param,pid_t bm_pid) +struct resctrl_val_param *param,pid_t bm_pid, +const char *bw_report) {unsigned long bw_resc, bw_resc_start, bw_resc_end;float bw_imc;int ret; + bw_report =get_bw_report_type (bw_report); +if (!bw_report) +return -1 ; +/* * Measure memory bandwidth from resctrl and from * another source which is perf imc value or could
@@ -579,7 +585,7 @@ int measure_mem_bw(const struct user_params *uparams,if (ret <0 )return ret; - ret =get_mem_bw_imc (param->bw_report, &bw_imc); + ret =get_mem_bw_imc (bw_report, &bw_imc);if (ret <0 )return ret;
@@ -674,13 +680,6 @@ int resctrl_val(const struct resctrl_test *test,return ret; } -if (!strncmp (resctrl_val,MBA_STR ,sizeof (MBA_STR )) || - !strncmp (resctrl_val,MBM_STR ,sizeof (MBM_STR ))) { - ret =validate_bw_report_request (param->bw_report); -if (ret) -return ret; - } -/* * If benchmark wasn't successfully started by child, then child should * kill parent, so save parent's pid
tools/testing/selftests/resctrl/resctrlfs.c +6 -7
@@ -837,22 +837,21 @@ int filter_dmesg(void)return 0 ; } -int validate_bw_report_request (char *bw_report) +const char *get_bw_report_type (const char *bw_report) {if (strcmp (bw_report,"reads" ) ==0 ) -return 0 ; +return bw_report;if (strcmp (bw_report,"writes" ) ==0 ) -return 0 ; +return bw_report;if (strcmp (bw_report,"nt-writes" ) ==0 ) { -strcpy (bw_report,"writes" ); -return 0 ; +return "writes" ; }if (strcmp (bw_report,"total" ) ==0 ) -return 0 ; +return bw_report;fprintf (stderr,"Requested iMC bandwidth report type unavailable\n" ); -return -1 ; +return NULL ; } int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu,
Signature · 1 line
2.39.2
PATCH v3 13/16 selftests/resctrl: Make some strings passed to resctrlfs functions const
In reply to Ilpo JärvinenControl group, monitor group and resctrl_val are not mutated and should not be mutated within resctrlfs.c functions.
Mark this by using const char * for the arguments.
--- tools/testing/selftests/resctrl/resctrl.h | 7 ++++--- tools/testing/selftests/resctrl/resctrlfs.c | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-)
tools/testing/selftests/resctrl/resctrl.h +4 -3
@@ -141,9 +141,10 @@ bool test_resource_feature_check(const struct resctrl_test *test);char *fgrep (FILE *inf,const char *str);int taskset_benchmark (pid_t bm_pid,int cpu_no,cpu_set_t *old_affinity);int taskset_restore (pid_t bm_pid,cpu_set_t *old_affinity); -int write_schemata (char *ctrlgrp,char *schemata,int cpu_no,const char *resource); -int write_bm_pid_to_resctrl (pid_t bm_pid,char *ctrlgrp,char *mongrp, -char *resctrl_val); +int write_schemata (const char *ctrlgrp,char *schemata,int cpu_no, +const char *resource); +int write_bm_pid_to_resctrl (pid_t bm_pid,const char *ctrlgrp, +const char *mongrp,const char *resctrl_val);int perf_event_open (struct perf_event_attr *hw_event,pid_t pid,int cpu,int group_fd,unsigned long flags);unsigned char *alloc_buffer (size_t buf_size,int memflush);
tools/testing/selftests/resctrl/resctrlfs.c +4 -3
@@ -534,8 +534,8 @@ static int write_pid_to_tasks(char *tasks, pid_t pid)* * Return: 0 on success, < 0 on error. */ -int write_bm_pid_to_resctrl (pid_t bm_pid,char *ctrlgrp,char *mongrp, -char *resctrl_val) +int write_bm_pid_to_resctrl (pid_t bm_pid,const char *ctrlgrp, +const char *mongrp,const char *resctrl_val) {char controlgroup[128 ], monitorgroup[512 ], monitorgroup_p[256 ];char tasks[1024 ];
@@ -593,7 +593,8 @@ int write_bm_pid_to_resctrl(pid_t bm_pid, char *ctrlgrp, char *mongrp,* * Return: 0 on success, < 0 on error. */ -int write_schemata (char *ctrlgrp,char *schemata,int cpu_no,const char *resource) +int write_schemata (const char *ctrlgrp,char *schemata,int cpu_no, +const char *resource) {char controlgroup[1024 ], reason[128 ], schema[1024 ] = {};int domain_id, fd, schema_len, ret =0 ;
Signature · 1 line
2.39.2
PATCH v3 14/16 selftests/resctrl: Convert ctrlgrp & mongrp to pointers
In reply to Ilpo JärvinenThe struct resctrl_val_param has control and monitor groups as char arrays but they are not supposed to be mutated within resctrl_val().
Convert the ctrlgrp and mongrp char array within resctrl_val_param to plain const char pointers and adjust the strlen() based checks to check NULL instead.
Convert !grp_name check in create_grp() into internal sanity check by returning error if the caller asked to create a group but doesn't provide a name for the group. The existing code already abides this by only calling create_grp() if mongrp is non-NULL so the error should never be returned with the current selftests (ctrlgrp is never NULL).
---
v3:
- Removed wrong comment
- Changed grp_name check to return -1 on fail (internal sanity check)
--- tools/testing/selftests/resctrl/resctrl.h | 4 ++-- tools/testing/selftests/resctrl/resctrlfs.c | 15 +++++---------- 2 files changed, 7 insertions(+), 12 deletions(-)
tools/testing/selftests/resctrl/resctrl.h +2 -2
@@ -91,8 +91,8 @@ struct resctrl_test {*/ struct resctrl_val_param {char *resctrl_val; -char ctrlgrp[64 ]; -char mongrp[64 ]; +const char *ctrlgrp; +const char *mongrp;char filename[64 ];unsigned long mask;int num_of_runs;
tools/testing/selftests/resctrl/resctrlfs.c +5 -10
@@ -464,13 +464,8 @@ static int create_grp(const char *grp_name, char *grp, const char *parent_grp)struct dirent *ep;DIR *dp; -/* -* At this point, we are guaranteed to have resctrl FS mounted and if -* length of grp_name == 0, it means, user wants to use root con_mon -* grp, so do nothing -*/ -if (strlen (grp_name) ==0 ) -return 0 ; +if (!grp_name) +return -1 ;/* Check if requested grp exists or not */ dp =opendir (parent_grp);
@@ -541,7 +536,7 @@ int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp,char tasks[1024 ];int ret =0 ; -if (strlen (ctrlgrp)) +if (ctrlgrp)sprintf (controlgroup,"%s/%s" ,RESCTRL_PATH , ctrlgrp);else sprintf (controlgroup,"%s" ,RESCTRL_PATH );
@@ -558,7 +553,7 @@ int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp,/* Create mon grp and write pid into it for "mbm" and "cmt" test */ if (!strncmp (resctrl_val,CMT_STR ,sizeof (CMT_STR )) || !strncmp (resctrl_val,MBM_STR ,sizeof (MBM_STR ))) { -if (strlen (mongrp)) { +if (mongrp) {sprintf (monitorgroup_p,"%s/mon_groups" , controlgroup);sprintf (monitorgroup,"%s/%s" , monitorgroup_p, mongrp); ret =create_grp (mongrp, monitorgroup, monitorgroup_p);
@@ -612,7 +607,7 @@ int write_schemata(const char *ctrlgrp, char *schemata, int cpu_no, goto out; } -if (strlen (ctrlgrp) !=0 ) +if (ctrlgrp)sprintf (controlgroup,"%s/%s/schemata" ,RESCTRL_PATH , ctrlgrp);else sprintf (controlgroup,"%s/schemata" ,RESCTRL_PATH );
Signature · 1 line
2.39.2
PATCH v3 15/16 selftests/resctrl: Remove mongrp from MBA test
In reply to Ilpo JärvinenNothing during MBA test uses mongrp even if it has been defined ever since the introduction of the MBA test in the commit 01fee6b4d1f9 ("selftests/resctrl: Add MBA test").
Remove the mongrp from MBA test.
--- tools/testing/selftests/resctrl/mba_test.c | 1 - 1 file changed, 1 deletion(-)
tools/testing/selftests/resctrl/mba_test.c +0 -1
@@ -166,7 +166,6 @@ static int mba_run_test(const struct resctrl_test *test, const struct user_paramstruct resctrl_val_param param = { .resctrl_val =MBA_STR , .ctrlgrp ="c1" , - .mongrp ="m1" , .filename =RESULT_FILE_NAME , .init = mba_init, .setup = mba_setup,
Signature · 1 line
2.39.2
PATCH v3 16/16 selftests/resctrl: Remove test name comparing from write_bm_pid_to_resctrl()
In reply to Ilpo Järvinenwrite_bm_pid_to_resctrl() uses resctrl_val to check test name which is not a good interface generic resctrl FS functions should provide.
Only MBM and CMT tests define mongrp so the test name check in write_bm_pid_to_resctrl() can be changed to depend simply on mongrp being non-NULL.
With last user of resctrl_val gone, the parameter and member from the struct resctrl_val_param can removed. Test name constants can also be removed because they are not used anymore.
--- tools/testing/selftests/resctrl/cat_test.c | 5 +-- tools/testing/selftests/resctrl/cmt_test.c | 1 - tools/testing/selftests/resctrl/mba_test.c | 1 - tools/testing/selftests/resctrl/mbm_test.c | 1 - tools/testing/selftests/resctrl/resctrl.h | 10 +----- tools/testing/selftests/resctrl/resctrl_val.c | 4 +-- tools/testing/selftests/resctrl/resctrlfs.c | 33 ++++++++----------- 7 files changed, 17 insertions(+), 38 deletions(-)
tools/testing/selftests/resctrl/cat_test.c +1 -4
@@ -158,7 +158,6 @@ static int cat_test(const struct resctrl_test *test,struct resctrl_val_param *param, size_t span, unsigned long current_mask) { - char *resctrl_val = param->resctrl_val; struct perf_event_read pe_read;struct perf_event_attr pea;cpu_set_t old_affinity;
@@ -178,8 +177,7 @@ static int cat_test(const struct resctrl_test *test,return ret;/* Write benchmark to specified con_mon grp, mon_grp in resctrl FS*/ - ret =write_bm_pid_to_resctrl (bm_pid, param->ctrlgrp, param->mongrp, - resctrl_val); + ret =write_bm_pid_to_resctrl (bm_pid, param->ctrlgrp, param->mongrp);if (ret) goto reset_affinity;
@@ -272,7 +270,6 @@ static int cat_run_test(const struct resctrl_test *test, const struct user_param start_mask =create_bit_mask (start, n);struct resctrl_val_param param = { - .resctrl_val =CAT_STR , .ctrlgrp ="c1" , .filename =RESULT_FILE_NAME , .num_of_runs =0 ,
tools/testing/selftests/resctrl/cmt_test.c +0 -1
@@ -144,7 +144,6 @@ static int cmt_run_test(const struct resctrl_test *test, const struct user_param }struct resctrl_val_param param = { - .resctrl_val =CMT_STR , .ctrlgrp ="c1" , .mongrp ="m1" , .filename =RESULT_FILE_NAME ,
tools/testing/selftests/resctrl/mba_test.c +0 -1
@@ -164,7 +164,6 @@ static void mba_test_cleanup(void)static int mba_run_test (const struct resctrl_test *test,const struct user_params *uparams) {struct resctrl_val_param param = { - .resctrl_val =MBA_STR , .ctrlgrp ="c1" , .filename =RESULT_FILE_NAME , .init = mba_init,
tools/testing/selftests/resctrl/mbm_test.c +0 -1
@@ -132,7 +132,6 @@ static void mbm_test_cleanup(void)static int mbm_run_test (const struct resctrl_test *test,const struct user_params *uparams) {struct resctrl_val_param param = { - .resctrl_val =MBM_STR , .ctrlgrp ="c1" , .mongrp ="m1" , .filename =RESULT_FILE_NAME ,
tools/testing/selftests/resctrl/resctrl.h +1 -9
@@ -81,7 +81,6 @@ struct resctrl_test {/* * resctrl_val_param: resctrl test parameters -* @resctrl_val: Resctrl feature (Eg: mbm, mba.. etc) * @ctrlgrp: Name of the control monitor group (con_mon grp) * @mongrp: Name of the monitor group (mon grp) * @filename: Name of file to which the o/p should be written
@@ -90,7 +89,6 @@ struct resctrl_test {* @measure: Callback that performs the measurement (a single test) */ struct resctrl_val_param { -char *resctrl_val;const char *ctrlgrp;const char *mongrp;char filename[64 ];
@@ -113,11 +111,6 @@ struct perf_event_read { } values[2 ]; }; -#define MBM_STR "mbm" -#define MBA_STR "mba" -#define CMT_STR "cmt" -#define CAT_STR "cat" -/* * Memory location that consumes values compiler must not optimize away. * Volatile ensures writes to this location cannot be optimized away by
@@ -143,8 +136,7 @@ int taskset_benchmark(pid_t bm_pid, int cpu_no, cpu_set_t *old_affinity);int taskset_restore (pid_t bm_pid,cpu_set_t *old_affinity);int write_schemata (const char *ctrlgrp,char *schemata,int cpu_no,const char *resource); -int write_bm_pid_to_resctrl (pid_t bm_pid,const char *ctrlgrp, -const char *mongrp,const char *resctrl_val); +int write_bm_pid_to_resctrl (pid_t bm_pid,const char *ctrlgrp,const char *mongrp);int perf_event_open (struct perf_event_attr *hw_event,pid_t pid,int cpu,int group_fd,unsigned long flags);unsigned char *alloc_buffer (size_t buf_size,int memflush);
tools/testing/selftests/resctrl/resctrl_val.c +1 -3
@@ -664,7 +664,6 @@ int resctrl_val(const struct resctrl_test *test,const char *const *benchmark_cmd, struct resctrl_val_param *param) { - char *resctrl_val = param->resctrl_val; struct sigaction sigact;int ret =0 , pipefd[2 ];char pipe_message =0 ;
@@ -755,8 +754,7 @@ int resctrl_val(const struct resctrl_test *test, goto out;/* Write benchmark to specified control&monitoring grp in resctrl FS */ - ret =write_bm_pid_to_resctrl (bm_pid, param->ctrlgrp, param->mongrp, - resctrl_val); + ret =write_bm_pid_to_resctrl (bm_pid, param->ctrlgrp, param->mongrp);if (ret) goto out;
tools/testing/selftests/resctrl/resctrlfs.c +14 -19
@@ -519,7 +519,6 @@ static int write_pid_to_tasks(char *tasks, pid_t pid)* @bm_pid: PID that should be written * @ctrlgrp: Name of the control monitor group (con_mon grp) * @mongrp: Name of the monitor group (mon grp) -* @resctrl_val: Resctrl feature (Eg: mbm, mba.. etc) * * If a con_mon grp is requested, create it and write pid to it, otherwise * write pid to root con_mon grp.
@@ -529,8 +528,7 @@ static int write_pid_to_tasks(char *tasks, pid_t pid)* * Return: 0 on success, < 0 on error. */ -int write_bm_pid_to_resctrl (pid_t bm_pid,const char *ctrlgrp, -const char *mongrp,const char *resctrl_val) +int write_bm_pid_to_resctrl (pid_t bm_pid,const char *ctrlgrp,const char *mongrp) {char controlgroup[128 ], monitorgroup[512 ], monitorgroup_p[256 ];char tasks[1024 ];
@@ -550,22 +548,19 @@ int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp,if (ret) goto out; -/* Create mon grp and write pid into it for "mbm" and "cmt" test */ -if (!strncmp (resctrl_val,CMT_STR ,sizeof (CMT_STR )) || - !strncmp (resctrl_val,MBM_STR ,sizeof (MBM_STR ))) { -if (mongrp) { -sprintf (monitorgroup_p,"%s/mon_groups" , controlgroup); -sprintf (monitorgroup,"%s/%s" , monitorgroup_p, mongrp); - ret =create_grp (mongrp, monitorgroup, monitorgroup_p); -if (ret) - goto out; - -sprintf (tasks,"%s/mon_groups/%s/tasks" , - controlgroup, mongrp); - ret =write_pid_to_tasks (tasks, bm_pid); -if (ret) - goto out; - } +/* Create monitor group and write pid into if it is used */ +if (mongrp) { +sprintf (monitorgroup_p,"%s/mon_groups" , controlgroup); +sprintf (monitorgroup,"%s/%s" , monitorgroup_p, mongrp); + ret =create_grp (mongrp, monitorgroup, monitorgroup_p); +if (ret) + goto out; + +sprintf (tasks,"%s/mon_groups/%s/tasks" , + controlgroup, mongrp); + ret =write_pid_to_tasks (tasks, bm_pid); +if (ret) + goto out; } out:
Signature · 1 line
2.39.2
Shuah Khan
maintainerQuoted 23 lines · Ilpo Järvinen
Hi all,
This series does a number of cleanups into
resctrl_val()and generalizes it by removing test name specific handling from the function.One of the changes improves MBA/MBM measurement by narrowing down the period the resctrl FS derived memory bandwidth numbers are measured over. My feel is it didn't cause noticeable difference into the numbers because they're generally good anyway except for the small number of outliers. To see the impact on outliers, I'd need to setup a test to run large number of replications and do a statistical analysis, which I've not spent my time on. Even without the statistical analysis, the new way to measure seems obviously better and makes sense even if I cannot see a major improvement with the setup I'm using.
This series has some conflicts with SNC series from Maciej (Maciej has privately agreed to base his series on top of this series) and also with the MBA/MBM series from Babu.
--
i.
Quoted 10 lines
v3:
- Rename init functions to <testname>_init()
- Replace for loops with READ+WRITE statements for clarity
- Don't drop Return: entry fromperf_open_imc_mem_bw()func comment
- New patch: Fix closing of IMC fds in case of error
- New patch: Make "bandwidth" consistent in comments & prints
- New patch: Simplify mem bandwidth file code
- Remove wrong comment
- Changedgrp_namecheck to return -1 on fail (internal sanity check)
I can apply these for Linux 6.10-rc1 once I get an Ack from Reinette.
thanks,
-- Shuah
Reinette Chatre
maintainerHi Shuah and Ilpo,
Quoted 35 lines · Shuah Khan
Quoted 16 lines · Ilpo Järvinen
Hi all,
This series does a number of cleanups into
resctrl_val()and generalizes it by removing test name specific handling from the function.One of the changes improves MBA/MBM measurement by narrowing down the period the resctrl FS derived memory bandwidth numbers are measured over. My feel is it didn't cause noticeable difference into the numbers because they're generally good anyway except for the small number of outliers. To see the impact on outliers, I'd need to setup a test to run large number of replications and do a statistical analysis, which I've not spent my time on. Even without the statistical analysis, the new way to measure seems obviously better and makes sense even if I cannot see a major improvement with the setup I'm using.
Quoted 17 lines
This series has some conflicts with SNC series from Maciej (Maciej has privately agreed to base his series on top of this series) and also with the MBA/MBM series from Babu.
Signature · 11 lines
i. v3: - Rename init functions to <testname>_init() - Replace for loops with READ+WRITE statements for clarity - Don't drop Return: entry from perf_open_imc_mem_bw() func comment - New patch: Fix closing of IMC fds in case of error - New patch: Make "bandwidth" consistent in comments & prints - New patch: Simplify mem bandwidth file code - Remove wrong comment - Changed grp_name check to return -1 on fail (internal sanity check)
Quoted 2 lines
I can apply these for Linux 6.10-rc1 once I get an Ack from Reinette.
Apologies for the delay in reviewing this. I've now provided feedback for consideration.
Reinette