From: Peter Zijlstra <peterz@infradead.org>
To: Jiri Olsa <jolsa@redhat.com>
Cc: linux-kernel@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Ingo Molnar <mingo@elte.hu>, Paul Mackerras <paulus@samba.org>,
Corey Ashford <cjashfor@linux.vnet.ibm.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Namhyung Kim <namhyung@kernel.org>
Subject: Re: [PATCH 02/11] perf: Add PERF_EVENT_IOC_ID ioctl to return event ID
Date: Thu, 2 May 2013 15:38:49 +0200 [thread overview]
Message-ID: <20130502133848.GI13837@dyad.programming.kicks-ass.net> (raw)
In-Reply-To: <1359981185-16819-3-git-send-email-jolsa@redhat.com>
On Mon, Feb 04, 2013 at 01:32:56PM +0100, Jiri Olsa wrote:
> From: "jolsa@redhat.com" <jolsa@redhat.com>
>
> The only way to get the event ID is by reading the event fd,
> followed by parsing the ID value out of the returned data.
>
> While this is ok for current read format used by perf tool,
> it is not ok when we use PERF_FORMAT_GROUP format.
>
> With this format the data are returned for the whole group
> and there's no way to find out what ID belongs to our fd
> (if we are not group leader event).
>
> Adding a simple ioctl that returns event primary ID for given fd.
>
> Signed-off-by: Jiri Olsa <jolsa@redhat.com>
> Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Cc: Ingo Molnar <mingo@elte.hu>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> ---
> include/uapi/linux/perf_event.h | 1 +
> kernel/events/core.c | 9 +++++++++
> 2 files changed, 10 insertions(+)
>
> diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
> index 9fa9c62..b4ea8ed 100644
> --- a/include/uapi/linux/perf_event.h
> +++ b/include/uapi/linux/perf_event.h
> @@ -316,6 +316,7 @@ struct perf_event_attr {
> #define PERF_EVENT_IOC_PERIOD _IOW('$', 4, __u64)
> #define PERF_EVENT_IOC_SET_OUTPUT _IO ('$', 5)
> #define PERF_EVENT_IOC_SET_FILTER _IOW('$', 6, char *)
> +#define PERF_EVENT_IOC_ID _IOR('$', 7, u64 *)
>
> enum perf_event_ioc_flags {
> PERF_IOC_FLAG_GROUP = 1U << 0,
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 301079d..4081261 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -3277,6 +3277,15 @@ static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
> case PERF_EVENT_IOC_PERIOD:
> return perf_event_period(event, (u64 __user *)arg);
>
> + case PERF_EVENT_IOC_ID:
> + {
> + u64 id = primary_event_id(event);
> +
> + if (copy_to_user((void __user *)arg, &id, sizeof(id)))
> + return -EFAULT;
> + return 0;
> + }
> +
> case PERF_EVENT_IOC_SET_OUTPUT:
> {
> int ret;
> --
> 1.7.11.7
>
next prev parent reply other threads:[~2013-05-02 13:40 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-04 12:32 [PATCH 00/11] perf tool: Add PERF_SAMPLE_READ sample read support Jiri Olsa
2013-02-04 12:32 ` [PATCH 01/11] perf ui/hist: Add support to display whole group data for raw columns Jiri Olsa
2013-02-06 4:41 ` Namhyung Kim
2013-02-06 22:10 ` [tip:perf/core] perf hists browser: " tip-bot for Jiri Olsa
2013-02-04 12:32 ` [PATCH 02/11] perf: Add PERF_EVENT_IOC_ID ioctl to return event ID Jiri Olsa
2013-05-02 13:38 ` Peter Zijlstra [this message]
2013-02-04 12:32 ` [PATCH 03/11] perf: Do not get values from disabled counters in group format read Jiri Olsa
2013-05-02 13:39 ` Peter Zijlstra
2013-02-04 12:32 ` [PATCH 04/11] perf tools: Use PERF_EVENT_IOC_ID perf ioctl to read event id Jiri Olsa
2013-02-04 12:32 ` [PATCH 05/11] perf tools: Add support for parsing PERF_SAMPLE_READ sample type Jiri Olsa
2013-02-04 12:33 ` [PATCH 06/11] perf tools: Fix event ID retrieval for group format read case Jiri Olsa
2013-02-04 12:33 ` [PATCH 07/11] perf tools: Add perf_evlist__id2sid function to get event ID related data Jiri Olsa
2013-02-04 12:33 ` [PATCH 08/11] perf tools: Add PERF_SAMPLE_READ sample related processing Jiri Olsa
2013-02-04 12:33 ` [PATCH 09/11] perf tools: Add 'S' event/group modifier to read sample value Jiri Olsa
2013-02-04 12:33 ` [PATCH 10/11] perf tests: Add attr record group sampling test Jiri Olsa
2013-02-04 12:33 ` [PATCH 11/11] perf tests: Add parse events tests for leader sampling Jiri Olsa
2013-02-06 4:59 ` [PATCH 00/11] perf tool: Add PERF_SAMPLE_READ sample read support Namhyung Kim
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=20130502133848.GI13837@dyad.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@ghostprotocols.net \
--cc=cjashfor@linux.vnet.ibm.com \
--cc=fweisbec@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=namhyung@kernel.org \
--cc=paulus@samba.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