Skip to content

Commit 711d27b

Browse files
ij-intelshuahkh
authored andcommitted
selftests/resctrl: Simplify mem bandwidth file code for MBA & MBM tests
initialize_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. Suggested-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Tested-by: Babu Moger <babu.moger@amd.com> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent bc074b6 commit 711d27b

2 files changed

Lines changed: 4 additions & 42 deletions

File tree

tools/testing/selftests/resctrl/mbm_test.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ static int mbm_run_test(const struct resctrl_test *test, const struct user_param
115115
struct resctrl_val_param param = {
116116
.resctrl_val = MBM_STR,
117117
.ctrlgrp = "c1",
118-
.mongrp = "m1",
119118
.filename = RESULT_FILE_NAME,
120119
.bw_report = "reads",
121120
.setup = mbm_setup

tools/testing/selftests/resctrl/resctrl_val.c

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,10 @@
1919
#define MAX_TOKENS 5
2020
#define READ 0
2121
#define WRITE 1
22-
#define CON_MON_MBM_LOCAL_BYTES_PATH \
23-
"%s/%s/mon_groups/%s/mon_data/mon_L3_%02d/mbm_local_bytes"
2422

2523
#define CON_MBM_LOCAL_BYTES_PATH \
2624
"%s/%s/mon_data/mon_L3_%02d/mbm_local_bytes"
2725

28-
#define MON_MBM_LOCAL_BYTES_PATH \
29-
"%s/mon_groups/%s/mon_data/mon_L3_%02d/mbm_local_bytes"
30-
31-
#define MBM_LOCAL_BYTES_PATH \
32-
"%s/mon_data/mon_L3_%02d/mbm_local_bytes"
33-
3426
#define CON_MON_LCC_OCCUP_PATH \
3527
"%s/%s/mon_groups/%s/mon_data/mon_L3_%02d/llc_occupancy"
3628

@@ -430,43 +422,15 @@ static int get_mem_bw_imc(char *bw_report, float *bw_imc)
430422
return 0;
431423
}
432424

433-
void set_mbm_path(const char *ctrlgrp, const char *mongrp, int domain_id)
434-
{
435-
if (ctrlgrp && mongrp)
436-
sprintf(mbm_total_path, CON_MON_MBM_LOCAL_BYTES_PATH,
437-
RESCTRL_PATH, ctrlgrp, mongrp, domain_id);
438-
else if (!ctrlgrp && mongrp)
439-
sprintf(mbm_total_path, MON_MBM_LOCAL_BYTES_PATH, RESCTRL_PATH,
440-
mongrp, domain_id);
441-
else if (ctrlgrp && !mongrp)
442-
sprintf(mbm_total_path, CON_MBM_LOCAL_BYTES_PATH, RESCTRL_PATH,
443-
ctrlgrp, domain_id);
444-
else if (!ctrlgrp && !mongrp)
445-
sprintf(mbm_total_path, MBM_LOCAL_BYTES_PATH, RESCTRL_PATH,
446-
domain_id);
447-
}
448-
449425
/*
450426
* initialize_mem_bw_resctrl: Appropriately populate "mbm_total_path"
451427
* @ctrlgrp: Name of the control monitor group (con_mon grp)
452-
* @mongrp: Name of the monitor group (mon grp)
453428
* @domain_id: Domain ID (cache ID; for MB, L3 cache ID)
454-
* @resctrl_val: Resctrl feature (Eg: mbm, mba.. etc)
455429
*/
456-
static void initialize_mem_bw_resctrl(const char *ctrlgrp, const char *mongrp,
457-
int domain_id, char *resctrl_val)
430+
static void initialize_mem_bw_resctrl(const char *ctrlgrp, int domain_id)
458431
{
459-
if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR)))
460-
set_mbm_path(ctrlgrp, mongrp, domain_id);
461-
462-
if (!strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR))) {
463-
if (ctrlgrp)
464-
sprintf(mbm_total_path, CON_MBM_LOCAL_BYTES_PATH,
465-
RESCTRL_PATH, ctrlgrp, domain_id);
466-
else
467-
sprintf(mbm_total_path, MBM_LOCAL_BYTES_PATH,
468-
RESCTRL_PATH, domain_id);
469-
}
432+
sprintf(mbm_total_path, CON_MBM_LOCAL_BYTES_PATH, RESCTRL_PATH,
433+
ctrlgrp, domain_id);
470434
}
471435

472436
/*
@@ -867,8 +831,7 @@ int resctrl_val(const struct resctrl_test *test,
867831
if (ret)
868832
goto out;
869833

870-
initialize_mem_bw_resctrl(param->ctrlgrp, param->mongrp,
871-
domain_id, resctrl_val);
834+
initialize_mem_bw_resctrl(param->ctrlgrp, domain_id);
872835
} else if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR)))
873836
initialize_llc_occu_resctrl(param->ctrlgrp, param->mongrp,
874837
domain_id, resctrl_val);

0 commit comments

Comments
 (0)