From: Peter Zijlstra <peterz@infradead.org>
To: kan.liang@intel.com
Cc: andi@firstfloor.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [PATCH V3 1/2] perf ignore LBR and offcore_rsp.
Date: Tue, 8 Jul 2014 11:29:23 +0200 [thread overview]
Message-ID: <20140708092923.GC6758@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1404740066-4374-1-git-send-email-kan.liang@intel.com>
[-- Attachment #1: Type: text/plain, Size: 1853 bytes --]
On Mon, Jul 07, 2014 at 06:34:25AM -0700, kan.liang@intel.com wrote:
> @@ -555,7 +577,11 @@ static inline void __x86_pmu_enable_event(struct hw_perf_event *hwc,
> {
> u64 disable_mask = __this_cpu_read(cpu_hw_events.perf_ctr_virt_mask);
>
> - if (hwc->extra_reg.reg)
> + if (hwc->extra_reg.reg &&
> + ((hwc->extra_reg.idx == EXTRA_REG_RSP_0) ?
> + x86_pmu.extra_msr_access[0] : true) &&
> + ((hwc->extra_reg.idx == EXTRA_REG_RSP_1) ?
> + x86_pmu.extra_msr_access[1] : true))
> wrmsrl(hwc->extra_reg.reg, hwc->extra_reg.config);
> wrmsrl(hwc->config_base, (hwc->config | enable_mask) & ~disable_mask);
> }
> diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
> index adb02aa..3d18765 100644
> --- a/arch/x86/kernel/cpu/perf_event_intel.c
> +++ b/arch/x86/kernel/cpu/perf_event_intel.c
> + /*
> + * Access extra MSR may cause #GP under certain circumstances.
> + * E.g. KVM doesn't support offcore event
> + * Check all extra_regs here.
> + */
> + if (x86_pmu.extra_regs) {
> + x86_pmu.extra_msr_access[0] =
> + check_msr(x86_pmu.extra_regs[EXTRA_REG_RSP_0].msr);
> +
> + /* Not all platforms have EXTRA_REG_RSP_1 */
> + if (x86_pmu.extra_regs[EXTRA_REG_RSP_1].idx == EXTRA_REG_RSP_1)
> + x86_pmu.extra_msr_access[1] =
> + check_msr(x86_pmu.extra_regs[EXTRA_REG_RSP_1].msr);
> + /*
> + * If there is no EXTRA_REG_RSP_1 support,
> + * just set the flag to be true.
> + * So it is ignored at the runtime check.
> + */
> + else
> + x86_pmu.extra_msr_access[1] = true;
> + }
This too is wrong in many ways; there's more than 2 extra_msrs on many
systems.
And the place you check is abysmal, if we know at init time that we
don't have those MSRs, WTF do you allow event creation that would use
them, only to then misbehave?
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2014-07-08 9:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-07 13:34 [PATCH V3 1/2] perf ignore LBR and offcore_rsp kan.liang
2014-07-07 13:34 ` [PATCH V3 2/2] kvm: ignore LBR and offcore rsp kan.liang
2014-07-08 9:25 ` [PATCH V3 1/2] perf ignore LBR and offcore_rsp Peter Zijlstra
2014-07-08 14:20 ` Liang, Kan
2014-07-08 9:29 ` Peter Zijlstra [this message]
2014-07-08 14:22 ` Liang, Kan
2014-07-08 14:31 ` Peter Zijlstra
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=20140708092923.GC6758@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=andi@firstfloor.org \
--cc=kan.liang@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.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