]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.18.137/perf-tools-handle-topology-headers-with-no-cpu.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.18.137 / perf-tools-handle-topology-headers-with-no-cpu.patch
1 From d06e8eda25bdbe088b2876d40f416ba4f20b4d49 Mon Sep 17 00:00:00 2001
2 From: Stephane Eranian <eranian@google.com>
3 Date: Sat, 19 Jan 2019 00:12:39 -0800
4 Subject: perf tools: Handle TOPOLOGY headers with no CPU
5
6 [ Upstream commit 1497e804d1a6e2bd9107ddf64b0310449f4673eb ]
7
8 This patch fixes an issue in cpumap.c when used with the TOPOLOGY
9 header. In some configurations, some NUMA nodes may have no CPU (empty
10 cpulist). Yet a cpumap map must be created otherwise perf abort with an
11 error. This patch handles this case by creating a dummy map.
12
13 Before:
14
15 $ perf record -o - -e cycles noploop 2 | perf script -i -
16 0x6e8 [0x6c]: failed to process type: 80
17
18 After:
19
20 $ perf record -o - -e cycles noploop 2 | perf script -i -
21 noploop for 2 seconds
22
23 Signed-off-by: Stephane Eranian <eranian@google.com>
24 Acked-by: Jiri Olsa <jolsa@kernel.org>
25 Cc: Andi Kleen <ak@linux.intel.com>
26 Cc: Kan Liang <kan.liang@linux.intel.com>
27 Cc: Peter Zijlstra <peterz@infradead.org>
28 Link: http://lkml.kernel.org/r/1547885559-1657-1-git-send-email-eranian@google.com
29 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
30 Signed-off-by: Sasha Levin <sashal@kernel.org>
31 ---
32 tools/perf/util/cpumap.c | 11 +++++++++--
33 1 file changed, 9 insertions(+), 2 deletions(-)
34
35 diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c
36 index c4e55b71010c..2ccfeb78fd5d 100644
37 --- a/tools/perf/util/cpumap.c
38 +++ b/tools/perf/util/cpumap.c
39 @@ -121,7 +121,12 @@ struct cpu_map *cpu_map__new(const char *cpu_list)
40 if (!cpu_list)
41 return cpu_map__read_all_cpu_map();
42
43 - if (!isdigit(*cpu_list))
44 + /*
45 + * must handle the case of empty cpumap to cover
46 + * TOPOLOGY header for NUMA nodes with no CPU
47 + * ( e.g., because of CPU hotplug)
48 + */
49 + if (!isdigit(*cpu_list) && *cpu_list != '\0')
50 goto out;
51
52 while (isdigit(*cpu_list)) {
53 @@ -168,8 +173,10 @@ struct cpu_map *cpu_map__new(const char *cpu_list)
54
55 if (nr_cpus > 0)
56 cpus = cpu_map__trim_new(nr_cpus, tmp_cpus);
57 - else
58 + else if (*cpu_list != '\0')
59 cpus = cpu_map__default_new();
60 + else
61 + cpus = cpu_map__dummy_new();
62 invalid:
63 free(tmp_cpus);
64 out:
65 --
66 2.19.1
67