mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Andi Kleen <andi@firstfloor.org>
Cc: acme@kernel.org, jolsa@kernel.org, linux-kernel@vger.kernel.org,
	Andi Kleen <ak@linux.intel.com>, Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH 5/5] x86, perf: Avoid context switching LBR_INFO when not needed
Date: Wed, 21 Oct 2015 15:44:52 +0200	[thread overview]
Message-ID: <20151021134452.GG3604@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1445366797-30894-5-git-send-email-andi@firstfloor.org>

On Tue, Oct 20, 2015 at 11:46:37AM -0700, Andi Kleen wrote:
> +++ b/arch/x86/kernel/cpu/perf_event_intel.c
> @@ -2844,7 +2844,7 @@ static void intel_pmu_cpu_starting(int cpu)
>  	/*
>  	 * Deal with CPUs that don't clear their LBRs on power-up.
>  	 */
> -	intel_pmu_lbr_reset();
> +	intel_pmu_lbr_reset(1);

s/1/true/ ?


> @@ -242,7 +245,7 @@ static void __intel_pmu_lbr_restore(struct x86_perf_task_context *task_ctx)
>  
>  	if (task_ctx->lbr_callstack_users == 0 ||
>  	    task_ctx->lbr_stack_state == LBR_NONE) {
> -		intel_pmu_lbr_reset();
> +		intel_pmu_lbr_reset(task_ctx->need_info > 0);
>  		return;
>  	}
>
> @@ -317,7 +320,7 @@ void intel_pmu_lbr_sched_task(struct perf_event_context *ctx, bool sched_in)
>  	 * stack with branch from multiple tasks.
>   	 */
>  	if (sched_in) {
> -		intel_pmu_lbr_reset();
> +		intel_pmu_lbr_reset(!task_ctx || task_ctx->need_info > 0);
>  		cpuc->lbr_context = ctx;
>  	}
>  }
> @@ -340,7 +343,7 @@ void intel_pmu_lbr_enable(struct perf_event *event)
>  	 * avoid data leaks.
>  	 */
>  	if (event->ctx->task && cpuc->lbr_context != event->ctx) {
> -		intel_pmu_lbr_reset();
> +		intel_pmu_lbr_reset(!(event->hw.branch_reg.reg & LBR_NO_INFO));
>  		cpuc->lbr_context = event->ctx;
>  	}
>  	cpuc->br_sel = event->hw.branch_reg.reg;

Are you sure none of that will result in some data leak in a weird corner
case?

  reply	other threads:[~2015-10-21 13:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-20 18:46 [PATCH 1/5] x86, perf: Fix LBR call stack save/restore Andi Kleen
2015-10-20 18:46 ` [PATCH 2/5] x86, perf: Add option to disable reading branch flags/cycles Andi Kleen
2015-11-23 16:25   ` [tip:perf/core] perf/x86: " tip-bot for Andi Kleen
2015-10-20 18:46 ` [PATCH 3/5] perf, tools: Disable branch flags/cycles for --callgraph lbr Andi Kleen
2015-10-21 13:27   ` Peter Zijlstra
2015-10-21 18:04     ` Arnaldo Carvalho de Melo
2015-10-20 18:46 ` [PATCH 4/5] perf, tools: Print branch filter state with -vv Andi Kleen
2015-10-20 18:51   ` Arnaldo Carvalho de Melo
2015-10-21  8:27     ` Peter Zijlstra
2015-10-22  9:23   ` [tip:perf/core] perf evsel: " tip-bot for Andi Kleen
2015-10-20 18:46 ` [PATCH 5/5] x86, perf: Avoid context switching LBR_INFO when not needed Andi Kleen
2015-10-21 13:44   ` Peter Zijlstra [this message]
2015-10-21 13:13 ` [PATCH 1/5] x86, perf: Fix LBR call stack save/restore Peter Zijlstra
2015-10-21 14:35   ` Andi Kleen
2015-10-21 16:24   ` Ingo Molnar
2015-11-23 16:20 ` [tip:perf/core] perf/x86: " tip-bot for Andi Kleen

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=20151021134452.GG3604@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=andi@firstfloor.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.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

Powered by JetHome