public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: "Yan, Zheng" <zheng.z.yan@intel.com>
Cc: linux-kernel@vger.kernel.org, mingo@kernel.org,
	acme@infradead.org, eranian@google.com, andi@firstfloor.org
Subject: Re: [PATCH v2 5/7] perf, x86: drain PEBS buffer during context switch
Date: Tue, 15 Jul 2014 13:57:17 +0200	[thread overview]
Message-ID: <20140715115717.GE9918@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1405414739-31455-6-git-send-email-zheng.z.yan@intel.com>

[-- Attachment #1: Type: text/plain, Size: 2240 bytes --]

On Tue, Jul 15, 2014 at 04:58:57PM +0800, Yan, Zheng wrote:
> +void intel_pmu_drain_pebs_buffer(void)
> +{
> +	struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
> +	struct debug_store *ds = cpuc->ds;
> +	struct pt_regs regs;
> +
> +	if (!x86_pmu.pebs_active)
> +		return;
> +	if (ds->pebs_index <= ds->pebs_buffer_base)
> +		return;

Both implementations of drain_pebs() already do that.

> +	x86_pmu.drain_pebs(&regs);
> +}

> @@ -759,8 +787,19 @@ void intel_pmu_pebs_disable(struct perf_event *event)
>  {
>  	struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
>  	struct hw_perf_event *hwc = &event->hw;
> +	struct debug_store *ds = cpuc->ds;
> +	bool multi_pebs = false;
> +
> +	if (ds->pebs_interrupt_threshold >
> +	    ds->pebs_buffer_base + x86_pmu.pebs_record_size)
> +		multi_pebs = true;
>  
>  	cpuc->pebs_enabled &= ~(1ULL << hwc->idx);
> +	if (cpuc->pebs_sched_cb_enabled &&
> +	    !(cpuc->pebs_enabled & ((1ULL << MAX_PEBS_EVENTS) - 1))) {

You seem fond of that expression, maybe make it an inline somewhere to
avoid all this repetition.

> +		perf_sched_cb_disable(event->ctx->pmu);
> +		cpuc->pebs_sched_cb_enabled = false;
> +	}
>  
>  	if (event->hw.constraint->flags & PERF_X86_EVENT_PEBS_LDLAT)
>  		cpuc->pebs_enabled &= ~(1ULL << (hwc->idx + 32));
> @@ -772,6 +811,9 @@ void intel_pmu_pebs_disable(struct perf_event *event)
>  
>  	hwc->config |= ARCH_PERFMON_EVENTSEL_INT;
>  	hwc->autoreload = false;
> +
> +	if (multi_pebs)
> +		intel_pmu_drain_pebs_buffer();
>  }

Is that condition worth the effort? Seeing how you already need to load
the DS state to compute multi_pebs in the first place.

> diff --git a/arch/x86/kernel/cpu/perf_event_intel_lbr.c b/arch/x86/kernel/cpu/perf_event_intel_lbr.c
> index 430f1ad..a3df61d 100644
> --- a/arch/x86/kernel/cpu/perf_event_intel_lbr.c
> +++ b/arch/x86/kernel/cpu/perf_event_intel_lbr.c
> @@ -199,8 +199,6 @@ void intel_pmu_lbr_enable(struct perf_event *event)
>  {
>  	struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
>  
> -	if (!x86_pmu.lbr_nr)
> -		return;
>  	/*
>  	 * Reset the LBR stack if we changed task context to
>  	 * avoid data leaks.

More random hunks?

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2014-07-15 11:57 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-15  8:58 [PATCH v2 0/7] perf, x86: large PEBS interrupt threshold Yan, Zheng
2014-07-15  8:58 ` [PATCH v2 1/7] perf, core: introduce pmu context switch callback Yan, Zheng
2014-07-15 11:39   ` Peter Zijlstra
2014-07-15  8:58 ` [PATCH v2 2/7] perf, x86: use context switch callback to flush LBR stack Yan, Zheng
2014-07-15  8:58 ` [PATCH v2 3/7] perf, x86: use the PEBS auto reload mechanism when possible Yan, Zheng
2014-07-15 10:14   ` Peter Zijlstra
2014-07-15  8:58 ` [PATCH v2 4/7] perf, x86: large PEBS interrupt threshold Yan, Zheng
2014-07-15 10:41   ` Peter Zijlstra
2014-07-15 11:38   ` Peter Zijlstra
2014-07-15  8:58 ` [PATCH v2 5/7] perf, x86: drain PEBS buffer during context switch Yan, Zheng
2014-07-15 11:57   ` Peter Zijlstra [this message]
2014-07-15  8:58 ` [PATCH v2 6/7] perf, x86: enable large PEBS interrupt threshold for SNB/IVB/HSW Yan, Zheng
2014-07-15 11:12   ` Peter Zijlstra
2014-07-15  8:58 ` [PATCH v2 7/7] tools, perf: Allow the user to disable time stamps Yan, Zheng
2014-07-15 10:02 ` [PATCH v2 0/7] perf, x86: large PEBS interrupt threshold Peter Zijlstra
2014-07-16  1:12   ` Yan, Zheng

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=20140715115717.GE9918@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=acme@infradead.org \
    --cc=andi@firstfloor.org \
    --cc=eranian@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.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