Skip to content

Commit e92dc32

Browse files
Stephane Eraniangregkh
authored andcommitted
perf/core: Restore mmap record type correctly
[ Upstream commit d9c1bb2 ] On mmap(), perf_events generates a RECORD_MMAP record and then checks which events are interested in this record. There are currently 2 versions of mmap records: RECORD_MMAP and RECORD_MMAP2. MMAP2 is larger. The event configuration controls which version the user level tool accepts. If the event->attr.mmap2=1 field then MMAP2 record is returned. The perf_event_mmap_output() takes care of this. It checks attr->mmap2 and corrects the record fields before putting it in the sampling buffer of the event. At the end the function restores the modified MMAP record fields. The problem is that the function restores the size but not the type. Thus, if a subsequent event only accepts MMAP type, then it would instead receive an MMAP2 record with a size of MMAP record. This patch fixes the problem by restoring the record type on exit. Signed-off-by: Stephane Eranian <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Fixes: 13d7a24 ("perf: Add attr->mmap2 attribute to an event") Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 653ee8d commit e92dc32

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

kernel/events/core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5998,6 +5998,7 @@ static void perf_event_mmap_output(struct perf_event *event,
59985998
struct perf_output_handle handle;
59995999
struct perf_sample_data sample;
60006000
int size = mmap_event->event_id.header.size;
6001+
u32 type = mmap_event->event_id.header.type;
60016002
int ret;
60026003

60036004
if (!perf_event_mmap_match(event, data))
@@ -6041,6 +6042,7 @@ static void perf_event_mmap_output(struct perf_event *event,
60416042
perf_output_end(&handle);
60426043
out:
60436044
mmap_event->event_id.header.size = size;
6045+
mmap_event->event_id.header.type = type;
60446046
}
60456047

60466048
static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)

0 commit comments

Comments
 (0)