Skip to content

Commit 48f07b0

Browse files
captain5050acmel
authored andcommitted
perf cputopo: Update to use pakage_cpus
core_siblings_list is the deprecated topology name for package_cpus_list, update the code to try the non-deprecated path first. Adjust variable names to match topology name. Signed-off-by: Ian Rogers <[email protected]> Acked-by: Jiri Olsa <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: John Garry <[email protected]> Cc: Kajol Jain <[email protected]> Cc: Kan Liang <[email protected]> Cc: Madhavan Srinivasan <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Paul A . Clarke <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Riccardo Mancini <[email protected]> Cc: Song Liu <[email protected]> Cc: Wan Jiabing <[email protected]> Cc: Yury Norov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 604ce2f commit 48f07b0

File tree

3 files changed

+28
-15
lines changed

3 files changed

+28
-15
lines changed

tools/perf/util/cputopo.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
#include "env.h"
1515
#include "pmu-hybrid.h"
1616

17-
#define CORE_SIB_FMT \
17+
#define PACKAGE_CPUS_FMT \
18+
"%s/devices/system/cpu/cpu%d/topology/package_cpus_list"
19+
#define PACKAGE_CPUS_FMT_OLD \
1820
"%s/devices/system/cpu/cpu%d/topology/core_siblings_list"
1921
#define DIE_SIB_FMT \
2022
"%s/devices/system/cpu/cpu%d/topology/die_cpus_list"
@@ -39,8 +41,12 @@ static int build_cpu_topology(struct cpu_topology *tp, int cpu)
3941
u32 i = 0;
4042
int ret = -1;
4143

42-
scnprintf(filename, MAXPATHLEN, CORE_SIB_FMT,
44+
scnprintf(filename, MAXPATHLEN, PACKAGE_CPUS_FMT,
4345
sysfs__mountpoint(), cpu);
46+
if (access(filename, F_OK) == -1) {
47+
scnprintf(filename, MAXPATHLEN, PACKAGE_CPUS_FMT_OLD,
48+
sysfs__mountpoint(), cpu);
49+
}
4450
fp = fopen(filename, "r");
4551
if (!fp)
4652
goto try_dies;
@@ -54,13 +60,13 @@ static int build_cpu_topology(struct cpu_topology *tp, int cpu)
5460
if (p)
5561
*p = '\0';
5662

57-
for (i = 0; i < tp->core_sib; i++) {
58-
if (!strcmp(buf, tp->core_siblings[i]))
63+
for (i = 0; i < tp->package_cpus_lists; i++) {
64+
if (!strcmp(buf, tp->package_cpus_list[i]))
5965
break;
6066
}
61-
if (i == tp->core_sib) {
62-
tp->core_siblings[i] = buf;
63-
tp->core_sib++;
67+
if (i == tp->package_cpus_lists) {
68+
tp->package_cpus_list[i] = buf;
69+
tp->package_cpus_lists++;
6470
buf = NULL;
6571
len = 0;
6672
}
@@ -139,8 +145,8 @@ void cpu_topology__delete(struct cpu_topology *tp)
139145
if (!tp)
140146
return;
141147

142-
for (i = 0 ; i < tp->core_sib; i++)
143-
zfree(&tp->core_siblings[i]);
148+
for (i = 0 ; i < tp->package_cpus_lists; i++)
149+
zfree(&tp->package_cpus_list[i]);
144150

145151
if (tp->die_sib) {
146152
for (i = 0 ; i < tp->die_sib; i++)
@@ -205,7 +211,7 @@ struct cpu_topology *cpu_topology__new(void)
205211

206212
tp = addr;
207213
addr += sizeof(*tp);
208-
tp->core_siblings = addr;
214+
tp->package_cpus_list = addr;
209215
addr += sz;
210216
if (has_die) {
211217
tp->die_siblings = addr;

tools/perf/util/cputopo.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@
55
#include <linux/types.h>
66

77
struct cpu_topology {
8-
u32 core_sib;
8+
/* The number of unique package_cpus_lists below. */
9+
u32 package_cpus_lists;
910
u32 die_sib;
1011
u32 thread_sib;
11-
char **core_siblings;
12+
/*
13+
* An array of strings where each string is unique and read from
14+
* /sys/devices/system/cpu/cpuX/topology/package_cpus_list. From the ABI
15+
* each of these is a human-readable list of CPUs sharing the same
16+
* physical_package_id. The format is like 0-3, 8-11, 14,17.
17+
*/
18+
const char **package_cpus_list;
1219
char **die_siblings;
1320
char **thread_siblings;
1421
};

tools/perf/util/header.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -583,12 +583,12 @@ static int write_cpu_topology(struct feat_fd *ff,
583583
if (!tp)
584584
return -1;
585585

586-
ret = do_write(ff, &tp->core_sib, sizeof(tp->core_sib));
586+
ret = do_write(ff, &tp->package_cpus_lists, sizeof(tp->package_cpus_lists));
587587
if (ret < 0)
588588
goto done;
589589

590-
for (i = 0; i < tp->core_sib; i++) {
591-
ret = do_write_string(ff, tp->core_siblings[i]);
590+
for (i = 0; i < tp->package_cpus_lists; i++) {
591+
ret = do_write_string(ff, tp->package_cpus_list[i]);
592592
if (ret < 0)
593593
goto done;
594594
}

0 commit comments

Comments
 (0)