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.

tools/power turbostat: Cleanup package_id

The kernel topology sysfs uses the name "physical_package_id"
because it is allowed to be sparse.

Inside Turbostat, that physical package_id namespace is the only
package_id namespace, so re-name it to simply be "package_id"
in cpus[].

Delete the redundant copy of package_id in pkg_data.
Rely instead on the single copy of the truth in cpus[].

No functional change.

Signed-off-by: Len Brown <len.brown@intel.com>

Len Brown 4aaf7d07 54ca69f3

+23 -29
+23 -29
tools/power/x86/turbostat/turbostat.c
··· 2171 2171 long long sam_mc6_ms; 2172 2172 unsigned int sam_mhz; 2173 2173 unsigned int sam_act_mhz; 2174 - unsigned int package_id; 2175 2174 struct rapl_counter energy_pkg; /* MSR_PKG_ENERGY_STATUS */ 2176 2175 struct rapl_counter energy_dram; /* MSR_DRAM_ENERGY_STATUS */ 2177 2176 struct rapl_counter energy_cores; /* MSR_PP0_ENERGY_STATUS */ ··· 2394 2395 } platform_counters_odd, platform_counters_even; 2395 2396 2396 2397 struct cpu_topology { 2397 - int physical_package_id; 2398 + int package_id; 2398 2399 int die_id; 2399 2400 int l3_id; 2400 2401 int logical_cpu_id; ··· 2661 2662 return cpus[cpu].physical_core_id; 2662 2663 2663 2664 case SCOPE_PACKAGE: 2664 - return cpus[cpu].physical_package_id; 2665 + return cpus[cpu].package_id; 2665 2666 } 2666 2667 2667 2668 __builtin_unreachable(); ··· 3198 3199 } 3199 3200 3200 3201 if (p && is_cpu_first_core_in_package(t, p)) { 3201 - outp += sprintf(outp, "package: %d\n", p->package_id); 3202 - 3203 3202 outp += sprintf(outp, "Weighted cores: %016llX\n", p->pkg_wtd_core_c0); 3204 3203 outp += sprintf(outp, "Any cores: %016llX\n", p->pkg_any_core_c0); 3205 3204 outp += sprintf(outp, "Any GFX: %016llX\n", p->pkg_any_gfxe_c0); ··· 3363 3366 } else { 3364 3367 if (DO_BIC(BIC_Package)) { 3365 3368 if (p) 3366 - outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), p->package_id); 3369 + outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), cpus[t->cpu_id].package_id); 3367 3370 else 3368 3371 outp += sprintf(outp, "%s-", (printed++ ? delim : "")); 3369 3372 } ··· 5177 5180 int rapl_core_id; 5178 5181 5179 5182 if (!platform->has_per_core_rapl) 5180 - return cpus[cpu].physical_package_id; 5183 + return cpus[cpu].package_id; 5181 5184 5182 5185 /* Compute the system-wide unique core-id for @cpu */ 5183 5186 rapl_core_id = cpus[cpu].physical_core_id; 5184 - rapl_core_id += cpus[cpu].physical_package_id * nr_cores_per_package; 5187 + rapl_core_id += cpus[cpu].package_id * nr_cores_per_package; 5185 5188 5186 5189 return rapl_core_id; 5187 5190 } ··· 5325 5328 } 5326 5329 5327 5330 if (DO_BIC(BIC_UNCORE_MHZ)) 5328 - p->uncore_mhz = get_legacy_uncore_mhz(p->package_id); 5331 + p->uncore_mhz = get_legacy_uncore_mhz(cpus[t->cpu_id].package_id); 5329 5332 5330 5333 if (DO_BIC(BIC_GFX_rc6)) 5331 5334 p->gfx_rc6_ms = gfx_info[GFX_rc6].val_ull; ··· 5349 5352 char *path = NULL; 5350 5353 5351 5354 if (mp->msr_num == 0) { 5352 - path = find_sysfs_path_by_id(mp->sp, p->package_id); 5355 + path = find_sysfs_path_by_id(mp->sp, cpus[t->cpu_id].package_id); 5353 5356 if (path == NULL) { 5354 - warnx("%s: package_id %d not found", __func__, p->package_id); 5357 + warnx("%s: package_id %d not found", __func__, cpus[t->cpu_id].package_id); 5355 5358 return -10; 5356 5359 } 5357 5360 } ··· 5363 5366 return -10; 5364 5367 5365 5368 for (i = 0, pp = sys.pmt_pp; pp; i++, pp = pp->next) 5366 - p->pmt_counter[i] = pmt_read_counter(pp, p->package_id); 5369 + p->pmt_counter[i] = pmt_read_counter(pp, cpus[t->cpu_id].package_id); 5367 5370 5368 5371 done: 5369 5372 gettimeofday(&t->tv_end, (struct timezone *)NULL); ··· 6047 6050 return cpu == parse_int_file("/sys/devices/system/cpu/cpu%d/topology/core_siblings_list", cpu); 6048 6051 } 6049 6052 6050 - int get_physical_package_id(int cpu) 6053 + int get_package_id(int cpu) 6051 6054 { 6052 6055 return parse_int_file("/sys/devices/system/cpu/cpu%d/topology/physical_package_id", cpu); 6053 6056 } ··· 6080 6083 for (pkg = 0; pkg < topo.num_packages; pkg++) { 6081 6084 lnode = 0; 6082 6085 for (cpu = 0; cpu <= topo.max_cpu_num; ++cpu) { 6083 - if (cpus[cpu].physical_package_id != pkg) 6086 + if (cpus[cpu].package_id != pkg) 6084 6087 continue; 6085 6088 /* find a cpu with an unset logical_node_id */ 6086 6089 if (cpus[cpu].logical_node_id != -1) ··· 6093 6096 * the logical_node_id 6094 6097 */ 6095 6098 for (cpux = cpu; cpux <= topo.max_cpu_num; cpux++) { 6096 - if ((cpus[cpux].physical_package_id == pkg) && (cpus[cpux].physical_node_id == node)) { 6099 + if ((cpus[cpux].package_id == pkg) && (cpus[cpux].physical_node_id == node)) { 6097 6100 cpus[cpux].logical_node_id = lnode; 6098 6101 cpu_count++; 6099 6102 } ··· 7203 7206 } 7204 7207 for (i = uncore_max_id; i >= 0; --i) { 7205 7208 int k, l; 7206 - int package_id, domain_id, cluster_id; 7209 + int unc_pkg_id, domain_id, cluster_id; 7207 7210 char name_buf[16]; 7208 7211 7209 7212 sprintf(path_base, "/sys/devices/system/cpu/intel_uncore_frequency/uncore%02d", i); ··· 7212 7215 err(1, "%s: %s", __func__, path_base); 7213 7216 7214 7217 sprintf(path, "%s/package_id", path_base); 7215 - package_id = read_sysfs_int(path); 7218 + unc_pkg_id = read_sysfs_int(path); 7216 7219 7217 7220 sprintf(path, "%s/domain_id", path_base); 7218 7221 domain_id = read_sysfs_int(path); ··· 7235 7238 */ 7236 7239 if BIC_IS_ENABLED 7237 7240 (BIC_UNCORE_MHZ) 7238 - add_counter(0, path, name_buf, 0, SCOPE_PACKAGE, COUNTER_K2M, FORMAT_AVERAGE, 0, package_id); 7241 + add_counter(0, path, name_buf, 0, SCOPE_PACKAGE, COUNTER_K2M, FORMAT_AVERAGE, 0, unc_pkg_id); 7239 7242 7240 7243 if (quiet) 7241 7244 continue; ··· 7244 7247 k = read_sysfs_int(path); 7245 7248 sprintf(path, "%s/max_freq_khz", path_base); 7246 7249 l = read_sysfs_int(path); 7247 - fprintf(outf, "Uncore Frequency package%d domain%d cluster%d: %d - %d MHz ", package_id, domain_id, cluster_id, k / 1000, l / 1000); 7250 + fprintf(outf, "Uncore Frequency package%d domain%d cluster%d: %d - %d MHz ", unc_pkg_id, domain_id, cluster_id, k / 1000, l / 1000); 7248 7251 7249 7252 sprintf(path, "%s/initial_min_freq_khz", path_base); 7250 7253 k = read_sysfs_int(path); ··· 8949 8952 continue; 8950 8953 8951 8954 const int core_id = cpus[cpu].physical_core_id; 8952 - const int pkg_id = cpus[cpu].physical_package_id; 8955 + const int pkg_id = cpus[cpu].package_id; 8953 8956 8954 8957 assert(core_id < cores_visited_elems); 8955 8958 assert(pkg_id < pkg_visited_elems); ··· 9609 9612 cpus[i].logical_cpu_id = i; 9610 9613 9611 9614 /* get package information */ 9612 - cpus[i].physical_package_id = get_physical_package_id(i); 9613 - if (cpus[i].physical_package_id > max_package_id) 9614 - max_package_id = cpus[i].physical_package_id; 9615 + cpus[i].package_id = get_package_id(i); 9616 + if (cpus[i].package_id > max_package_id) 9617 + max_package_id = cpus[i].package_id; 9615 9618 9616 9619 /* get die information */ 9617 9620 cpus[i].die_id = get_die_id(i); ··· 9682 9685 continue; 9683 9686 fprintf(outf, 9684 9687 "cpu %d pkg %d die %d l3 %d node %d lnode %d core %d thread %d\n", 9685 - i, cpus[i].physical_package_id, cpus[i].die_id, cpus[i].l3_id, 9688 + i, cpus[i].package_id, cpus[i].die_id, cpus[i].l3_id, 9686 9689 cpus[i].physical_node_id, cpus[i].logical_node_id, cpus[i].physical_core_id, cpus[i].thread_id); 9687 9690 } 9688 9691 ··· 9714 9717 if (*p == NULL) 9715 9718 goto error; 9716 9719 9717 - for (i = 0; i < topo.num_packages; i++) { 9718 - (*p)[i].package_id = i; 9720 + for (i = 0; i < topo.num_packages; i++) 9719 9721 (*p)[i].first_cpu = -1; 9720 - } 9721 9722 9722 9723 return; 9723 9724 error: ··· 9729 9734 */ 9730 9735 void init_counter(struct thread_data *thread_base, struct core_data *core_base, struct pkg_data *pkg_base, int cpu_id) 9731 9736 { 9732 - int pkg_id = cpus[cpu_id].physical_package_id; 9737 + int pkg_id = cpus[cpu_id].package_id; 9733 9738 int node_id = cpus[cpu_id].logical_node_id; 9734 9739 int core_id = cpus[cpu_id].physical_core_id; 9735 9740 int thread_id = cpus[cpu_id].thread_id; ··· 9755 9760 } 9756 9761 9757 9762 c->core_id = core_id; 9758 - pkg_base[pkg_id].package_id = pkg_id; 9759 9763 } 9760 9764 9761 9765 int initialize_counters(int cpu_id)