linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
To: Stephane Eranian <eranian@google.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	"mingo@elte.hu" <mingo@elte.hu>,
	"ak@linux.intel.com" <ak@linux.intel.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung.kim@lge.com>,
	David Ahern <dsahern@gmail.com>
Subject: Re: [PATCH v2 2/2] perf tools: add attr->mmap2 support
Date: Tue, 10 Sep 2013 16:58:47 -0300	[thread overview]
Message-ID: <20130910195847.GA1866@ghostprotocols.net> (raw)
In-Reply-To: <20130910131728.GE28428@ghostprotocols.net>

[-- Attachment #1: Type: text/plain, Size: 2290 bytes --]

Em Tue, Sep 10, 2013 at 10:17:28AM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Tue, Sep 10, 2013 at 03:05:03PM +0200, Stephane Eranian escreveu:
> > On Tue, Sep 10, 2013 at 3:00 PM, Arnaldo Carvalho de Melo <acme@ghostprotocols.net> wrote:
> > > Em Mon, Sep 09, 2013 at 04:48:44PM -0300, Arnaldo Carvalho de Melo escreveu:
> > > +++ b/kernel/events/core.c
> > > @@ -5039,6 +5039,7 @@ static void perf_event_mmap_output(struct perf_event *event,
> > >                 mmap_event->event_id.header.size += sizeof(mmap_event->maj);
> > >                 mmap_event->event_id.header.size += sizeof(mmap_event->min);
> > >                 mmap_event->event_id.header.size += sizeof(mmap_event->ino);
> > > +               mmap_event->event_id.header.size += sizeof(mmap_event->ino_generation);
> > >         }
> > >         perf_event_header__init_id(&mmap_event->event_id.header, &sample, event);

> > Arg, yes, this is missing.
> > Do you want to submit the patch?

> I will, in some jiffies, just rebooting with the patched kernel to
> re-run tperf test.
 
> > Thanks for tracking it down.
 
> np :-)

More fallout, this time the resulting tools fail to run on older
kernels, i.e. any kernel that doesn't have perf_event_attr.mmap2,
doesn't matter the event type:

[acme@zoo linux]$ perf record usleep 1
Error:
The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (cycles).  
/bin/dmesg may provide additional information.
No CONFIG_PERF_EVENTS=y kernel support configured?

usleep: Terminated
[acme@zoo linux]$ perf record -e cpu-clock usleep 1
Error:
The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (cpu-clock).  
/bin/dmesg may provide additional information.
No CONFIG_PERF_EVENTS=y kernel support configured?

usleep: Terminated
[acme@zoo linux]$

That is because kernel/events/core.c  perf_copy_attr() has this test:

        if (attr->__reserved_1)
                return -EINVAL;

So we must have the handling we have for other things that were added
in the past, like .sample_id_all, .exclude_guest, etc, like is done in
the attached patch, please ack.

Ingo, since you haven't merged my latest perf/urgent pull req, do you
want me to fold this into the patch that makes the tooling side use
PERF_RECORD_MMAP2?

- Arnaldo

[-- Attachment #2: perf_mmap2_fallback.patch --]
[-- Type: text/plain, Size: 1499 bytes --]

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index ff2098b..404599d 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -27,6 +27,7 @@
 static struct {
 	bool sample_id_all;
 	bool exclude_guest;
+	bool mmap2;
 } perf_missing_features;
 
 #define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y))
@@ -677,7 +678,7 @@ void perf_evsel__config(struct perf_evsel *evsel,
 		attr->sample_type	|= PERF_SAMPLE_WEIGHT;
 
 	attr->mmap  = track;
-	attr->mmap2 = track;
+	attr->mmap2 = track && !perf_missing_features.mmap2;
 	attr->comm  = track;
 
 	/*
@@ -1017,6 +1018,8 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
 	}
 
 fallback_missing_features:
+	if (perf_missing_features.mmap2)
+		evsel->attr.mmap2 = 0;
 	if (perf_missing_features.exclude_guest)
 		evsel->attr.exclude_guest = evsel->attr.exclude_host = 0;
 retry_sample_id:
@@ -1081,8 +1084,11 @@ try_fallback:
 	if (err != -EINVAL || cpu > 0 || thread > 0)
 		goto out_close;
 
-	if (!perf_missing_features.exclude_guest &&
-	    (evsel->attr.exclude_guest || evsel->attr.exclude_host)) {
+	if (!perf_missing_features.mmap2 && evsel->attr.mmap2) {
+		perf_missing_features.mmap2 = true;
+		goto fallback_missing_features;
+	} else if (!perf_missing_features.exclude_guest &&
+		   (evsel->attr.exclude_guest || evsel->attr.exclude_host)) {
 		perf_missing_features.exclude_guest = true;
 		goto fallback_missing_features;
 	} else if (!perf_missing_features.sample_id_all) {

  reply	other threads:[~2013-09-10 19:59 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-21 10:10 [PATCH v2 0/2] perf: add new PERF_RECORD_MMAP2 record type Stephane Eranian
2013-08-21 10:10 ` [PATCH v2 1/2] perf: add attr->mmap2 attribute to an event Stephane Eranian
2013-08-22 15:57   ` Arnaldo Carvalho de Melo
2013-09-02  7:41   ` [tip:perf/core] perf: Add " tip-bot for Stephane Eranian
2013-08-21 10:10 ` [PATCH v2 2/2] perf tools: add attr->mmap2 support Stephane Eranian
2013-08-22 10:51   ` Peter Zijlstra
2013-08-30 14:03     ` Stephane Eranian
2013-08-30 14:08       ` Peter Zijlstra
2013-08-30 14:15         ` Stephane Eranian
2013-08-30 17:32           ` Stephane Eranian
2013-08-31  6:00             ` Ingo Molnar
2013-09-09 19:47   ` Arnaldo Carvalho de Melo
2013-09-09 19:48     ` Arnaldo Carvalho de Melo
2013-09-10 13:00       ` Arnaldo Carvalho de Melo
2013-09-10 13:05         ` Stephane Eranian
2013-09-10 13:17           ` Arnaldo Carvalho de Melo
2013-09-10 19:58             ` Arnaldo Carvalho de Melo [this message]
2013-09-10 20:16               ` Arnaldo Carvalho de Melo
2013-09-11 14:42                 ` Stephane Eranian
2013-09-11 14:53                   ` Arnaldo Carvalho de Melo
2013-09-11 15:28                     ` Arnaldo Carvalho de Melo
2013-09-12  6:35                       ` Ingo Molnar
2013-09-10  9:17     ` Peter Zijlstra
2013-09-12 11:10   ` [tip:perf/urgent] perf tools: Add " tip-bot for Stephane Eranian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130910195847.GA1866@ghostprotocols.net \
    --to=acme@ghostprotocols.net \
    --cc=ak@linux.intel.com \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=namhyung.kim@lge.com \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).