Skip to content

Commit 1497e80

Browse files
Stephane Eranianacmel
authored andcommitted
perf tools: Handle TOPOLOGY headers with no CPU
This patch fixes an issue in cpumap.c when used with the TOPOLOGY header. In some configurations, some NUMA nodes may have no CPU (empty cpulist). Yet a cpumap map must be created otherwise perf abort with an error. This patch handles this case by creating a dummy map. Before: $ perf record -o - -e cycles noploop 2 | perf script -i - 0x6e8 [0x6c]: failed to process type: 80 After: $ perf record -o - -e cycles noploop 2 | perf script -i - noploop for 2 seconds Signed-off-by: Stephane Eranian <[email protected]> Acked-by: Jiri Olsa <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Kan Liang <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 94ec1eb commit 1497e80

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tools/perf/util/cpumap.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,12 @@ struct cpu_map *cpu_map__new(const char *cpu_list)
134134
if (!cpu_list)
135135
return cpu_map__read_all_cpu_map();
136136

137-
if (!isdigit(*cpu_list))
137+
/*
138+
* must handle the case of empty cpumap to cover
139+
* TOPOLOGY header for NUMA nodes with no CPU
140+
* ( e.g., because of CPU hotplug)
141+
*/
142+
if (!isdigit(*cpu_list) && *cpu_list != '\0')
138143
goto out;
139144

140145
while (isdigit(*cpu_list)) {
@@ -181,8 +186,10 @@ struct cpu_map *cpu_map__new(const char *cpu_list)
181186

182187
if (nr_cpus > 0)
183188
cpus = cpu_map__trim_new(nr_cpus, tmp_cpus);
184-
else
189+
else if (*cpu_list != '\0')
185190
cpus = cpu_map__default_new();
191+
else
192+
cpus = cpu_map__dummy_new();
186193
invalid:
187194
free(tmp_cpus);
188195
out:

0 commit comments

Comments
 (0)