Skip to content

Commit aa7fb40

Browse files
Stephane Eraniangregkh
authored andcommitted
perf tools: Handle TOPOLOGY headers with no CPU
[ Upstream commit 1497e80 ] 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 <eranian@google.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Andi Kleen <ak@linux.intel.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/1547885559-1657-1-git-send-email-eranian@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent a4fa2a1 commit aa7fb40

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

tools/perf/util/cpumap.c

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

127-
if (!isdigit(*cpu_list))
127+
/*
128+
* must handle the case of empty cpumap to cover
129+
* TOPOLOGY header for NUMA nodes with no CPU
130+
* ( e.g., because of CPU hotplug)
131+
*/
132+
if (!isdigit(*cpu_list) && *cpu_list != '\0')
128133
goto out;
129134

130135
while (isdigit(*cpu_list)) {
@@ -171,8 +176,10 @@ struct cpu_map *cpu_map__new(const char *cpu_list)
171176

172177
if (nr_cpus > 0)
173178
cpus = cpu_map__trim_new(nr_cpus, tmp_cpus);
174-
else
179+
else if (*cpu_list != '\0')
175180
cpus = cpu_map__default_new();
181+
else
182+
cpus = cpu_map__dummy_new();
176183
invalid:
177184
free(tmp_cpus);
178185
out:

0 commit comments

Comments
 (0)