2323#define CON_MBM_LOCAL_BYTES_PATH \
2424 "%s/%s/mon_data/mon_L3_%02d/mbm_local_bytes"
2525
26- #define CON_MON_LCC_OCCUP_PATH \
27- "%s/%s/mon_groups/%s/mon_data/mon_L3_%02d/llc_occupancy"
28-
29- #define CON_LCC_OCCUP_PATH \
30- "%s/%s/mon_data/mon_L3_%02d/llc_occupancy"
31-
32- #define MON_LCC_OCCUP_PATH \
33- "%s/mon_groups/%s/mon_data/mon_L3_%02d/llc_occupancy"
34-
35- #define LCC_OCCUP_PATH \
36- "%s/mon_data/mon_L3_%02d/llc_occupancy"
37-
3826struct membw_read_format {
3927 __u64 value ; /* The value of the event */
4028 __u64 time_enabled ; /* if PERF_FORMAT_TOTAL_TIME_ENABLED */
@@ -268,7 +256,7 @@ static int num_of_imcs(void)
268256 return count ;
269257}
270258
271- static int initialize_mem_bw_imc (void )
259+ int initialize_mem_bw_imc (void )
272260{
273261 int imc , j ;
274262
@@ -424,24 +412,18 @@ static int get_mem_bw_imc(char *bw_report, float *bw_imc)
424412
425413/*
426414 * initialize_mem_bw_resctrl: Appropriately populate "mbm_total_path"
427- * @ctrlgrp: Name of the control monitor group (con_mon grp )
428- * @domain_id: Domain ID (cache ID; for MB, L3 cache ID)
415+ * @param: Parameters passed to resctrl_val( )
416+ * @domain_id: Domain ID (cache ID; for MB, L3 cache ID)
429417 */
430- static void initialize_mem_bw_resctrl (const char * ctrlgrp , int domain_id )
418+ void initialize_mem_bw_resctrl (const struct resctrl_val_param * param ,
419+ int domain_id )
431420{
432421 sprintf (mbm_total_path , CON_MBM_LOCAL_BYTES_PATH , RESCTRL_PATH ,
433- ctrlgrp , domain_id );
422+ param -> ctrlgrp , domain_id );
434423}
435424
436425/*
437- * Get MBM Local bytes as reported by resctrl FS
438- * For MBM,
439- * 1. If con_mon grp and mon grp are given, then read from con_mon grp's mon grp
440- * 2. If only con_mon grp is given, then read from con_mon grp
441- * 3. If both are not given, then read from root con_mon grp
442- * For MBA,
443- * 1. If con_mon grp is given, then read from it
444- * 2. If con_mon grp is not given, then read from root con_mon grp
426+ * Open file to read MBM local bytes from resctrl FS
445427 */
446428static FILE * open_mem_bw_resctrl (const char * mbm_bw_file )
447429{
@@ -454,6 +436,9 @@ static FILE *open_mem_bw_resctrl(const char *mbm_bw_file)
454436 return fp ;
455437}
456438
439+ /*
440+ * Get MBM Local bytes as reported by resctrl FS
441+ */
457442static int get_mem_bw_resctrl (FILE * fp , unsigned long * mbm_total )
458443{
459444 if (fscanf (fp , "%lu\n" , mbm_total ) <= 0 ) {
@@ -566,35 +551,6 @@ static int print_results_bw(char *filename, pid_t bm_pid, float bw_imc,
566551 return 0 ;
567552}
568553
569- static void set_cmt_path (const char * ctrlgrp , const char * mongrp , char sock_num )
570- {
571- if (strlen (ctrlgrp ) && strlen (mongrp ))
572- sprintf (llc_occup_path , CON_MON_LCC_OCCUP_PATH , RESCTRL_PATH ,
573- ctrlgrp , mongrp , sock_num );
574- else if (!strlen (ctrlgrp ) && strlen (mongrp ))
575- sprintf (llc_occup_path , MON_LCC_OCCUP_PATH , RESCTRL_PATH ,
576- mongrp , sock_num );
577- else if (strlen (ctrlgrp ) && !strlen (mongrp ))
578- sprintf (llc_occup_path , CON_LCC_OCCUP_PATH , RESCTRL_PATH ,
579- ctrlgrp , sock_num );
580- else if (!strlen (ctrlgrp ) && !strlen (mongrp ))
581- sprintf (llc_occup_path , LCC_OCCUP_PATH , RESCTRL_PATH , sock_num );
582- }
583-
584- /*
585- * initialize_llc_occu_resctrl: Appropriately populate "llc_occup_path"
586- * @ctrlgrp: Name of the control monitor group (con_mon grp)
587- * @mongrp: Name of the monitor group (mon grp)
588- * @domain_id: Domain ID (cache ID; for MB, L3 cache ID)
589- * @resctrl_val: Resctrl feature (Eg: cat, cmt.. etc)
590- */
591- static void initialize_llc_occu_resctrl (const char * ctrlgrp , const char * mongrp ,
592- int domain_id , char * resctrl_val )
593- {
594- if (!strncmp (resctrl_val , CMT_STR , sizeof (CMT_STR )))
595- set_cmt_path (ctrlgrp , mongrp , domain_id );
596- }
597-
598554/*
599555 * measure_mem_bw - Measures memory bandwidth numbers while benchmark runs
600556 * @uparams: User supplied parameters
@@ -825,16 +781,11 @@ int resctrl_val(const struct resctrl_test *test,
825781 if (ret )
826782 goto out ;
827783
828- if (!strncmp (resctrl_val , MBM_STR , sizeof (MBM_STR )) ||
829- !strncmp (resctrl_val , MBA_STR , sizeof (MBA_STR ))) {
830- ret = initialize_mem_bw_imc ();
784+ if (param -> init ) {
785+ ret = param -> init (param , domain_id );
831786 if (ret )
832787 goto out ;
833-
834- initialize_mem_bw_resctrl (param -> ctrlgrp , domain_id );
835- } else if (!strncmp (resctrl_val , CMT_STR , sizeof (CMT_STR )))
836- initialize_llc_occu_resctrl (param -> ctrlgrp , param -> mongrp ,
837- domain_id , resctrl_val );
788+ }
838789
839790 /* Parent waits for child to be ready. */
840791 close (pipefd [1 ]);
0 commit comments