]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.14/perf-core-restore-mmap-record-type-correctly.patch
autosel patches for 4.14
[thirdparty/kernel/stable-queue.git] / queue-4.14 / perf-core-restore-mmap-record-type-correctly.patch
1 From abcb46d9f77c3ac4e7e6c84b32a7c4831ccf50b6 Mon Sep 17 00:00:00 2001
2 From: Stephane Eranian <eranian@google.com>
3 Date: Thu, 7 Mar 2019 10:52:33 -0800
4 Subject: perf/core: Restore mmap record type correctly
5
6 [ Upstream commit d9c1bb2f6a2157b38e8eb63af437cb22701d31ee ]
7
8 On mmap(), perf_events generates a RECORD_MMAP record and then checks
9 which events are interested in this record. There are currently 2
10 versions of mmap records: RECORD_MMAP and RECORD_MMAP2. MMAP2 is larger.
11 The event configuration controls which version the user level tool
12 accepts.
13
14 If the event->attr.mmap2=1 field then MMAP2 record is returned. The
15 perf_event_mmap_output() takes care of this. It checks attr->mmap2 and
16 corrects the record fields before putting it in the sampling buffer of
17 the event. At the end the function restores the modified MMAP record
18 fields.
19
20 The problem is that the function restores the size but not the type.
21 Thus, if a subsequent event only accepts MMAP type, then it would
22 instead receive an MMAP2 record with a size of MMAP record.
23
24 This patch fixes the problem by restoring the record type on exit.
25
26 Signed-off-by: Stephane Eranian <eranian@google.com>
27 Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
28 Cc: Andi Kleen <ak@linux.intel.com>
29 Cc: Jiri Olsa <jolsa@redhat.com>
30 Cc: Kan Liang <kan.liang@linux.intel.com>
31 Fixes: 13d7a2410fa6 ("perf: Add attr->mmap2 attribute to an event")
32 Link: http://lkml.kernel.org/r/20190307185233.225521-1-eranian@google.com
33 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
34 Signed-off-by: Sasha Levin <sashal@kernel.org>
35 ---
36 kernel/events/core.c | 2 ++
37 1 file changed, 2 insertions(+)
38
39 diff --git a/kernel/events/core.c b/kernel/events/core.c
40 index 92939b5397df..580616e6fcee 100644
41 --- a/kernel/events/core.c
42 +++ b/kernel/events/core.c
43 @@ -6923,6 +6923,7 @@ static void perf_event_mmap_output(struct perf_event *event,
44 struct perf_output_handle handle;
45 struct perf_sample_data sample;
46 int size = mmap_event->event_id.header.size;
47 + u32 type = mmap_event->event_id.header.type;
48 int ret;
49
50 if (!perf_event_mmap_match(event, data))
51 @@ -6966,6 +6967,7 @@ static void perf_event_mmap_output(struct perf_event *event,
52 perf_output_end(&handle);
53 out:
54 mmap_event->event_id.header.size = size;
55 + mmap_event->event_id.header.type = type;
56 }
57
58 static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
59 --
60 2.19.1
61