mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Anshuman Khandual <khandual@linux.vnet.ibm.com>
To: Stephane Eranian <eranian@google.com>
Cc: linux-kernel@vger.kernel.org, peterz@infradead.org,
	mingo@elte.hu, acme@infradead.org, robert.richter@amd.com,
	ming.m.lin@intel.com, andi@firstfloor.org, asharma@fb.com,
	ravitillo@lbl.gov, vweaver1@eecs.utk.edu
Subject: Re: [PATCH 09/13] perf_events: disable PERF_SAMPLE_BRANCH_* when not supported (v3)
Date: Fri, 27 Jan 2012 12:45:05 +0530	[thread overview]
Message-ID: <4F224EF9.5040307@linux.vnet.ibm.com> (raw)
In-Reply-To: <1326127761-2723-10-git-send-email-eranian@google.com>

On Monday 09 January 2012 10:19 PM, Stephane Eranian wrote:
> PERF_SAMPLE_BRANCH_* is disabled for:
> - SW events (sw counters, tracepoints)
> - HW breakpoints
> - ALL but Intel X86 architecture
> - AMD64 processors
> 
> Signed-off-by: Stephane Eranian <eranian@google.com>
> ---
>  arch/alpha/kernel/perf_event.c       |    4 ++++
>  arch/arm/kernel/perf_event.c         |    4 ++++
>  arch/mips/kernel/perf_event_mipsxx.c |    4 ++++
>  arch/powerpc/kernel/perf_event.c     |    4 ++++
>  arch/sh/kernel/perf_event.c          |    4 ++++
>  arch/sparc/kernel/perf_event.c       |    4 ++++
>  arch/x86/kernel/cpu/perf_event_amd.c |    3 +++
>  kernel/events/core.c                 |   24 ++++++++++++++++++++++++
>  kernel/events/hw_breakpoint.c        |    6 ++++++
>  9 files changed, 57 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/alpha/kernel/perf_event.c b/arch/alpha/kernel/perf_event.c
> index 8143cd7..0dae252 100644
> --- a/arch/alpha/kernel/perf_event.c
> +++ b/arch/alpha/kernel/perf_event.c
> @@ -685,6 +685,10 @@ static int alpha_pmu_event_init(struct perf_event *event)
>  {
>  	int err;
> 
> +	/* does not support taken branch sampling */
> +	if (has_branch_stack(event))
> +		return -EOPNOTSUPP;
> +
>  	switch (event->attr.type) {
>  	case PERF_TYPE_RAW:
>  	case PERF_TYPE_HARDWARE:
> diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c
> index 88b0941..42262ff 100644
> --- a/arch/arm/kernel/perf_event.c
> +++ b/arch/arm/kernel/perf_event.c
> @@ -540,6 +540,10 @@ static int armpmu_event_init(struct perf_event *event)
>  	int err = 0;
>  	atomic_t *active_events = &armpmu->active_events;
> 
> +	/* does not support taken branch sampling */
> +	if (has_branch_smpl(event))
I guess this would be 'has_branch_stack' instead of 'has_branch_smpl'.
'has_branch_smpl' has not been defined any where but getting called here.
> +		return -EOPNOTSUPP;
> +
>  	if (armpmu->map_event(event) == -ENOENT)
>  		return -ENOENT;
> 
> diff --git a/arch/mips/kernel/perf_event_mipsxx.c b/arch/mips/kernel/perf_event_mipsxx.c
> index 315fc0b..7070f8c 100644
> --- a/arch/mips/kernel/perf_event_mipsxx.c
> +++ b/arch/mips/kernel/perf_event_mipsxx.c
> @@ -606,6 +606,10 @@ static int mipspmu_event_init(struct perf_event *event)
>  {
>  	int err = 0;
> 
> +	/* does not support taken branch sampling */
> +	if (has_branch_stack(event))
> +		return -EOPNOTSUPP;
> +
>  	switch (event->attr.type) {
>  	case PERF_TYPE_RAW:
>  	case PERF_TYPE_HARDWARE:
> diff --git a/arch/powerpc/kernel/perf_event.c b/arch/powerpc/kernel/perf_event.c
> index d614ab5..4e0b265 100644
> --- a/arch/powerpc/kernel/perf_event.c
> +++ b/arch/powerpc/kernel/perf_event.c
> @@ -1078,6 +1078,10 @@ static int power_pmu_event_init(struct perf_event *event)
>  	if (!ppmu)
>  		return -ENOENT;
> 
> +	/* does not support taken branch sampling */
> +	if (has_branch_stack(event))
> +		return -EOPNOTSUPP;
> +
>  	switch (event->attr.type) {
>  	case PERF_TYPE_HARDWARE:
>  		ev = event->attr.config;
> diff --git a/arch/sh/kernel/perf_event.c b/arch/sh/kernel/perf_event.c
> index 10b14e3..068b8a2 100644
> --- a/arch/sh/kernel/perf_event.c
> +++ b/arch/sh/kernel/perf_event.c
> @@ -310,6 +310,10 @@ static int sh_pmu_event_init(struct perf_event *event)
>  {
>  	int err;
> 
> +	/* does not support taken branch sampling */
> +	if (has_branch_stack(event))
> +		return -EOPNOTSUPP;
> +
>  	switch (event->attr.type) {
>  	case PERF_TYPE_RAW:
>  	case PERF_TYPE_HW_CACHE:
> diff --git a/arch/sparc/kernel/perf_event.c b/arch/sparc/kernel/perf_event.c
> index 614da62..8e16a4a 100644
> --- a/arch/sparc/kernel/perf_event.c
> +++ b/arch/sparc/kernel/perf_event.c
> @@ -1105,6 +1105,10 @@ static int sparc_pmu_event_init(struct perf_event *event)
>  	if (atomic_read(&nmi_active) < 0)
>  		return -ENODEV;
> 
> +	/* does not support taken branch sampling */
> +	if (has_branch_stack(event))
> +		return -EOPNOTSUPP;
> +
>  	switch (attr->type) {
>  	case PERF_TYPE_HARDWARE:
>  		if (attr->config >= sparc_pmu->max_events)
> diff --git a/arch/x86/kernel/cpu/perf_event_amd.c b/arch/x86/kernel/cpu/perf_event_amd.c
> index 0397b23..0d8da03 100644
> --- a/arch/x86/kernel/cpu/perf_event_amd.c
> +++ b/arch/x86/kernel/cpu/perf_event_amd.c
> @@ -138,6 +138,9 @@ static int amd_pmu_hw_config(struct perf_event *event)
>  	if (ret)
>  		return ret;
> 
> +	if (has_branch_stack(event))
> +		return -EOPNOTSUPP;
> +
>  	if (event->attr.exclude_host && event->attr.exclude_guest)
>  		/*
>  		 * When HO == GO == 1 the hardware treats that as GO == HO == 0
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index ed39225..36d1a63 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -5000,6 +5000,12 @@ static int perf_swevent_init(struct perf_event *event)
>  	if (event->attr.type != PERF_TYPE_SOFTWARE)
>  		return -ENOENT;
> 
> +	/*
> +	 * no branch sampling for software events
> +	 */
> +	if (has_branch_stack(event))
> +		return -EOPNOTSUPP;
> +
>  	switch (event_id) {
>  	case PERF_COUNT_SW_CPU_CLOCK:
>  	case PERF_COUNT_SW_TASK_CLOCK:
> @@ -5110,6 +5116,12 @@ static int perf_tp_event_init(struct perf_event *event)
>  	if (event->attr.type != PERF_TYPE_TRACEPOINT)
>  		return -ENOENT;
> 
> +	/*
> +	 * no branch sampling for tracepoint events
> +	 */
> +	if (has_branch_stack(event))
> +		return -EOPNOTSUPP;
> +
>  	err = perf_trace_init(event);
>  	if (err)
>  		return err;
> @@ -5335,6 +5347,12 @@ static int cpu_clock_event_init(struct perf_event *event)
>  	if (event->attr.config != PERF_COUNT_SW_CPU_CLOCK)
>  		return -ENOENT;
> 
> +	/*
> +	 * no branch sampling for software events
> +	 */
> +	if (has_branch_stack(event))
> +		return -EOPNOTSUPP;
> +
>  	perf_swevent_init_hrtimer(event);
> 
>  	return 0;
> @@ -5409,6 +5427,12 @@ static int task_clock_event_init(struct perf_event *event)
>  	if (event->attr.config != PERF_COUNT_SW_TASK_CLOCK)
>  		return -ENOENT;
> 
> +	/*
> +	 * no branch sampling for software events
> +	 */
> +	if (has_branch_stack(event))
> +		return -EOPNOTSUPP;
> +
>  	perf_swevent_init_hrtimer(event);
> 
>  	return 0;
> diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c
> index b0309f7..cee5423 100644
> --- a/kernel/events/hw_breakpoint.c
> +++ b/kernel/events/hw_breakpoint.c
> @@ -581,6 +581,12 @@ static int hw_breakpoint_event_init(struct perf_event *bp)
>  	if (bp->attr.type != PERF_TYPE_BREAKPOINT)
>  		return -ENOENT;
> 
> +	/*
> +	 * no branch sampling for breakpoint events
> +	 */
> +	if (has_branch_stack(bp))
> +		return -EOPNOTSUPP;
> +
>  	err = register_perf_hw_breakpoint(bp);
>  	if (err)
>  		return err;


-- 
Linux Technology Centre
IBM Systems and Technology Group
Bangalore India


  reply	other threads:[~2012-01-27  7:15 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-09 16:49 [PATCH 00/13] perf_events: add support for sampling taken branches (v3) Stephane Eranian
2012-01-09 16:49 ` [PATCH 01/13] perf_events: add generic taken branch sampling support (v3) Stephane Eranian
2012-01-27  4:46   ` Anshuman Khandual
2012-01-27  9:57     ` Stephane Eranian
2012-01-09 16:49 ` [PATCH 02/13] perf_events: add Intel LBR MSR definitions (v3) Stephane Eranian
2012-01-27  5:03   ` Anshuman Khandual
2012-01-09 16:49 ` [PATCH 03/13] perf_events: add Intel X86 LBR sharing logic (v3) Stephane Eranian
2012-01-09 16:49 ` [PATCH 04/13] perf_events: sync branch stack sampling with X86 precise_sampling (v3) Stephane Eranian
2012-01-27  5:26   ` Anshuman Khandual
2012-01-09 16:49 ` [PATCH 05/13] perf_events: add LBR mappings for PERF_SAMPLE_BRANCH filters (v3) Stephane Eranian
2012-01-27  5:41   ` Anshuman Khandual
2012-01-09 16:49 ` [PATCH 06/13] perf_events: disable LBR support for older Intel Atom processors (v3) Stephane Eranian
2012-01-27  5:43   ` Anshuman Khandual
2012-01-09 16:49 ` [PATCH 07/13] perf_events: implement PERF_SAMPLE_BRANCH for Intel X86 (v3) Stephane Eranian
2012-01-27  6:14   ` Anshuman Khandual
2012-01-09 16:49 ` [PATCH 08/13] perf_events: add LBR software filter support " Stephane Eranian
2012-01-09 16:49 ` [PATCH 09/13] perf_events: disable PERF_SAMPLE_BRANCH_* when not supported (v3) Stephane Eranian
2012-01-27  7:15   ` Anshuman Khandual [this message]
2012-01-27  9:56     ` Stephane Eranian
2012-01-09 16:49 ` [PATCH 10/13] perf_events: add hook to flush branch_stack on context switch (v3) Stephane Eranian
2012-01-09 16:49 ` [PATCH 11/13] perf: add code to support PERF_SAMPLE_BRANCH_STACK (v3) Stephane Eranian
2012-01-10  1:25   ` Arun Sharma
2012-01-10 15:43     ` Stephane Eranian
2012-01-09 16:49 ` [PATCH 12/13] perf: add support for sampling taken branch to perf record (v3) Stephane Eranian
2012-01-09 16:49 ` [PATCH 13/13] perf: add support for taken branch sampling to perf report (v3) Stephane Eranian
2012-01-23 10:14 ` [PATCH 00/13] perf_events: add support for sampling taken branches (v3) Stephane Eranian
2012-01-23 12:25   ` Peter Zijlstra
2012-01-23 15:07     ` Stephane Eranian
2012-01-23 15:47       ` Andi Kleen
2012-01-23 17:14     ` Stephane Eranian
2012-01-24 15:39       ` Stephane Eranian
2012-01-24 16:08         ` David Ahern
2012-01-24 17:42           ` Stephane Eranian
2012-01-26 16:21           ` Stephane Eranian
2012-01-27 12:09 ` Peter Zijlstra
2012-01-27 18:20   ` Arun Sharma

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=4F224EF9.5040307@linux.vnet.ibm.com \
    --to=khandual@linux.vnet.ibm.com \
    --cc=acme@infradead.org \
    --cc=andi@firstfloor.org \
    --cc=asharma@fb.com \
    --cc=eranian@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.m.lin@intel.com \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=ravitillo@lbl.gov \
    --cc=robert.richter@amd.com \
    --cc=vweaver1@eecs.utk.edu \
    /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

Powered by JetHome