Skip to content

Commit 0b6b84c

Browse files
captain5050acmel
authored andcommitted
perf cputopo: Match thread_siblings to topology ABI name
The topology name for thread_siblings is core_cpus_list, use this for consistency and add documentation. 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 406018d commit 0b6b84c

File tree

3 files changed

+25
-18
lines changed

3 files changed

+25
-18
lines changed

tools/perf/util/cputopo.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
"%s/devices/system/cpu/cpu%d/topology/core_siblings_list"
2121
#define DIE_CPUS_FMT \
2222
"%s/devices/system/cpu/cpu%d/topology/die_cpus_list"
23-
#define THRD_SIB_FMT \
24-
"%s/devices/system/cpu/cpu%d/topology/thread_siblings_list"
25-
#define THRD_SIB_FMT_NEW \
23+
#define CORE_CPUS_FMT \
2624
"%s/devices/system/cpu/cpu%d/topology/core_cpus_list"
25+
#define CORE_CPUS_FMT_OLD \
26+
"%s/devices/system/cpu/cpu%d/topology/thread_siblings_list"
2727
#define NODE_ONLINE_FMT \
2828
"%s/devices/system/node/online"
2929
#define NODE_MEMINFO_FMT \
@@ -104,10 +104,10 @@ static int build_cpu_topology(struct cpu_topology *tp, int cpu)
104104
ret = 0;
105105

106106
try_threads:
107-
scnprintf(filename, MAXPATHLEN, THRD_SIB_FMT_NEW,
107+
scnprintf(filename, MAXPATHLEN, CORE_CPUS_FMT,
108108
sysfs__mountpoint(), cpu);
109109
if (access(filename, F_OK) == -1) {
110-
scnprintf(filename, MAXPATHLEN, THRD_SIB_FMT,
110+
scnprintf(filename, MAXPATHLEN, CORE_CPUS_FMT_OLD,
111111
sysfs__mountpoint(), cpu);
112112
}
113113
fp = fopen(filename, "r");
@@ -121,13 +121,13 @@ static int build_cpu_topology(struct cpu_topology *tp, int cpu)
121121
if (p)
122122
*p = '\0';
123123

124-
for (i = 0; i < tp->thread_sib; i++) {
125-
if (!strcmp(buf, tp->thread_siblings[i]))
124+
for (i = 0; i < tp->core_cpus_lists; i++) {
125+
if (!strcmp(buf, tp->core_cpus_list[i]))
126126
break;
127127
}
128-
if (i == tp->thread_sib) {
129-
tp->thread_siblings[i] = buf;
130-
tp->thread_sib++;
128+
if (i == tp->core_cpus_lists) {
129+
tp->core_cpus_list[i] = buf;
130+
tp->core_cpus_lists++;
131131
buf = NULL;
132132
}
133133
ret = 0;
@@ -151,8 +151,8 @@ void cpu_topology__delete(struct cpu_topology *tp)
151151
for (i = 0 ; i < tp->die_cpus_lists; i++)
152152
zfree(&tp->die_cpus_list[i]);
153153

154-
for (i = 0 ; i < tp->thread_sib; i++)
155-
zfree(&tp->thread_siblings[i]);
154+
for (i = 0 ; i < tp->core_cpus_lists; i++)
155+
zfree(&tp->core_cpus_list[i]);
156156

157157
free(tp);
158158
}
@@ -215,7 +215,7 @@ struct cpu_topology *cpu_topology__new(void)
215215
tp->die_cpus_list = addr;
216216
addr += sz;
217217
}
218-
tp->thread_siblings = addr;
218+
tp->core_cpus_list = addr;
219219

220220
for (i = 0; i < nr; i++) {
221221
if (!cpu_map__has(map, i))

tools/perf/util/cputopo.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ struct cpu_topology {
99
u32 package_cpus_lists;
1010
/* The number of unique die_cpu_lists below. */
1111
u32 die_cpus_lists;
12-
u32 thread_sib;
12+
/* The number of unique core_cpu_lists below. */
13+
u32 core_cpus_lists;
1314
/*
1415
* An array of strings where each string is unique and read from
1516
* /sys/devices/system/cpu/cpuX/topology/package_cpus_list. From the ABI
@@ -24,7 +25,13 @@ struct cpu_topology {
2425
* The format is like 0-3, 8-11, 14,17.
2526
*/
2627
const char **die_cpus_list;
27-
char **thread_siblings;
28+
/*
29+
* An array of string where each string is unique and from
30+
* /sys/devices/system/cpu/cpuX/topology/core_cpus_list. From the ABI
31+
* each of these is a human-readable list of CPUs within the same
32+
* core. The format is like 0-3, 8-11, 14,17.
33+
*/
34+
const char **core_cpus_list;
2835
};
2936

3037
struct numa_topology_node {

tools/perf/util/header.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -592,12 +592,12 @@ static int write_cpu_topology(struct feat_fd *ff,
592592
if (ret < 0)
593593
goto done;
594594
}
595-
ret = do_write(ff, &tp->thread_sib, sizeof(tp->thread_sib));
595+
ret = do_write(ff, &tp->core_cpus_lists, sizeof(tp->core_cpus_lists));
596596
if (ret < 0)
597597
goto done;
598598

599-
for (i = 0; i < tp->thread_sib; i++) {
600-
ret = do_write_string(ff, tp->thread_siblings[i]);
599+
for (i = 0; i < tp->core_cpus_lists; i++) {
600+
ret = do_write_string(ff, tp->core_cpus_list[i]);
601601
if (ret < 0)
602602
break;
603603
}

0 commit comments

Comments
 (0)