Skip to content

Commit 406018d

Browse files
captain5050acmel
authored andcommitted
perf cputopo: Match die_siblings to topology ABI name
The topology name for die_siblings is die_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 48f07b0 commit 406018d

File tree

3 files changed

+25
-20
lines changed

3 files changed

+25
-20
lines changed

tools/perf/util/cputopo.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"%s/devices/system/cpu/cpu%d/topology/package_cpus_list"
1919
#define PACKAGE_CPUS_FMT_OLD \
2020
"%s/devices/system/cpu/cpu%d/topology/core_siblings_list"
21-
#define DIE_SIB_FMT \
21+
#define DIE_CPUS_FMT \
2222
"%s/devices/system/cpu/cpu%d/topology/die_cpus_list"
2323
#define THRD_SIB_FMT \
2424
"%s/devices/system/cpu/cpu%d/topology/thread_siblings_list"
@@ -73,10 +73,10 @@ static int build_cpu_topology(struct cpu_topology *tp, int cpu)
7373
ret = 0;
7474

7575
try_dies:
76-
if (!tp->die_siblings)
76+
if (!tp->die_cpus_list)
7777
goto try_threads;
7878

79-
scnprintf(filename, MAXPATHLEN, DIE_SIB_FMT,
79+
scnprintf(filename, MAXPATHLEN, DIE_CPUS_FMT,
8080
sysfs__mountpoint(), cpu);
8181
fp = fopen(filename, "r");
8282
if (!fp)
@@ -91,13 +91,13 @@ static int build_cpu_topology(struct cpu_topology *tp, int cpu)
9191
if (p)
9292
*p = '\0';
9393

94-
for (i = 0; i < tp->die_sib; i++) {
95-
if (!strcmp(buf, tp->die_siblings[i]))
94+
for (i = 0; i < tp->die_cpus_lists; i++) {
95+
if (!strcmp(buf, tp->die_cpus_list[i]))
9696
break;
9797
}
98-
if (i == tp->die_sib) {
99-
tp->die_siblings[i] = buf;
100-
tp->die_sib++;
98+
if (i == tp->die_cpus_lists) {
99+
tp->die_cpus_list[i] = buf;
100+
tp->die_cpus_lists++;
101101
buf = NULL;
102102
len = 0;
103103
}
@@ -148,10 +148,8 @@ void cpu_topology__delete(struct cpu_topology *tp)
148148
for (i = 0 ; i < tp->package_cpus_lists; i++)
149149
zfree(&tp->package_cpus_list[i]);
150150

151-
if (tp->die_sib) {
152-
for (i = 0 ; i < tp->die_sib; i++)
153-
zfree(&tp->die_siblings[i]);
154-
}
151+
for (i = 0 ; i < tp->die_cpus_lists; i++)
152+
zfree(&tp->die_cpus_list[i]);
155153

156154
for (i = 0 ; i < tp->thread_sib; i++)
157155
zfree(&tp->thread_siblings[i]);
@@ -170,7 +168,7 @@ static bool has_die_topology(void)
170168
if (strncmp(uts.machine, "x86_64", 6))
171169
return false;
172170

173-
scnprintf(filename, MAXPATHLEN, DIE_SIB_FMT,
171+
scnprintf(filename, MAXPATHLEN, DIE_CPUS_FMT,
174172
sysfs__mountpoint(), 0);
175173
if (access(filename, F_OK) == -1)
176174
return false;
@@ -214,7 +212,7 @@ struct cpu_topology *cpu_topology__new(void)
214212
tp->package_cpus_list = addr;
215213
addr += sz;
216214
if (has_die) {
217-
tp->die_siblings = addr;
215+
tp->die_cpus_list = addr;
218216
addr += sz;
219217
}
220218
tp->thread_siblings = addr;

tools/perf/util/cputopo.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
struct cpu_topology {
88
/* The number of unique package_cpus_lists below. */
99
u32 package_cpus_lists;
10-
u32 die_sib;
10+
/* The number of unique die_cpu_lists below. */
11+
u32 die_cpus_lists;
1112
u32 thread_sib;
1213
/*
1314
* An array of strings where each string is unique and read from
@@ -16,7 +17,13 @@ struct cpu_topology {
1617
* physical_package_id. The format is like 0-3, 8-11, 14,17.
1718
*/
1819
const char **package_cpus_list;
19-
char **die_siblings;
20+
/*
21+
* An array of string where each string is unique and from
22+
* /sys/devices/system/cpu/cpuX/topology/die_cpus_list. From the ABI
23+
* each of these is a human-readable list of CPUs within the same die.
24+
* The format is like 0-3, 8-11, 14,17.
25+
*/
26+
const char **die_cpus_list;
2027
char **thread_siblings;
2128
};
2229

tools/perf/util/header.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -617,15 +617,15 @@ static int write_cpu_topology(struct feat_fd *ff,
617617
return ret;
618618
}
619619

620-
if (!tp->die_sib)
620+
if (!tp->die_cpus_lists)
621621
goto done;
622622

623-
ret = do_write(ff, &tp->die_sib, sizeof(tp->die_sib));
623+
ret = do_write(ff, &tp->die_cpus_lists, sizeof(tp->die_cpus_lists));
624624
if (ret < 0)
625625
goto done;
626626

627-
for (i = 0; i < tp->die_sib; i++) {
628-
ret = do_write_string(ff, tp->die_siblings[i]);
627+
for (i = 0; i < tp->die_cpus_lists; i++) {
628+
ret = do_write_string(ff, tp->die_cpus_list[i]);
629629
if (ret < 0)
630630
goto done;
631631
}

0 commit comments

Comments
 (0)