Skip to contentSkip to conversation

perf tools: Setup initial evlist::all_cpus value

PATCH Applied Jiri Olsa 3 participants 3 messages Jan 10, 2020 – Jan 20, 2020 perf events

lore
Share & tools
lore

Jiri Olsa

author reviewer
#0 lore raw

PATCH 1/1 perf tools: Setup initial evlist::all_cpus value

Jann Horn reported crash in perf ftrace because evlist::all_cpus isn't initialized if there's evlist without events, which is the case for perf ftrace.

Adding initial initialization of evlist::all_cpus from given cpus, regardless of events in the evlist.

---
 tools/lib/perf/evlist.c | 3 +++
 1 file changed, 3 insertions(+)
tools/lib/perf/evlist.c +3 -0
index ae9e65aa2491..5b9f2ca50591 100644
@@ -164,6 +164,9 @@ void perf_evlist__set_maps(struct perf_evlist *evlist,
 		evlist->threads = perf_thread_map__get(threads);
 	}
 
+	if (!evlist->all_cpus && cpus)
+		evlist->all_cpus = perf_cpu_map__get(cpus);
+
 	perf_evlist__propagate_maps(evlist);
 }
 
Signature · 1 line
2.24.1
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Jiri Olsa

Jann Horn reported crash in perf ftrace because evlist::all_cpus isn't initialized if there's evlist without events, which is the case for perf ftrace.

Adding initial initialization of evlist::all_cpus from given cpus, regardless of events in the evlist.

Quoted 25 lines
---
 tools/lib/perf/evlist.c | 3 +++
 1 file changed, 3 insertions(+)
tools/lib/perf/evlist.c +3 -0
index ae9e65aa2491..5b9f2ca50591 100644
@@ -164,6 +164,9 @@ void perf_evlist__set_maps(struct perf_evlist *evlist,
 		evlist->threads = perf_thread_map__get(threads);
 	}
 
+	if (!evlist->all_cpus && cpus)
+		evlist->all_cpus = perf_cpu_map__get(cpus);
+
 	perf_evlist__propagate_maps(evlist);
 }
 
Signature · 1 line
2.24.1
merge bot Applied
#2 lore raw

[tip: perf/core] libperf: Setup initial evlist::all_cpus value

In reply to Jiri Olsa
The following commit has been merged into the perf/core branch of tip:

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     cb71f7d43ece3d5a4f400f510c61b2ec7c9ce9a1
Gitweb:        https://git.kernel.org/tip/cb71f7d43ece3d5a4f400f510c61b2ec7c9ce9a1
Author:        Jiri Olsa <[email protected]>
AuthorDate:    Fri, 10 Jan 2020 16:15:37 +01:00
Committer:     Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Tue, 14 Jan 2020 12:02:19 -03:00

libperf: Setup initial evlist::all_cpus value

Jann Horn reported crash in perf ftrace because evlist::all_cpus isn't initialized if there's evlist without events, which is the case for perf ftrace.

Adding initial initialization of evlist::all_cpus from given cpus, regardless of events in the evlist.

Fixes 7736627b865d ("perf stat: Use affinity for closing file descriptors")
Cc Alexander Shishkin <[email protected]>
Cc Michael Petlan <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Peter Zijlstra <[email protected]>
---
 tools/lib/perf/evlist.c | 3 +++
 1 file changed, 3 insertions(+)
tools/lib/perf/evlist.c +3 -0
index ae9e65a..5b9f2ca 100644
@@ -164,6 +164,9 @@ void perf_evlist__set_maps(struct perf_evlist *evlist,
 		evlist->threads = perf_thread_map__get(threads);
 	}
 
+	if (!evlist->all_cpus && cpus)
+		evlist->all_cpus = perf_cpu_map__get(cpus);
+
 	perf_evlist__propagate_maps(evlist);
 }