All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Yang Weijiang <weijiang.yang@intel.com>
Cc: pbonzini@redhat.com, kvm@vger.kernel.org
Subject: Re: [kvm-unit-tests PATCH v4 1/2] x86: Skip perf related tests when platform cannot support
Date: Thu, 7 Jul 2022 20:26:19 +0000	[thread overview]
Message-ID: <YsdBa6BNrwdwBMPI@google.com> (raw)
In-Reply-To: <20220628093203.73160-1-weijiang.yang@intel.com>

On Tue, Jun 28, 2022, Yang Weijiang wrote:
> Add helpers to check whether MSR_CORE_PERF_GLOBAL_CTRL and rdpmc
> are supported in KVM. When pmu is disabled with enable_pmu=0,
> reading MSR_CORE_PERF_GLOBAL_CTRL or executing rdpmc leads to #GP,
> so skip related tests in this case to avoid test failure.
> 
> Opportunistically replace some "printf" with "report_skip" to make
> the output log clean.

Ooof, these end up dominating the patch.  Can you split them to a separate prep
patch?  Thanks!

> Suggested-by: Sean Christopherson <seanjc@google.com>
> Signed-off-by: Yang Weijiang <weijiang.yang@intel.com>
> 
> v4:
> - Use supported_fn() to make the code nicer. [Sean]
> - Replace some of the printf with report_skip to make the results clean. [Sean]

Put the versioning info below the three dashes so that it doesn't show up in the
final changelog.

> ---

<version info goes here>

>  lib/x86/processor.h | 10 ++++++++++
>  x86/vmx_tests.c     | 40 +++++++++++++++++++++++++++-------------
>  2 files changed, 37 insertions(+), 13 deletions(-)
> 
> diff --git a/lib/x86/processor.h b/lib/x86/processor.h
> index 9a0dad6..7b6ee92 100644
> --- a/lib/x86/processor.h
> +++ b/lib/x86/processor.h
> @@ -690,4 +690,14 @@ static inline bool cpuid_osxsave(void)
>  	return cpuid(1).c & (1 << (X86_FEATURE_OSXSAVE % 32));
>  }
>  
> +static inline u8 pmu_version(void)
> +{
> +	return cpuid(10).a & 0xff;
> +}
> +
> +static inline bool cpu_has_perf_global_ctrl(void)
> +{
> +	return pmu_version() > 1;
> +}
> +
>  #endif
> diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
> index 4d581e7..3a14cb2 100644
> --- a/x86/vmx_tests.c
> +++ b/x86/vmx_tests.c
> @@ -852,6 +852,10 @@ static bool monitor_supported(void)
>  	return this_cpu_has(X86_FEATURE_MWAIT);
>  }
>  
> +static inline bool pmu_supported(void) {

Curly brace goes on a new line.

> +	return !!pmu_version();
> +}

Why not put this in processor.h?  And maybe call it cpu_has_pmu()?

  parent reply	other threads:[~2022-07-07 20:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-28  9:32 [kvm-unit-tests PATCH v4 1/2] x86: Skip perf related tests when platform cannot support Yang Weijiang
2022-06-28  9:32 ` [kvm-unit-tests PATCH v4 2/2] x86: Check platform vPMU capabilities before run lbr tests Yang Weijiang
2022-07-07 20:28   ` Sean Christopherson
2022-07-08  0:57     ` Yang, Weijiang
2022-07-07 20:26 ` Sean Christopherson [this message]
2022-07-08  0:48   ` [kvm-unit-tests PATCH v4 1/2] x86: Skip perf related tests when platform cannot support Yang, Weijiang

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=YsdBa6BNrwdwBMPI@google.com \
    --to=seanjc@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=weijiang.yang@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 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.