From: Sean Christopherson <seanjc@google.com>
To: Like Xu <like.xu.linux@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>, kvm@vger.kernel.org
Subject: Re: [kvm-unit-tests PATCH v3 03/13] x86/pmu: Reset the expected count of the fixed counter 0 when i386
Date: Wed, 5 Oct 2022 22:18:31 +0000 [thread overview]
Message-ID: <Yz4Ct/rxI2EZ+I7o@google.com> (raw)
In-Reply-To: <20220819110939.78013-4-likexu@tencent.com>
On Fri, Aug 19, 2022, Like Xu wrote:
> From: Like Xu <likexu@tencent.com>
>
> The pmu test check_counter_overflow() always fails with the "./configure
> --arch=i386".
Explicitly state that the failures are with 32-bit binaries. E.g. I can and do
run KUT in 32-bit VMs, which doesn't require the explicit --arch=i386.
> The cnt.count obtained from the latter run of measure()
> (based on fixed counter 0) is not equal to the expected value (based
> on gp counter 0) and there is a positive error with a value of 2.
>
> The two extra instructions come from inline wrmsr() and inline rdmsr()
> inside the global_disable() binary code block. Specifically, for each msr
> access, the i386 code will have two assembly mov instructions before
> rdmsr/wrmsr (mark it for fixed counter 0, bit 32), but only one assembly
> mov is needed for x86_64 and gp counter 0 on i386.
>
> Fix the expected init cnt.count for fixed counter 0 overflow based on
> the same fixed counter 0, not always using gp counter 0.
You lost me here. I totally understand the problem, but I don't understand the
fix.
> Signed-off-by: Like Xu <likexu@tencent.com>
> ---
> x86/pmu.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/x86/pmu.c b/x86/pmu.c
> index 45ca2c6..057fd4a 100644
> --- a/x86/pmu.c
> +++ b/x86/pmu.c
> @@ -315,6 +315,9 @@ static void check_counter_overflow(void)
>
> if (i == nr_gp_counters) {
> cnt.ctr = fixed_events[0].unit_sel;
> + __measure(&cnt, 0);
> + count = cnt.count;
> + cnt.count = 1 - count;
This definitely needs a comment.
Dumb question time: if the count is off by 2, why can't we just subtract 2?
#ifndef __x86_64__
/* comment about extra MOV insns for RDMSR/WRMSR */
cnt.count -= 2;
#endif
> cnt.count &= (1ull << pmu_fixed_counter_width()) - 1;
> }
>
> --
> 2.37.2
>
next prev parent reply other threads:[~2022-10-05 22:18 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-19 11:09 [kvm-unit-tests PATCH v3 00/13] x86/pmu: Test case optimization, fixes and additions Like Xu
2022-08-19 11:09 ` [kvm-unit-tests PATCH v3 01/13] x86/pmu: Introduce __start_event() to drop all of the manual zeroing Like Xu
2022-08-19 11:09 ` [kvm-unit-tests PATCH v3 02/13] x86/pmu: Introduce multiple_{one, many}() to improve readability Like Xu
2022-08-19 11:09 ` [kvm-unit-tests PATCH v3 03/13] x86/pmu: Reset the expected count of the fixed counter 0 when i386 Like Xu
2022-10-05 22:18 ` Sean Christopherson [this message]
2022-10-17 7:30 ` Like Xu
2022-10-21 19:16 ` Sean Christopherson
2022-08-19 11:09 ` [kvm-unit-tests PATCH v3 04/13] x86/pmu: Add tests for Intel Processor Event Based Sampling (PEBS) Like Xu
2022-10-05 22:21 ` Sean Christopherson
2022-10-05 22:22 ` Sean Christopherson
2022-08-19 11:09 ` [kvm-unit-tests PATCH v3 05/13] x86: create pmu group for quick pmu-scope testing Like Xu
2022-10-05 22:23 ` Sean Christopherson
2022-08-19 11:09 ` [kvm-unit-tests PATCH v3 06/13] x86/pmu: Test emulation instructions on full-width counters Like Xu
2022-08-19 11:09 ` [kvm-unit-tests PATCH v3 07/13] x86/pmu: Pop up FW prefix to avoid out-of-context propagation Like Xu
2022-10-05 22:25 ` Sean Christopherson
2022-08-19 11:09 ` [kvm-unit-tests PATCH v3 08/13] x86/pmu: Add PDCM check before accessing PERF_CAP register Like Xu
2022-10-05 22:28 ` Sean Christopherson
2022-08-19 11:09 ` [kvm-unit-tests PATCH v3 09/13] x86/pmu: Report SKIP when testing Intel LBR on AMD platforms Like Xu
2022-10-05 22:29 ` Sean Christopherson
2022-08-19 11:09 ` [kvm-unit-tests PATCH v3 10/13] x86/pmu: Update testcases to cover Intel Arch PMU Version 1 Like Xu
2022-09-06 7:15 ` Sandipan Das
2022-09-06 13:28 ` Like Xu
2022-09-06 8:16 ` Sandipan Das
2022-09-06 13:35 ` Like Xu
2022-09-08 8:23 ` Sandipan Das
2022-09-19 7:09 ` Like Xu
2022-10-21 7:32 ` Like Xu
2022-10-25 8:34 ` Sandipan Das
2022-10-05 22:35 ` Sean Christopherson
2022-10-18 9:32 ` Like Xu
2022-08-19 11:09 ` [kvm-unit-tests PATCH v3 11/13] x86/pmu: Refine message when testing PMU on AMD platforms Like Xu
2022-08-19 11:09 ` [kvm-unit-tests PATCH v3 12/13] x86/pmu: Add assignment framework for Intel-specific HW resources Like Xu
2022-09-06 7:19 ` Sandipan Das
2022-10-05 22:44 ` Sean Christopherson
2022-10-21 7:21 ` Like Xu
2022-10-21 18:22 ` Sean Christopherson
2022-08-19 11:09 ` [kvm-unit-tests PATCH v3 13/13] x86/pmu: Update testcases to cover AMD PMU Like Xu
2022-09-06 7:32 ` Sandipan Das
2022-10-05 22:48 ` Sean Christopherson
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=Yz4Ct/rxI2EZ+I7o@google.com \
--to=seanjc@google.com \
--cc=kvm@vger.kernel.org \
--cc=like.xu.linux@gmail.com \
--cc=pbonzini@redhat.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 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.