public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] perf: disable PERF_RECORD_MMAP2 support
@ 2013-10-17 14:28 Stephane Eranian
  2013-10-17 15:54 ` David Ahern
  0 siblings, 1 reply; 5+ messages in thread
From: Stephane Eranian @ 2013-10-17 14:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: mingo, peterz, ak, dsahern, jolsa, acme, hughd


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.

Signed-off-by: Stephane Eranian <eranian@google.com>
---
 kernel/events/core.c    |    4 ++++
 tools/perf/util/event.c |   30 +++++++++++++-----------------
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index c716385..5bd7fe4 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -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;
 
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 9b393e7..63df031 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -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;
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] perf: disable PERF_RECORD_MMAP2 support
  2013-10-17 14:28 [PATCH v2] perf: disable PERF_RECORD_MMAP2 support Stephane Eranian
@ 2013-10-17 15:54 ` David Ahern
  2013-10-17 15:57   ` Stephane Eranian
  0 siblings, 1 reply; 5+ messages in thread
From: David Ahern @ 2013-10-17 15:54 UTC (permalink / raw)
  To: Stephane Eranian, linux-kernel; +Cc: mingo, peterz, ak, jolsa, acme, hughd

On 10/17/13 8:28 AM, Stephane Eranian wrote:
>
> 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.

Why not disable mmap2 as well:

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 0ce9febf1ba0..289f34dbe970 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -678,7 +678,7 @@ 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->mmap2 = track && !perf_missing_features.mmap2; */
     attr->comm  = track;


David

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] perf: disable PERF_RECORD_MMAP2 support
  2013-10-17 15:54 ` David Ahern
@ 2013-10-17 15:57   ` Stephane Eranian
  2013-10-17 15:59     ` David Ahern
  0 siblings, 1 reply; 5+ messages in thread
From: Stephane Eranian @ 2013-10-17 15:57 UTC (permalink / raw)
  To: David Ahern
  Cc: LKML, mingo@elte.hu, Peter Zijlstra, ak@linux.intel.com,
	Jiri Olsa, Arnaldo Carvalho de Melo, Hugh Dickins

On Thu, Oct 17, 2013 at 5:54 PM, David Ahern <dsahern@gmail.com> wrote:
> On 10/17/13 8:28 AM, Stephane Eranian wrote:
>>
>>
>> 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.
>
>
> Why not disable mmap2 as well:
>
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index 0ce9febf1ba0..289f34dbe970 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -678,7 +678,7 @@ 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->mmap2 = track && !perf_missing_features.mmap2; */
>     attr->comm  = track;
>
It is disabled automatically later on. I checked that. Wanted to minimize
the changes.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] perf: disable PERF_RECORD_MMAP2 support
  2013-10-17 15:57   ` Stephane Eranian
@ 2013-10-17 15:59     ` David Ahern
  2013-10-17 16:09       ` Stephane Eranian
  0 siblings, 1 reply; 5+ messages in thread
From: David Ahern @ 2013-10-17 15:59 UTC (permalink / raw)
  To: Stephane Eranian
  Cc: LKML, mingo@elte.hu, Peter Zijlstra, ak@linux.intel.com,
	Jiri Olsa, Arnaldo Carvalho de Melo, Hugh Dickins

On 10/17/13 9:57 AM, Stephane Eranian wrote:
> On Thu, Oct 17, 2013 at 5:54 PM, David Ahern <dsahern@gmail.com> wrote:
>> On 10/17/13 8:28 AM, Stephane Eranian wrote:
>>>
>>>
>>> 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.
>>
>>
>> Why not disable mmap2 as well:
>>
>> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
>> index 0ce9febf1ba0..289f34dbe970 100644
>> --- a/tools/perf/util/evsel.c
>> +++ b/tools/perf/util/evsel.c
>> @@ -678,7 +678,7 @@ 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->mmap2 = track && !perf_missing_features.mmap2; */
>>      attr->comm  = track;
>>
> It is disabled automatically later on. I checked that. Wanted to minimize
> the changes.
>

Understood that the fallback kicks in. Why fail the perf_event_open 
every single time when we know it is not going to succeed?

David

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] perf: disable PERF_RECORD_MMAP2 support
  2013-10-17 15:59     ` David Ahern
@ 2013-10-17 16:09       ` Stephane Eranian
  0 siblings, 0 replies; 5+ messages in thread
From: Stephane Eranian @ 2013-10-17 16:09 UTC (permalink / raw)
  To: David Ahern
  Cc: LKML, mingo@elte.hu, Peter Zijlstra, ak@linux.intel.com,
	Jiri Olsa, Arnaldo Carvalho de Melo, Hugh Dickins

On Thu, Oct 17, 2013 at 5:59 PM, David Ahern <dsahern@gmail.com> wrote:
> On 10/17/13 9:57 AM, Stephane Eranian wrote:
>>
>> On Thu, Oct 17, 2013 at 5:54 PM, David Ahern <dsahern@gmail.com> wrote:
>>>
>>> On 10/17/13 8:28 AM, Stephane Eranian wrote:
>>>>
>>>>
>>>>
>>>> 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.
>>>
>>>
>>>
>>> Why not disable mmap2 as well:
>>>
>>> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
>>> index 0ce9febf1ba0..289f34dbe970 100644
>>> --- a/tools/perf/util/evsel.c
>>> +++ b/tools/perf/util/evsel.c
>>> @@ -678,7 +678,7 @@ 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->mmap2 = track && !perf_missing_features.mmap2; */
>>>      attr->comm  = track;
>>>
>> It is disabled automatically later on. I checked that. Wanted to minimize
>> the changes.
>>
>
> Understood that the fallback kicks in. Why fail the perf_event_open every
> single time when we know it is not going to succeed?
>
Ok, I can add that.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-10-17 16:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-17 14:28 [PATCH v2] perf: disable PERF_RECORD_MMAP2 support Stephane Eranian
2013-10-17 15:54 ` David Ahern
2013-10-17 15:57   ` Stephane Eranian
2013-10-17 15:59     ` David Ahern
2013-10-17 16:09       ` Stephane Eranian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox