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 V4 15/16] perf, x86: disable FREEZE_LBRS_ON_PMI when LBR operates in callstack mode
Date: Wed, 2 Jul 2014 13:13:26 +0200 [thread overview]
Message-ID: <20140702111326.GD6758@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1404118253-19532-16-git-send-email-zheng.z.yan@intel.com>
[-- Attachment #1: Type: text/plain, Size: 2670 bytes --]
On Mon, Jun 30, 2014 at 04:50:52PM +0800, Yan, Zheng wrote:
> LBR callstack is designed for PEBS, It does not work well with
> FREEZE_LBRS_ON_PMI for non PEBS event. If FREEZE_LBRS_ON_PMI is set for
> non PEBS event, PMIs near call/return instructions may cause superfluous
> increase/decrease of LBR_TOS.
>
> This patch modifies __intel_pmu_lbr_enable() to not enable
> FREEZE_LBRS_ON_PMI when LBR operates in callstack mode. We currently
> don't use LBR callstack to capture kernel space callchain, so disabling
> FREEZE_LBRS_ON_PMI should not be a problem.
>
> Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
> ---
> arch/x86/kernel/cpu/perf_event_intel_lbr.c | 9 ++++++++-
> 1 file changed, 8 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 f059b98..dd14f67 100644
> --- a/arch/x86/kernel/cpu/perf_event_intel_lbr.c
> +++ b/arch/x86/kernel/cpu/perf_event_intel_lbr.c
> @@ -138,7 +138,14 @@ static void __intel_pmu_lbr_enable(void)
> wrmsrl(MSR_LBR_SELECT, cpuc->lbr_sel->config);
>
> rdmsrl(MSR_IA32_DEBUGCTLMSR, debugctl);
> - debugctl |= (DEBUGCTLMSR_LBR | DEBUGCTLMSR_FREEZE_LBRS_ON_PMI);
> + debugctl |= DEBUGCTLMSR_LBR;
> + /*
> + * LBR callstack does not work well with FREEZE_LBRS_ON_PMI.
> + * If FREEZE_LBRS_ON_PMI is set, PMI near call/return instructions
> + * may cause superfluous increase/decrease of LBR_TOS.
> + */
> + if (!cpuc->lbr_sel || !(cpuc->lbr_sel->config & LBR_CALL_STACK))
> + debugctl |= DEBUGCTLMSR_FREEZE_LBRS_ON_PMI;
> wrmsrl(MSR_IA32_DEBUGCTLMSR, debugctl);
Something like so perhaps? Its slightly bigger, but less messy.
diff --git a/arch/x86/kernel/cpu/perf_event_intel_lbr.c b/arch/x86/kernel/cpu/perf_event_intel_lbr.c
index 9dd2459a4c73..a55670529b9e 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_lbr.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_lbr.c
@@ -132,14 +132,18 @@ static void intel_pmu_lbr_filter(struct cpu_hw_events *cpuc);
static void __intel_pmu_lbr_enable(void)
{
- u64 debugctl;
struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
+ u64 debugctl, lbr_select = 0;
- if (cpuc->lbr_sel)
- wrmsrl(MSR_LBR_SELECT, cpuc->lbr_sel->config);
+ if (cpuc->lbr_sel) {
+ lbr_select = cpuc->lbr_sel->config;
+ wrmsrl(MSR_LBR_SELECT, lbr_config);
+ }
rdmsrl(MSR_IA32_DEBUGCTLMSR, debugctl);
- debugctl |= (DEBUGCTLMSR_LBR | DEBUGCTLMSR_FREEZE_LBRS_ON_PMI);
+ debugctl |= DEBUGCTLMSR_LBR;
+ if (!(lbr_select & LBR_CALL_STACK))
+ debugctl |= DEBUGCTLMSR_FREEZE_LBRS_ON_PMI;
wrmsrl(MSR_IA32_DEBUGCTLMSR, debugctl);
}
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2014-07-02 11:13 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-30 8:50 [PATCH V4 00/16] perf, x86: Haswell LBR call stack support Yan, Zheng
2014-06-30 8:50 ` [PATCH V4 01/16] perf, x86: Reduce lbr_sel_map size Yan, Zheng
2014-06-30 8:50 ` [PATCH V4 02/16] perf, core: introduce pmu context switch callback Yan, Zheng
2014-07-02 8:48 ` Peter Zijlstra
2014-07-02 10:12 ` Peter Zijlstra
2014-07-03 5:47 ` Yan, Zheng
2014-06-30 8:50 ` [PATCH V4 03/16] perf, x86: use context switch callback to flush LBR stack Yan, Zheng
2014-07-02 9:06 ` Peter Zijlstra
2014-07-03 5:44 ` Yan, Zheng
2014-06-30 8:50 ` [PATCH V4 04/16] perf, x86: Basic Haswell LBR call stack support Yan, Zheng
2014-07-02 10:14 ` Peter Zijlstra
2014-06-30 8:50 ` [PATCH V4 05/16] perf, core: pmu specific data for perf task context Yan, Zheng
2014-07-02 10:18 ` Peter Zijlstra
2014-06-30 8:50 ` [PATCH V4 06/16] perf, core: always switch pmu specific data during context switch Yan, Zheng
2014-07-02 10:19 ` Peter Zijlstra
2014-06-30 8:50 ` [PATCH V4 07/16] perf, x86: track number of events that use LBR callstack Yan, Zheng
2014-07-02 10:21 ` Peter Zijlstra
2014-07-03 5:59 ` Yan, Zheng
2014-07-02 10:25 ` Peter Zijlstra
2014-06-30 8:50 ` [PATCH V4 08/16] perf, x86: allocate space for storing LBR stack Yan, Zheng
2014-06-30 8:50 ` [PATCH V4 09/16] perf, x86: Save/resotre LBR stack during context switch Yan, Zheng
2014-07-02 10:49 ` Peter Zijlstra
2014-06-30 8:50 ` [PATCH V4 10/16] perf, core: simplify need branch stack check Yan, Zheng
2014-07-02 10:57 ` Peter Zijlstra
2014-07-02 11:08 ` Stephane Eranian
2014-07-02 12:27 ` Peter Zijlstra
2014-07-02 13:00 ` Stephane Eranian
2014-07-02 13:28 ` Peter Zijlstra
2014-06-30 8:50 ` [PATCH V4 11/16] perf, core: Pass perf_sample_data to perf_callchain() Yan, Zheng
2014-06-30 8:50 ` [PATCH V4 12/16] perf, x86: use LBR call stack to get user callchain Yan, Zheng
2014-06-30 8:50 ` [PATCH V4 13/16] perf, x86: re-organize code that implicitly enables LBR/PEBS Yan, Zheng
2014-06-30 8:50 ` [PATCH V4 14/16] perf, x86: enable LBR callstack when recording callchain Yan, Zheng
2014-06-30 14:45 ` Andi Kleen
2014-06-30 8:50 ` [PATCH V4 15/16] perf, x86: disable FREEZE_LBRS_ON_PMI when LBR operates in callstack mode Yan, Zheng
2014-07-02 11:13 ` Peter Zijlstra [this message]
2014-06-30 8:50 ` [PATCH V4 16/16] perf, x86: Discard zero length call entries in LBR call stack Yan, Zheng
-- strict thread matches above, loose matches on Subject: below --
2014-03-17 5:57 [PATCH v4 00/16] perf, x86: Haswell LBR call stack support Yan, Zheng
2014-03-17 5:57 ` [PATCH v4 15/16] perf, x86: disable FREEZE_LBRS_ON_PMI when LBR operates in callstack mode 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=20140702111326.GD6758@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
Powered by JetHome