All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Robert Richter <robert.richter@amd.com>
Cc: Ingo Molnar <mingo@kernel.org>, David Ahern <dsahern@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf, ibs: Check syscall attribute flags
Date: Fri, 07 Sep 2012 18:56:27 +0200	[thread overview]
Message-ID: <1347036987.2124.3.camel@twins> (raw)
In-Reply-To: <20120907164114.GJ8285@erda.amd.com>

On Fri, 2012-09-07 at 18:41 +0200, Robert Richter wrote:
> From 1d037614edef576da441936bd8c917d31f57b179 Mon Sep 17 00:00:00 2001
> From: Robert Richter <robert.richter@amd.com>
> Date: Wed, 25 Jul 2012 19:12:45 +0200
> Subject: [PATCH] perf, ibs: Check syscall attribute flags
> 
> Current implementation simply ignores attribute flags. Thus, there is
> no notification to userland of unsupported features. Check syscall's
> attribute flags to let userland know if a feature is supported by the
> kernel. This is also needed to distinguish between future kernels what
> might support a feature.
> 
> Cc: <stable@vger.kernel.org> v3.5..
> Signed-off-by: Robert Richter <robert.richter@amd.com>
> ---
>  arch/x86/kernel/cpu/perf_event_amd_ibs.c |   11 +++++++++++
>  include/linux/perf_event.h               |    2 ++
>  2 files changed, 13 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/perf_event_amd_ibs.c b/arch/x86/kernel/cpu/perf_event_amd_ibs.c
> index 7bfb5be..0456061 100644
> --- a/arch/x86/kernel/cpu/perf_event_amd_ibs.c
> +++ b/arch/x86/kernel/cpu/perf_event_amd_ibs.c
> @@ -215,6 +215,14 @@ static int perf_ibs_init(struct perf_event *event)
>         struct perf_ibs *perf_ibs;
>         u64 max_cnt, config;
>         int ret;
> +       struct perf_event_attr notsupp = {

static const ?

> +               .exclude_user   = 1,
> +               .exclude_kernel = 1,
> +               .exclude_hv     = 1,
> +               .exclude_idle   = 1,
> +               .exclude_host   = 1,
> +               .exclude_guest  = 1,

Ideally we'd grow support for those using SVM entry/exit hooks though.

> +       };
>  
>         perf_ibs = get_ibs_pmu(event->attr.type);
>         if (perf_ibs) {
> @@ -229,6 +237,9 @@ static int perf_ibs_init(struct perf_event *event)
>         if (event->pmu != &perf_ibs->pmu)
>                 return -ENOENT;
>  
> +       if (perf_flags(&event->attr) & perf_flags(&notsupp))
> +               return -EINVAL;
> +
>         if (config & ~perf_ibs->config_mask)
>                 return -EINVAL;
>  
> diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
> index 28f9cee..c36a04f 100644
> --- a/include/linux/perf_event.h
> +++ b/include/linux/perf_event.h
> @@ -304,6 +304,8 @@ struct perf_event_attr {
>         __u32   __reserved_2;
>  };
>  
> +#define perf_flags(attr)       (*(&(attr)->read_format + 1))


Another anonymous union shouldn't hurt..

---
 include/linux/perf_event.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index cc5e2cd..5df37a0 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -236,7 +236,9 @@ struct perf_event_attr {
 	__u64			sample_type;
 	__u64			read_format;
 
-	__u64			disabled       :  1, /* off by default        */
+	union {
+		__u64		flags;
+		__u64		disabled       :  1, /* off by default        */
 				inherit	       :  1, /* children inherit it   */
 				pinned	       :  1, /* must always be on PMU */
 				exclusive      :  1, /* only group on PMU     */
@@ -272,6 +274,7 @@ struct perf_event_attr {
 				exclude_callchain_user   : 1, /* exclude user callchains */
 
 				__reserved_1   : 41;
+	};
 
 	union {
 		__u32		wakeup_events;	  /* wakeup every n events */


  parent reply	other threads:[~2012-09-07 16:56 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-20 23:25 [PATCH 00/11] perf tool: assorted cleanups and bug fixes David Ahern
2012-07-20 23:25 ` [PATCH 01/11] perf tool: add machine id to modules debug message David Ahern
2012-07-25 19:16   ` [tip:perf/core] perf symbols: Add " tip-bot for David Ahern
2012-07-20 23:25 ` [PATCH 02/11] perf kvm: set name for VM process in guest machine David Ahern
2012-07-25 12:12   ` Jiri Olsa
2012-07-25 19:17   ` [tip:perf/core] perf kvm: Set " tip-bot for David Ahern
2012-07-20 23:25 ` [PATCH 03/11] perf kvm: guest userspace samples should not be lumped with host uspace David Ahern
2012-07-25 12:13   ` Jiri Olsa
2012-07-25 19:18   ` [tip:perf/core] perf kvm: Guest " tip-bot for David Ahern
2012-07-20 23:25 ` [PATCH 04/11] perf kvm: fix bug resolving guest kernel syms - v2 David Ahern
2012-07-25 12:11   ` Jiri Olsa
2012-07-25 19:19   ` [tip:perf/core] perf kvm: Fix bug resolving guest kernel syms tip-bot for David Ahern
2012-07-20 23:25 ` [PATCH 05/11] perf kvm: use strtol for walking guestmount directory David Ahern
2012-07-23 18:09   ` Arnaldo Carvalho de Melo
2012-07-20 23:25 ` [PATCH 06/11] perf kvm: limit repetitive guestmount message to once per directory David Ahern
2012-07-23 18:11   ` Arnaldo Carvalho de Melo
2012-07-25 19:20   ` [tip:perf/core] perf kvm: Limit " tip-bot for David Ahern
2012-07-20 23:25 ` [PATCH 07/11] perf tools: dump exclude_{guest,host}, precise_ip header info too David Ahern
2012-07-25 19:20   ` [tip:perf/core] perf tools: Dump " tip-bot for David Ahern
2012-07-20 23:25 ` [PATCH 08/11] perf tool: precise mode requires exclude_guest David Ahern
2012-07-23 18:13   ` Arnaldo Carvalho de Melo
2012-07-24 14:20     ` David Ahern
2012-07-24 16:15       ` Robert Richter
2012-07-24 17:28         ` David Ahern
2012-07-24 18:03           ` Arnaldo Carvalho de Melo
2012-07-26  5:16             ` David Ahern
2012-07-26  8:08               ` Peter Zijlstra
2012-08-03 13:51                 ` Robert Richter
2012-08-15 15:22                   ` David Ahern
2012-09-05 15:43                   ` David Ahern
2012-09-05 22:07                     ` Peter Zijlstra
2012-09-06 17:44                       ` Robert Richter
2012-09-06 18:19                         ` David Ahern
2012-07-25 20:35         ` Peter Zijlstra
2012-07-26  5:50           ` Gleb Natapov
2012-07-26  8:07             ` Peter Zijlstra
2012-07-26  8:10               ` Gleb Natapov
2012-07-26  9:07               ` Robert Richter
2012-08-02 16:06             ` David Ahern
2012-09-06 19:02   ` Robert Richter
2012-09-06 19:17     ` David Ahern
2012-09-06 19:56       ` Robert Richter
2012-09-07 16:41         ` [PATCH] perf, ibs: Check syscall attribute flags Robert Richter
2012-09-07 16:50           ` David Ahern
2012-09-07 17:07             ` Robert Richter
2012-09-07 17:11               ` David Ahern
2012-09-07 17:20                 ` David Ahern
2012-09-10 13:07                   ` Robert Richter
2012-09-10 15:37                     ` Arnaldo Carvalho de Melo
2012-09-07 17:25                 ` Robert Richter
2012-09-07 16:56           ` Peter Zijlstra [this message]
2012-09-07 17:18             ` Robert Richter
2012-09-07 19:11               ` Peter Zijlstra
2012-09-10  9:30             ` [PATCH -v2] " Robert Richter
2012-09-14  6:17               ` [tip:perf/urgent] perf/x86/ibs: " tip-bot for Robert Richter
2012-07-20 23:25 ` [PATCH 09/11] perf top: error handling for counter creation should parallel perf-record David Ahern
2012-07-23 18:15   ` Arnaldo Carvalho de Melo
2012-07-24 14:01     ` David Ahern
2012-07-24 14:39       ` Arnaldo Carvalho de Melo
2012-07-20 23:25 ` [PATCH 10/11] perf tool: give user better message if precise is not supported David Ahern
2012-07-21 10:40   ` Namhyung Kim
2012-07-22  2:28     ` David Ahern
2012-07-20 23:25 ` [PATCH 11/11] perf kvm top: limit guest kernel info message to once David Ahern
2012-07-23 18:17   ` Arnaldo Carvalho de Melo
2012-07-24 14:02     ` David Ahern
2012-07-24 14:40       ` Arnaldo Carvalho de Melo

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=1347036987.2124.3.camel@twins \
    --to=peterz@infradead.org \
    --cc=dsahern@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=robert.richter@amd.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.