From 56d6469291f8b1e1ab2f78e401c564163d3ee0f0 Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Sat, 20 Aug 2022 23:58:21 +0800 Subject: [PATCH] tools/power/x86/intel-speed-select: Cleanup get_physical_id usage struct isst_id already contains package and die id information, thus there is no need to get the package and die id information, when struct isst_id is already available. Remove unneeded get_physical_package_id/get_physical_die_id usage. Signed-off-by: Zhang Rui Signed-off-by: Srinivas Pandruvada --- tools/power/x86/intel-speed-select/isst-config.c | 68 +++++++++-------------- tools/power/x86/intel-speed-select/isst-core.c | 8 +-- tools/power/x86/intel-speed-select/isst-daemon.c | 18 +++--- tools/power/x86/intel-speed-select/isst-display.c | 17 ++---- 4 files changed, 43 insertions(+), 68 deletions(-) diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index 355d81d..c65b764 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -677,11 +677,8 @@ void set_cpu_mask_from_punit_coremask(struct isst_id *id, unsigned long long cor cpu_set_t *core_cpumask, int *cpu_cnt) { int i, cnt = 0; - int die_id, pkg_id; *cpu_cnt = 0; - die_id = get_physical_die_id(id->cpu); - pkg_id = get_physical_package_id(id->cpu); for (i = 0; i < 64; ++i) { if (core_mask & BIT_ULL(i)) { @@ -691,8 +688,8 @@ void set_cpu_mask_from_punit_coremask(struct isst_id *id, unsigned long long cor if (!CPU_ISSET_S(j, present_cpumask_size, present_cpumask)) continue; - if (cpu_map[j].pkg_id == pkg_id && - cpu_map[j].die_id == die_id && + if (cpu_map[j].pkg_id == id->pkg && + cpu_map[j].die_id == id->die && cpu_map[j].punit_cpu_core == i) { CPU_SET_S(j, core_cpumask_size, core_cpumask); @@ -1106,7 +1103,7 @@ static int clx_n_get_base_ratio(void) static int clx_n_config(struct isst_id *id) { - int i, ret, pkg_id, die_id; + int i, ret; unsigned long cpu_bf; struct isst_pkg_ctdp_level_info *ctdp_level; struct isst_pbf_info *pbf_info; @@ -1128,15 +1125,12 @@ static int clx_n_config(struct isst_id *id) pbf_info->p1_high = 0; pbf_info->p1_low = ~0; - pkg_id = get_physical_package_id(id->cpu); - die_id = get_physical_die_id(id->cpu); - for (i = 0; i < topo_max_cpus; i++) { if (!CPU_ISSET_S(i, present_cpumask_size, present_cpumask)) continue; - if (pkg_id != get_physical_package_id(i) || - die_id != get_physical_die_id(i)) + if (id->pkg != get_physical_package_id(i) || + id->die != get_physical_die_id(i)) continue; CPU_SET_S(i, ctdp_level->core_cpumask_size, @@ -1173,8 +1167,8 @@ static int clx_n_config(struct isst_id *id) if (!CPU_ISSET_S(i, present_cpumask_size, present_cpumask)) continue; - if (pkg_id != get_physical_package_id(i) || - die_id != get_physical_die_id(i)) + if (id->pkg != get_physical_package_id(i) || + id->die != get_physical_die_id(i)) continue; cpu_bf = parse_int_file(1, @@ -1291,8 +1285,6 @@ static void set_tdp_level_for_cpu(struct isst_id *id, void *arg1, void *arg2, vo ret); if (force_online_offline) { struct isst_pkg_ctdp_level_info ctdp_level; - int pkg_id = get_physical_package_id(id->cpu); - int die_id = get_physical_die_id(id->cpu); /* Wait for updated base frequencies */ usleep(2000); @@ -1308,7 +1300,7 @@ static void set_tdp_level_for_cpu(struct isst_id *id, void *arg1, void *arg2, vo if (ctdp_level.cpu_count) { int i, max_cpus = get_topo_max_cpus(); for (i = 0; i < max_cpus; ++i) { - if (pkg_id != get_physical_package_id(i) || die_id != get_physical_die_id(i)) + if (id->pkg != get_physical_package_id(i) || id->die != get_physical_die_id(i)) continue; if (CPU_ISSET_S(i, ctdp_level.core_cpumask_size, ctdp_level.core_cpumask)) { fprintf(stderr, "online cpu %d\n", i); @@ -1500,7 +1492,7 @@ static int set_clx_pbf_cpufreq_scaling_min_max(struct isst_id *id) { struct isst_pkg_ctdp_level_info *ctdp_level; struct isst_pbf_info *pbf_info; - int i, pkg_id, die_id, freq, freq_high, freq_low; + int i, freq, freq_high, freq_low; int ret; ret = clx_n_config(id); @@ -1514,11 +1506,9 @@ static int set_clx_pbf_cpufreq_scaling_min_max(struct isst_id *id) freq_high = pbf_info->p1_high * 100000; freq_low = pbf_info->p1_low * 100000; - pkg_id = get_physical_package_id(id->cpu); - die_id = get_physical_die_id(id->cpu); for (i = 0; i < get_topo_max_cpus(); ++i) { - if (pkg_id != get_physical_package_id(i) || - die_id != get_physical_die_id(i)) + if (id->pkg != get_physical_package_id(i) || + id->die != get_physical_die_id(i)) continue; if (CPU_ISSET_S(i, pbf_info->core_cpumask_size, @@ -1583,13 +1573,11 @@ static int set_cpufreq_scaling_min_max_from_cpuinfo(int cpu, int cpuinfo_max, in static void set_scaling_min_to_cpuinfo_max(struct isst_id *id) { - int i, pkg_id, die_id; + int i; - pkg_id = get_physical_package_id(id->cpu); - die_id = get_physical_die_id(id->cpu); for (i = 0; i < get_topo_max_cpus(); ++i) { - if (pkg_id != get_physical_package_id(i) || - die_id != get_physical_die_id(i)) + if (id->pkg != get_physical_package_id(i) || + id->die != get_physical_die_id(i)) continue; adjust_scaling_max_from_base_freq(i); @@ -1600,13 +1588,11 @@ static void set_scaling_min_to_cpuinfo_max(struct isst_id *id) static void set_scaling_min_to_cpuinfo_min(struct isst_id *id) { - int i, pkg_id, die_id; + int i; - pkg_id = get_physical_package_id(id->cpu); - die_id = get_physical_die_id(id->cpu); for (i = 0; i < get_topo_max_cpus(); ++i) { - if (pkg_id != get_physical_package_id(i) || - die_id != get_physical_die_id(i)) + if (id->pkg != get_physical_package_id(i) || + id->die != get_physical_die_id(i)) continue; adjust_scaling_max_from_base_freq(i); @@ -1616,13 +1602,11 @@ static void set_scaling_min_to_cpuinfo_min(struct isst_id *id) static void set_scaling_max_to_cpuinfo_max(struct isst_id *id) { - int i, pkg_id, die_id; + int i; - pkg_id = get_physical_package_id(id->cpu); - die_id = get_physical_die_id(id->cpu); for (i = 0; i < get_topo_max_cpus(); ++i) { - if (pkg_id != get_physical_package_id(i) || - die_id != get_physical_die_id(i)) + if (id->pkg != get_physical_package_id(i) || + id->die != get_physical_die_id(i)) continue; set_cpufreq_scaling_min_max_from_cpuinfo(i, 1, 1); @@ -1633,7 +1617,7 @@ static int set_core_priority_and_min(struct isst_id *id, int mask_size, cpu_set_t *cpu_mask, int min_high, int min_low) { - int pkg_id, die_id, ret, i; + int ret, i; if (!CPU_COUNT_S(mask_size, cpu_mask)) return -1; @@ -1654,14 +1638,12 @@ static int set_core_priority_and_min(struct isst_id *id, int mask_size, if (ret) return ret; - pkg_id = get_physical_package_id(id->cpu); - die_id = get_physical_die_id(id->cpu); for (i = 0; i < get_topo_max_cpus(); ++i) { int clos; struct isst_id tid; - if (pkg_id != get_physical_package_id(i) || - die_id != get_physical_die_id(i)) + if (id->pkg != get_physical_package_id(i) || + id->die != get_physical_die_id(i)) continue; if (CPU_ISSET_S(i, mask_size, cpu_mask)) @@ -2206,8 +2188,8 @@ static void set_clos_config_for_cpu(struct isst_id *id, void *arg1, void *arg2, struct isst_clos_config clos_config; int ret; - clos_config.pkg_id = get_physical_package_id(id->cpu); - clos_config.die_id = get_physical_die_id(id->cpu); + clos_config.pkg_id = id->pkg; + clos_config.die_id = id->die; clos_config.epp = clos_epp; clos_config.clos_prop_prio = clos_prop_prio; diff --git a/tools/power/x86/intel-speed-select/isst-core.c b/tools/power/x86/intel-speed-select/isst-core.c index 86eeea8..91a6c57 100644 --- a/tools/power/x86/intel-speed-select/isst-core.c +++ b/tools/power/x86/intel-speed-select/isst-core.c @@ -782,8 +782,8 @@ int isst_get_process_ctdp(struct isst_id *id, int tdp_level, struct isst_pkg_ctd ctdp_level->level = i; ctdp_level->control_cpu = id->cpu; - ctdp_level->pkg_id = get_physical_package_id(id->cpu); - ctdp_level->die_id = get_physical_die_id(id->cpu); + ctdp_level->pkg_id = id->pkg; + ctdp_level->die_id = id->die; ret = isst_get_ctdp_control(id, i, ctdp_level); if (ret) @@ -971,8 +971,8 @@ int isst_pm_get_clos(struct isst_id *id, int clos, struct isst_clos_config *clos if (ret) return ret; - clos_config->pkg_id = get_physical_package_id(id->cpu); - clos_config->die_id = get_physical_die_id(id->cpu); + clos_config->pkg_id = id->pkg; + clos_config->die_id = id->die; clos_config->epp = resp & 0x0f; clos_config->clos_prop_prio = (resp >> 4) & 0x0f; diff --git a/tools/power/x86/intel-speed-select/isst-daemon.c b/tools/power/x86/intel-speed-select/isst-daemon.c index 9bfe4e4..4826625 100644 --- a/tools/power/x86/intel-speed-select/isst-daemon.c +++ b/tools/power/x86/intel-speed-select/isst-daemon.c @@ -35,22 +35,20 @@ static void init_levels(void) void process_level_change(struct isst_id *id) { struct isst_pkg_ctdp_level_info ctdp_level; - int pkg_id = get_physical_package_id(id->cpu); - int die_id = get_physical_die_id(id->cpu); struct isst_pkg_ctdp pkg_dev; time_t tm; int ret; - if (pkg_id >= MAX_PACKAGE_COUNT || die_id >= MAX_DIE_PER_PACKAGE) { + if (id->pkg >= MAX_PACKAGE_COUNT || id->die >= MAX_DIE_PER_PACKAGE) { debug_printf("Invalid package/die info for cpu:%d\n", id->cpu); return; } tm = time(NULL); - if (tm - per_package_levels_tm[pkg_id][die_id] < 2 ) + if (tm - per_package_levels_tm[id->pkg][id->die] < 2) return; - per_package_levels_tm[pkg_id][die_id] = tm; + per_package_levels_tm[id->pkg][id->die] = tm; ret = isst_get_ctdp_levels(id, &pkg_dev); if (ret) { @@ -59,21 +57,21 @@ void process_level_change(struct isst_id *id) } debug_printf("Get Config level %d pkg:%d die:%d current_level:%d\n", id->cpu, - pkg_id, die_id, pkg_dev.current_level); + id->pkg, id->die, pkg_dev.current_level); if (pkg_dev.locked) { debug_printf("config TDP s locked \n"); return; } - if (per_package_levels_info[pkg_id][die_id] == pkg_dev.current_level) + if (per_package_levels_info[id->pkg][id->die] == pkg_dev.current_level) return; debug_printf("**Config level change for cpu:%d pkg:%d die:%d from %d to %d\n", - id->cpu, pkg_id, die_id, per_package_levels_info[pkg_id][die_id], + id->cpu, id->pkg, id->die, per_package_levels_info[id->pkg][id->die], pkg_dev.current_level); - per_package_levels_info[pkg_id][die_id] = pkg_dev.current_level; + per_package_levels_info[id->pkg][id->die] = pkg_dev.current_level; ctdp_level.core_cpumask_size = alloc_cpu_set(&ctdp_level.core_cpumask); @@ -87,7 +85,7 @@ void process_level_change(struct isst_id *id) if (ctdp_level.cpu_count) { int i, max_cpus = get_topo_max_cpus(); for (i = 0; i < max_cpus; ++i) { - if (pkg_id != get_physical_package_id(i) || die_id != get_physical_die_id(i)) + if (id->pkg != get_physical_package_id(i) || id->die != get_physical_die_id(i)) continue; if (CPU_ISSET_S(i, ctdp_level.core_cpumask_size, ctdp_level.core_cpumask)) { fprintf(stderr, "online cpu %d\n", i); diff --git a/tools/power/x86/intel-speed-select/isst-display.c b/tools/power/x86/intel-speed-select/isst-display.c index 2b282ee..b19f57d 100644 --- a/tools/power/x86/intel-speed-select/isst-display.c +++ b/tools/power/x86/intel-speed-select/isst-display.c @@ -172,15 +172,13 @@ static int print_package_info(struct isst_id *id, FILE *outf) if (out_format_is_json()) { snprintf(header, sizeof(header), "package-%d:die-%d:cpu-%d", - get_physical_package_id(id->cpu), get_physical_die_id(id->cpu), - id->cpu); + id->pkg, id->die, id->cpu); format_and_print(outf, 1, header, NULL); return 1; } - snprintf(header, sizeof(header), "package-%d", - get_physical_package_id(id->cpu)); + snprintf(header, sizeof(header), "package-%d", id->pkg); format_and_print(outf, 1, header, NULL); - snprintf(header, sizeof(header), "die-%d", get_physical_die_id(id->cpu)); + snprintf(header, sizeof(header), "die-%d", id->die); format_and_print(outf, 2, header, NULL); snprintf(header, sizeof(header), "cpu-%d", id->cpu); format_and_print(outf, 3, header, NULL); @@ -328,15 +326,12 @@ void isst_ctdp_display_core_info(struct isst_id *id, FILE *outf, char *prefix, if (out_format_is_json()) { snprintf(header, sizeof(header), "package-%d:die-%d:cpu-%d", - get_physical_package_id(id->cpu), get_physical_die_id(id->cpu), - id->cpu); + id->pkg, id->die, id->cpu); format_and_print(outf, level++, header, NULL); } else { - snprintf(header, sizeof(header), "package-%d", - get_physical_package_id(id->cpu)); + snprintf(header, sizeof(header), "package-%d", id->pkg); format_and_print(outf, level++, header, NULL); - snprintf(header, sizeof(header), "die-%d", - get_physical_die_id(id->cpu)); + snprintf(header, sizeof(header), "die-%d", id->die); format_and_print(outf, level++, header, NULL); snprintf(header, sizeof(header), "cpu-%d", id->cpu); format_and_print(outf, level++, header, NULL); -- 2.7.4