Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Ilpo Järvinen and committed by
Shuah Khan
9224db51 2704b2d1

+13 -20
+13 -20
tools/testing/selftests/resctrl/resctrl_val.c
··· 450 450 * initialize_mem_bw_resctrl: Appropriately populate "mbm_total_path" 451 451 * @ctrlgrp: Name of the control monitor group (con_mon grp) 452 452 * @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) 454 454 * @resctrl_val: Resctrl feature (Eg: mbm, mba.. etc) 455 455 */ 456 456 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) 458 458 { 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 - 466 459 if (!strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR))) 467 460 set_mbm_path(ctrlgrp, mongrp, domain_id); 468 461 ··· 614 621 * initialize_llc_occu_resctrl: Appropriately populate "llc_occup_path" 615 622 * @ctrlgrp: Name of the control monitor group (con_mon grp) 616 623 * @mongrp: Name of the monitor group (mon grp) 617 - * @cpu_no: CPU number that the benchmark PID is binded to 624 + * @domain_id: Domain ID (cache ID; for MB, L3 cache ID) 618 625 * @resctrl_val: Resctrl feature (Eg: cat, cmt.. etc) 619 626 */ 620 627 static void initialize_llc_occu_resctrl(const char *ctrlgrp, const char *mongrp, 621 - int cpu_no, char *resctrl_val) 628 + int domain_id, char *resctrl_val) 622 629 { 623 - int domain_id; 624 - 625 - if (get_domain_id("L3", cpu_no, &domain_id) < 0) { 626 - ksft_print_msg("Could not get domain ID\n"); 627 - return; 628 - } 629 - 630 630 if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) 631 631 set_cmt_path(ctrlgrp, mongrp, domain_id); 632 632 } ··· 751 765 int ret = 0, pipefd[2]; 752 766 char pipe_message = 0; 753 767 union sigval value; 768 + int domain_id; 754 769 755 770 if (strcmp(param->filename, "") == 0) 756 771 sprintf(param->filename, "stdio"); 772 + 773 + ret = get_domain_id(test->resource, uparams->cpu, &domain_id); 774 + if (ret < 0) { 775 + ksft_print_msg("Could not get domain ID\n"); 776 + return ret; 777 + } 757 778 758 779 if (!strncmp(resctrl_val, MBA_STR, sizeof(MBA_STR)) || 759 780 !strncmp(resctrl_val, MBM_STR, sizeof(MBM_STR))) { ··· 856 863 goto out; 857 864 858 865 initialize_mem_bw_resctrl(param->ctrlgrp, param->mongrp, 859 - uparams->cpu, resctrl_val); 866 + domain_id, resctrl_val); 860 867 } else if (!strncmp(resctrl_val, CMT_STR, sizeof(CMT_STR))) 861 868 initialize_llc_occu_resctrl(param->ctrlgrp, param->mongrp, 862 - uparams->cpu, resctrl_val); 869 + domain_id, resctrl_val); 863 870 864 871 /* Parent waits for child to be ready. */ 865 872 close(pipefd[1]);