linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Liang, Kan" <kan.liang@intel.com>
To: Jiri Olsa <jolsa@redhat.com>
Cc: "a.p.zijlstra@chello.nl" <a.p.zijlstra@chello.nl>,
	"eranian@google.com" <eranian@google.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"paulus@samba.org" <paulus@samba.org>,
	"acme@kernel.org" <acme@kernel.org>,
	"ak@linux.intel.com" <ak@linux.intel.com>,
	"Yan, Zheng" <zheng.z.yan@intel.com>
Subject: RE: [PATCH V6 13/17] perf, x86: enable LBR callstack when recording callchain
Date: Fri, 24 Oct 2014 14:49:52 +0000	[thread overview]
Message-ID: <37D7C6CF3E00A74B8858931C1DB2F0770164929D@SHSMSX103.ccr.corp.intel.com> (raw)
In-Reply-To: <20141024133936.GD1036@krava.brq.redhat.com>



> 
> On Sun, Oct 19, 2014 at 05:55:08PM -0400, Kan Liang wrote:
> > Only enable LBR callstack when user requires fp callgraph. The feature
> > is not available when PERF_SAMPLE_BRANCH_STACK or
> > PERF_SAMPLE_STACK_USER is required.
> > Also, this feature only affects how to get user callchain. The kernel
> > callchain is always got by frame pointers.
> >
> > Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
> > Signed-off-by: Kan Liang <kan.liang@intel.com>
> > ---
> >  arch/x86/kernel/cpu/perf_event.c | 18 ++++++++++++++++--
> >  1 file changed, 16 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/x86/kernel/cpu/perf_event.c
> > b/arch/x86/kernel/cpu/perf_event.c
> > index 9656b9e..b3256a3 100644
> > --- a/arch/x86/kernel/cpu/perf_event.c
> > +++ b/arch/x86/kernel/cpu/perf_event.c
> > @@ -424,10 +424,24 @@ int x86_pmu_hw_config(struct perf_event
> *event)
> >  			if (!event->attr.exclude_kernel)
> >  				*br_type |=
> PERF_SAMPLE_BRANCH_KERNEL;
> >  		}
> > -	}
> > +	} else if (x86_pmu_has_lbr_callstack() &&
> > +		   (event->attr.sample_type & PERF_SAMPLE_CALLCHAIN)
> &&
> > +		   !(event->attr.sample_type & PERF_SAMPLE_STACK_USER)
> &&
> > +		   !has_branch_stack(event) &&
> > +		   !event->attr.exclude_user &&
> > +		   (event->attach_state & PERF_ATTACH_TASK)) {
> > +		/*
> > +		 * user did not specify branch_sample_type,
> > +		 * try using the LBR call stack facility to
> > +		 * record call chains of user program.
> > +		 */
> > +		event->attr.branch_sample_type =
> > +			PERF_SAMPLE_BRANCH_USER |
> > +			PERF_SAMPLE_BRANCH_CALL_STACK;
> >
> 
> I dont see PERF_SAMPLE_BRANCH_CALL_STACK being defind in uapi.. any
> reason why I cant enable this feature explicitly?


The LBR call stack has some limitations. E.g. the feature is only for HSW+.
It is only available for user callchain. We cannot collect branch information
and call chain by LBR at the same time.. So the feature is designed as
an alternative way to get callgraph, and it isn't exposed to enable.
Otherwise, it may confuse the user. He enables the BRANCH_CALL_STACK, 
but the data is only partly or even not at all from hardware.

We have an option for perf report, the user can choose the preferred data
source. User can set it to LBR. So it tries LBR data first. If not available, it
tries FP then. The user cannot lose any callchain data. 

Thanks,
Kan

> 
> thanks,
> jirka

  reply	other threads:[~2014-10-24 14:50 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-19 21:54 [PATCH V6 00/17] perf, x86: Haswell LBR call stack support Kan Liang
2014-10-19 21:54 ` [PATCH V6 01/17] perf, x86: Reduce lbr_sel_map size Kan Liang
2014-10-24  9:39   ` Peter Zijlstra
2014-11-04  1:07     ` Liang, Kan
2014-11-04  7:14       ` Peter Zijlstra
2014-11-04  7:16         ` Peter Zijlstra
2014-10-19 21:54 ` [PATCH V6 02/17] perf, core: introduce pmu context switch callback Kan Liang
2014-10-19 21:54 ` [PATCH V6 03/17] perf, x86: use context switch callback to flush LBR stack Kan Liang
2014-10-19 21:54 ` [PATCH V6 04/17] perf, x86: Basic Haswell LBR call stack support Kan Liang
2014-10-19 21:55 ` [PATCH V6 05/17] perf, core: pmu specific data for perf task context Kan Liang
2014-10-19 21:55 ` [PATCH V6 06/17] perf, core: always switch pmu specific data during context switch Kan Liang
2014-10-19 21:55 ` [PATCH V6 07/17] perf, x86: allocate space for storing LBR stack Kan Liang
2014-10-19 21:55 ` [PATCH V6 08/17] perf, x86: track number of events that use LBR callstack Kan Liang
2014-10-19 21:55 ` [PATCH V6 09/17] perf, x86: Save/resotre LBR stack during context switch Kan Liang
2014-10-19 21:55 ` [PATCH V6 10/17] perf, core: simplify need branch stack check Kan Liang
2014-10-19 21:55 ` [PATCH V6 11/17] perf, core: expose LBR call stack to user perf tool Kan Liang
2014-10-19 21:55 ` [PATCH V6 12/17] perf, x86: re-organize code that implicitly enables LBR/PEBS Kan Liang
2014-10-19 21:55 ` [PATCH V6 13/17] perf, x86: enable LBR callstack when recording callchain Kan Liang
2014-10-24 13:39   ` Jiri Olsa
2014-10-24 14:49     ` Liang, Kan [this message]
2014-10-19 21:55 ` [PATCH V6 14/17] perf, x86: disable FREEZE_LBRS_ON_PMI when LBR operates in callstack mode Kan Liang
2014-10-19 21:55 ` [PATCH V6 15/17] perf, x86: Discard zero length call entries in LBR call stack Kan Liang
2014-10-19 21:55 ` [PATCH V6 16/17] perf tools: handle LBR call stack data Kan Liang
2014-10-19 21:55 ` [PATCH V6 17/17] perf tools: choose to dump callchain from LBR and FP Kan Liang
2014-10-24 13:36   ` Jiri Olsa
2014-10-24 13:55     ` Jiri Olsa
2014-10-24 15:20       ` Liang, Kan

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=37D7C6CF3E00A74B8858931C1DB2F0770164929D@SHSMSX103.ccr.corp.intel.com \
    --to=kan.liang@intel.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=eranian@google.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=paulus@samba.org \
    --cc=zheng.z.yan@intel.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 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).