From: Ingo Molnar <mingo@kernel.org>
To: Robert O'Callahan <robert@ocallahan.org>
Cc: kvm@vger.kernel.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Ingo Molnar" <mingo@redhat.com>,
"H . Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: x86: never specify a sample period for virtualized in_tx_cp counters
Date: Tue, 31 Jan 2017 08:34:10 +0100 [thread overview]
Message-ID: <20170131073410.GC11851@gmail.com> (raw)
In-Reply-To: <20170131014813.15220-1-robert@ocallahan.org>
* Robert O'Callahan <robert@ocallahan.org> wrote:
> pmc_reprogram_counter() always sets a sample period based on the value of
> pmc->counter. However, hsw_hw_config() rejects sample periods less than
> 2^31 - 1. So for example, a KVM guest doing
> perf stat -e r2005101c4 sleep 0
> will count some conditional branch events, deschedule the task, reschedule
> the task, try to restore the guest PMU state for the task, in the host
> reach pmc_reprogram_counter() with nonzero pmc->count, trigger EOPNOTSUPP
> in hsw_hw_config(), print "kvm_pmu: event creation failed" in
> pmc_reprogram_counter(), and silently (from the guest's point of view) stop
> counting events.
>
> We fix event counting by forcing attr.sample_period to always be zero for
> in_tx_cp counters. Sampling doesn't work, but it already didn't work and
> can't be fixed without major changes to the approach in hsw_hw_config().
>
> Signed-off-by: Robert O'Callahan <robert@ocallahan.org>
> ---
> arch/x86/kvm/pmu.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c
> index 06ce377..af993d7 100644
> --- a/arch/x86/kvm/pmu.c
> +++ b/arch/x86/kvm/pmu.c
> @@ -113,12 +113,18 @@ static void pmc_reprogram_counter(struct kvm_pmc *pmc, u32 type,
> .config = config,
> };
>
> + attr.sample_period = (-pmc->counter) & pmc_bitmask(pmc);
> +
> if (in_tx)
> attr.config |= HSW_IN_TX;
> - if (in_tx_cp)
> + if (in_tx_cp) {
> + /* HSW_IN_TX_CHECKPOINTED is not supported with nonzero
> + * period. Just clear the sample period so at least
> + * allocating the counter doesn't fail.
> + */
> + attr.sample_period = 0;
> attr.config |= HSW_IN_TX_CHECKPOINTED;
> -
> - attr.sample_period = (-pmc->counter) & pmc_bitmask(pmc);
> + }
please use the customary (multi-line) comment style:
/*
* Comment .....
* ...... goes here.
*/
specified in Documentation/CodingStyle.
Thanks,
Ingo
prev parent reply other threads:[~2017-01-31 7:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-31 1:48 [PATCH] KVM: x86: never specify a sample period for virtualized in_tx_cp counters Robert O'Callahan
2017-01-31 7:34 ` Ingo Molnar [this message]
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=20170131073410.GC11851@gmail.com \
--to=mingo@kernel.org \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=robert@ocallahan.org \
--cc=tglx@linutronix.de \
--cc=x86@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.