perf: disable PERF_RECORD_MMAP2 support
PATCH v3 1/1 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.
--- kernel/events/core.c | 4 ++++ tools/perf/util/event.c | 30 +++++++++++++----------------- tools/perf/util/evsel.c | 1 - 3 files changed, 17 insertions(+), 18 deletions(-)
kernel/events/core.c +4 -0
@@ -6773,6 +6773,10 @@ static int perf_copy_attr(struct perf_event_attr __user *uattr,if (ret)return -EFAULT ; +/* disabled for now */ +if (attr->mmap2) +return -EINVAL ; +if (attr->__reserved_1)return -EINVAL ;
tools/perf/util/event.c +13 -17
@@ -187,7 +187,7 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool,return -1 ; } - event->header.type =PERF_RECORD_MMAP2 ; + event->header.type =PERF_RECORD_MMAP ;/* * Just like the kernel, see __perf_event_mmap in kernel/perf_event.c */
@@ -198,7 +198,6 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool,char prot[5 ];char execname[PATH_MAX ];char anonstr[] ="//anon" ; -unsigned int ino;size_t size;ssize_t n;
@@ -209,13 +208,10 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool,strcpy (execname,"" );/* 00400000-0040c000 r-xp 00000000 fd:01 41038 /bin/cat */ - n =sscanf (bf,"%" PRIx64"-%" PRIx64" %s %" PRIx64" %x:%x %u %s\n" , - &event->mmap2.start, &event->mmap2.len, prot, - &event->mmap2.pgoff, &event->mmap2.maj, - &event->mmap2.min, - &ino, execname); - - event->mmap2.ino = (u64 )ino; + n =sscanf (bf,"%" PRIx64"-%" PRIx64" %s %" PRIx64" %*x:%*x %*u %s\n" , + &event->mmap.start, &event->mmap.len, prot, + &event->mmap.pgoff, + execname);if (n !=8 )continue ;
@@ -227,15 +223,15 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool,strcpy (execname, anonstr); size =strlen (execname) +1 ; -memcpy (event->mmap2.filename, execname, size); +memcpy (event->mmap.filename, execname, size); size =PERF_ALIGN (size,sizeof (u64)); - event->mmap2.len -= event->mmap.start; - event->mmap2.header.size = (sizeof (event->mmap2) - - (sizeof (event->mmap2.filename) - size)); -memset (event->mmap2.filename + size,0 , machine->id_hdr_size); - event->mmap2.header.size += machine->id_hdr_size; - event->mmap2.pid = tgid; - event->mmap2.tid = pid; + event->mmap.len -= event->mmap.start; + event->mmap.header.size = (sizeof (event->mmap) - + (sizeof (event->mmap.filename) - size)); +memset (event->mmap.filename + size,0 , machine->id_hdr_size); + event->mmap.header.size += machine->id_hdr_size; + event->mmap.pid = tgid; + event->mmap.tid = pid;if (process (tool, event, &synth_sample, machine) !=0 ) { rc =-1 ;
tools/perf/util/evsel.c +0 -1
@@ -678,7 +678,6 @@ void perf_evsel__config(struct perf_evsel *evsel, attr->sample_type |=PERF_SAMPLE_WEIGHT ; attr->mmap = track; - attr->mmap2 = track && !perf_missing_features.mmap2; attr->comm = track;if (opts->sample_transaction)
Signature · 1 line
1.7.9.5
Em Thu, Oct 17, 2013 at 07:32:15PM +0200, Stephane Eranian escreveu:
Quoted 11 lines
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 regularPERF_RECORD_MMAPfor synthetic events and it also prevents the tool from requestingattr->mmap2mode because the kernel would reject it.
Quoted 5 lines
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 callingperf_event_open()with mmap2 set because we know it will fail and require fallback retry.
Again it applied, but with some fuzz, which branch did you coded this against? Testing...
[acme@zoo linux]$ patch -p1 < /wb/1
patching file kernel/events/core.c
Hunk #1 succeeded at 6767 (offset -6 lines).
patching file tools/perf/util/event.c
patching file tools/perf/util/evsel.c
Hunk #1 succeeded at 678 with fuzz 1.
[acme@zoo linux]$
- Arnaldo
tip-bot for Stephane Eranian
merge bot[tip:perf/urgent] perf: Disable PERF_RECORD_MMAP2 support
In reply to Stephane Eranianperf: Disable PERF_RECORD_MMAP2 support
Commit-ID: 3090ffb5a2515990182f3f55b0688a7817325488 Gitweb: http://git.kernel.org/tip/3090ffb5a2515990182f3f55b0688a7817325488 Author: Stephane Eranian <[email protected]> AuthorDate: Thu, 17 Oct 2013 19:32:15 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 17 Oct 2013 16:27:14 -0300
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.
--- kernel/events/core.c | 4 ++++ tools/perf/util/event.c | 30 +++++++++++++----------------- tools/perf/util/evsel.c | 1 - 3 files changed, 17 insertions(+), 18 deletions(-)
kernel/events/core.c +4 -0
@@ -6767,6 +6767,10 @@ static int perf_copy_attr(struct perf_event_attr __user *uattr,if (ret)return -EFAULT ; +/* disabled for now */ +if (attr->mmap2) +return -EINVAL ; +if (attr->__reserved_1)return -EINVAL ;
tools/perf/util/event.c +13 -17
@@ -187,7 +187,7 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool,return -1 ; } - event->header.type =PERF_RECORD_MMAP2 ; + event->header.type =PERF_RECORD_MMAP ;/* * Just like the kernel, see __perf_event_mmap in kernel/perf_event.c */
@@ -198,7 +198,6 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool,char prot[5 ];char execname[PATH_MAX ];char anonstr[] ="//anon" ; -unsigned int ino;size_t size;ssize_t n;
@@ -209,13 +208,10 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool,strcpy (execname,"" );/* 00400000-0040c000 r-xp 00000000 fd:01 41038 /bin/cat */ - n =sscanf (bf,"%" PRIx64"-%" PRIx64" %s %" PRIx64" %x:%x %u %s\n" , - &event->mmap2.start, &event->mmap2.len, prot, - &event->mmap2.pgoff, &event->mmap2.maj, - &event->mmap2.min, - &ino, execname); - - event->mmap2.ino = (u64 )ino; + n =sscanf (bf,"%" PRIx64"-%" PRIx64" %s %" PRIx64" %*x:%*x %*u %s\n" , + &event->mmap.start, &event->mmap.len, prot, + &event->mmap.pgoff, + execname);if (n !=8 )continue ;
@@ -227,15 +223,15 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool,strcpy (execname, anonstr); size =strlen (execname) +1 ; -memcpy (event->mmap2.filename, execname, size); +memcpy (event->mmap.filename, execname, size); size =PERF_ALIGN (size,sizeof (u64)); - event->mmap2.len -= event->mmap.start; - event->mmap2.header.size = (sizeof (event->mmap2) - - (sizeof (event->mmap2.filename) - size)); -memset (event->mmap2.filename + size,0 , machine->id_hdr_size); - event->mmap2.header.size += machine->id_hdr_size; - event->mmap2.pid = tgid; - event->mmap2.tid = pid; + event->mmap.len -= event->mmap.start; + event->mmap.header.size = (sizeof (event->mmap) - + (sizeof (event->mmap.filename) - size)); +memset (event->mmap.filename + size,0 , machine->id_hdr_size); + event->mmap.header.size += machine->id_hdr_size; + event->mmap.pid = tgid; + event->mmap.tid = pid;if (process (tool, event, &synth_sample, machine) !=0 ) { rc =-1 ;
tools/perf/util/evsel.c +0 -1
@@ -678,7 +678,6 @@ void perf_evsel__config(struct perf_evsel *evsel, attr->sample_type |=PERF_SAMPLE_WEIGHT ; attr->mmap = track; - attr->mmap2 = track && !perf_missing_features.mmap2; attr->comm = track;/*