Skip to content

Commit 9224db5

Browse files
ij-intelshuahkh
authored andcommitted
selftests/resctrl: Consolidate get_domain_id() into resctrl_val()
Both 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(). 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 2704b2d commit 9224db5

1 file changed

Lines changed: 13 additions & 20 deletions

File tree

tools/testing/selftests/resctrl/resctrl_val.c

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -450,19 +450,12 @@ void set_mbm_path(const char *ctrlgrp, const char *mongrp, int domain_id)
450450
* initialize_mem_bw_resctrl: Appropriately populate "mbm_total_path"
451451
* @ctrlgrp: Name of the control monitor group (con_mon grp)
452452
* @mongrp: Name of the monitor group (mon grp)
453-
* @cpu_no: CPU number that the benchmark PID is binded to
453+
* @domain_id: Domain ID (cache ID; for MB, L3 cache ID)
454454
* @resctrl_val: Resctrl feature (Eg: mbm, mba.. etc)
455455
*/
456456
static void initialize_mem_bw_resctrl(const char *ctrlgrp, const char *mongrp,
457-
int cpu_no, char *resctrl_val)
457+
int domain_id, char *resctrl_val)
458458
{
459-
int domain_id;
460-
461-
if (get_domain_id("MB", cpu_no, &domain_id) < 0) {
462-
ksft_print_msg("Could not get domain ID\n");
463-
return;
464-
}
465-
466459
if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR)))
467460
set_mbm_path(ctrlgrp, mongrp, domain_id);
468461

@@ -621,19 +614,12 @@ static void set_cmt_path(const char *ctrlgrp, const char *mongrp, char sock_num)
621614
* initialize_llc_occu_resctrl: Appropriately populate "llc_occup_path"
622615
* @ctrlgrp: Name of the control monitor group (con_mon grp)
623616
* @mongrp: Name of the monitor group (mon grp)
624-
* @cpu_no: CPU number that the benchmark PID is binded to
617+
* @domain_id: Domain ID (cache ID; for MB, L3 cache ID)
625618
* @resctrl_val: Resctrl feature (Eg: cat, cmt.. etc)
626619
*/
627620
static void initialize_llc_occu_resctrl(const char *ctrlgrp, const char *mongrp,
628-
int cpu_no, char *resctrl_val)
621+
int domain_id, char *resctrl_val)
629622
{
630-
int domain_id;
631-
632-
if (get_domain_id("L3", cpu_no, &domain_id) < 0) {
633-
ksft_print_msg("Could not get domain ID\n");
634-
return;
635-
}
636-
637623
if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR)))
638624
set_cmt_path(ctrlgrp, mongrp, domain_id);
639625
}
@@ -765,10 +751,17 @@ int resctrl_val(const struct resctrl_test *test,
765751
int ret = 0, pipefd[2];
766752
char pipe_message = 0;
767753
union sigval value;
754+
int domain_id;
768755

769756
if (strcmp(param->filename, "") == 0)
770757
sprintf(param->filename, "stdio");
771758

759+
ret = get_domain_id(test->resource, uparams->cpu, &domain_id);
760+
if (ret < 0) {
761+
ksft_print_msg("Could not get domain ID\n");
762+
return ret;
763+
}
764+
772765
if (!strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR)) ||
773766
!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR))) {
774767
ret = validate_bw_report_request(param->bw_report);
@@ -863,10 +856,10 @@ int resctrl_val(const struct resctrl_test *test,
863856
goto out;
864857

865858
initialize_mem_bw_resctrl(param->ctrlgrp, param->mongrp,
866-
uparams->cpu, resctrl_val);
859+
domain_id, resctrl_val);
867860
} else if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR)))
868861
initialize_llc_occu_resctrl(param->ctrlgrp, param->mongrp,
869-
uparams->cpu, resctrl_val);
862+
domain_id, resctrl_val);
870863

871864
/* Parent waits for child to be ready. */
872865
close(pipefd[1]);

0 commit comments

Comments
 (0)