Commit e469e88a authored by Stephane Eranian's avatar Stephane Eranian Committed by Kleber Sacilotto de Souza

perf tools: Handle TOPOLOGY headers with no CPU

BugLink: https://bugs.launchpad.net/bugs/1822271

[ Upstream commit 1497e804 ]

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: default avatarStephane Eranian <eranian@google.com>
Acked-by: default avatarJiri 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.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
Acked-by: default avatarJuerg Haefliger <juerg.haefliger@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent ff1a239a
...@@ -124,7 +124,12 @@ struct cpu_map *cpu_map__new(const char *cpu_list) ...@@ -124,7 +124,12 @@ struct cpu_map *cpu_map__new(const char *cpu_list)
if (!cpu_list) if (!cpu_list)
return cpu_map__read_all_cpu_map(); return cpu_map__read_all_cpu_map();
if (!isdigit(*cpu_list)) /*
* must handle the case of empty cpumap to cover
* TOPOLOGY header for NUMA nodes with no CPU
* ( e.g., because of CPU hotplug)
*/
if (!isdigit(*cpu_list) && *cpu_list != '\0')
goto out; goto out;
while (isdigit(*cpu_list)) { while (isdigit(*cpu_list)) {
...@@ -171,8 +176,10 @@ struct cpu_map *cpu_map__new(const char *cpu_list) ...@@ -171,8 +176,10 @@ struct cpu_map *cpu_map__new(const char *cpu_list)
if (nr_cpus > 0) if (nr_cpus > 0)
cpus = cpu_map__trim_new(nr_cpus, tmp_cpus); cpus = cpu_map__trim_new(nr_cpus, tmp_cpus);
else else if (*cpu_list != '\0')
cpus = cpu_map__default_new(); cpus = cpu_map__default_new();
else
cpus = cpu_map__dummy_new();
invalid: invalid:
free(tmp_cpus); free(tmp_cpus);
out: out:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment