Skip to content

Commit 3090ffb

Browse files
Stephane Eranianacmel
authored andcommitted
perf: Disable PERF_RECORD_MMAP2 support
For now, we disable the extended MMAP record support (MMAP2). We have identified cases where it would not report the correct mapping information, clone(VM_CLONE) but with separate pids. We will revisit the support once we find a solution for this case. The patch changes the kernel to return EINVAL if attr->mmap2 is set. The patch also modifies the perf tool to use regular PERF_RECORD_MMAP for synthetic events and it also prevents the tool from requesting attr->mmap2 mode because the kernel would reject it. The support will be revisited once the kenrel interface is updated. In V2, we reduce the patch to the strict minimum. In V3, we avoid calling perf_event_open() with mmap2 set because we know it will fail and require fallback retry. Signed-off-by: Stephane Eranian <eranian@google.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20131017173215.GA8820@quad Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 3b16ff8 commit 3090ffb

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

kernel/events/core.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6767,6 +6767,10 @@ static int perf_copy_attr(struct perf_event_attr __user *uattr,
67676767
if (ret)
67686768
return -EFAULT;
67696769

6770+
/* disabled for now */
6771+
if (attr->mmap2)
6772+
return -EINVAL;
6773+
67706774
if (attr->__reserved_1)
67716775
return -EINVAL;
67726776

tools/perf/util/event.c

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool,
187187
return -1;
188188
}
189189

190-
event->header.type = PERF_RECORD_MMAP2;
190+
event->header.type = PERF_RECORD_MMAP;
191191
/*
192192
* Just like the kernel, see __perf_event_mmap in kernel/perf_event.c
193193
*/
@@ -198,7 +198,6 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool,
198198
char prot[5];
199199
char execname[PATH_MAX];
200200
char anonstr[] = "//anon";
201-
unsigned int ino;
202201
size_t size;
203202
ssize_t n;
204203

@@ -209,13 +208,10 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool,
209208
strcpy(execname, "");
210209

211210
/* 00400000-0040c000 r-xp 00000000 fd:01 41038 /bin/cat */
212-
n = sscanf(bf, "%"PRIx64"-%"PRIx64" %s %"PRIx64" %x:%x %u %s\n",
213-
&event->mmap2.start, &event->mmap2.len, prot,
214-
&event->mmap2.pgoff, &event->mmap2.maj,
215-
&event->mmap2.min,
216-
&ino, execname);
217-
218-
event->mmap2.ino = (u64)ino;
211+
n = sscanf(bf, "%"PRIx64"-%"PRIx64" %s %"PRIx64" %*x:%*x %*u %s\n",
212+
&event->mmap.start, &event->mmap.len, prot,
213+
&event->mmap.pgoff,
214+
execname);
219215

220216
if (n != 8)
221217
continue;
@@ -227,15 +223,15 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool,
227223
strcpy(execname, anonstr);
228224

229225
size = strlen(execname) + 1;
230-
memcpy(event->mmap2.filename, execname, size);
226+
memcpy(event->mmap.filename, execname, size);
231227
size = PERF_ALIGN(size, sizeof(u64));
232-
event->mmap2.len -= event->mmap.start;
233-
event->mmap2.header.size = (sizeof(event->mmap2) -
234-
(sizeof(event->mmap2.filename) - size));
235-
memset(event->mmap2.filename + size, 0, machine->id_hdr_size);
236-
event->mmap2.header.size += machine->id_hdr_size;
237-
event->mmap2.pid = tgid;
238-
event->mmap2.tid = pid;
228+
event->mmap.len -= event->mmap.start;
229+
event->mmap.header.size = (sizeof(event->mmap) -
230+
(sizeof(event->mmap.filename) - size));
231+
memset(event->mmap.filename + size, 0, machine->id_hdr_size);
232+
event->mmap.header.size += machine->id_hdr_size;
233+
event->mmap.pid = tgid;
234+
event->mmap.tid = pid;
239235

240236
if (process(tool, event, &synth_sample, machine) != 0) {
241237
rc = -1;

tools/perf/util/evsel.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,6 @@ void perf_evsel__config(struct perf_evsel *evsel,
678678
attr->sample_type |= PERF_SAMPLE_WEIGHT;
679679

680680
attr->mmap = track;
681-
attr->mmap2 = track && !perf_missing_features.mmap2;
682681
attr->comm = track;
683682

684683
/*

0 commit comments

Comments
 (0)