lkml.org 
[lkml]   [2014]   [Feb]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 07/14] perf: track number of events that use LBR callstack
From
On Fri, Jan 3, 2014 at 6:48 AM, Yan, Zheng <zheng.z.yan@intel.com> wrote:
> Later patch will use it to decide if the LBR stack should be saved/restored
>
You should describe better what this patch does. It should be repeated from
the patch title at least.

> Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
> ---
> arch/x86/kernel/cpu/perf_event_intel_lbr.c | 21 ++++++++++++++++++++-
> 1 file changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kernel/cpu/perf_event_intel_lbr.c b/arch/x86/kernel/cpu/perf_event_intel_lbr.c
> index bdd8758..2137a9f 100644
> --- a/arch/x86/kernel/cpu/perf_event_intel_lbr.c
> +++ b/arch/x86/kernel/cpu/perf_event_intel_lbr.c
> @@ -201,15 +201,27 @@ void intel_pmu_lbr_sched_task(struct perf_event_context *ctx, bool sched_in)
> intel_pmu_lbr_reset();
> }
>
> +static inline bool branch_user_callstack(unsigned br_sel)
> +{
> + return (br_sel & X86_BR_USER) && (br_sel & X86_BR_CALL_STACK);
> +}
> +
> void intel_pmu_lbr_enable(struct perf_event *event)
> {
> struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
> + struct x86_perf_task_context *task_ctx;
>
> if (!x86_pmu.lbr_nr)
> return;
>
> + cpuc = &__get_cpu_var(cpu_hw_events);
> + task_ctx = event->ctx ? event->ctx->task_ctx_data : NULL;
> +
> cpuc->br_sel = event->hw.branch_reg.reg;
>
> + if (branch_user_callstack(cpuc->br_sel))
> + task_ctx->lbr_callstack_users++;
> +
> cpuc->lbr_users++;
> if (cpuc->lbr_users == 1)
> perf_sched_cb_enable(event->ctx->pmu);
> @@ -217,11 +229,18 @@ void intel_pmu_lbr_enable(struct perf_event *event)
>
> void intel_pmu_lbr_disable(struct perf_event *event)
> {
> - struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
> + struct cpu_hw_events *cpuc;
> + struct x86_perf_task_context *task_ctx;
>
> if (!x86_pmu.lbr_nr)
> return;
>
> + cpuc = &__get_cpu_var(cpu_hw_events);
> + task_ctx = event->ctx ? event->ctx->task_ctx_data : NULL;
> +
> + if (branch_user_callstack(cpuc->br_sel))
> + task_ctx->lbr_callstack_users--;
> +
> cpuc->lbr_users--;
> WARN_ON_ONCE(cpuc->lbr_users < 0);
>
> --
> 1.8.4.2
>


\
 
 \ /
  Last update: 2014-02-06 16:41    [W:0.744 / U:0.256 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site