linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH] x86: pmu: Test WRMSR on a running counter
@ 2020-02-04  1:25 Eric Hankland
  2020-02-05 11:45 ` Vitaly Kuznetsov
  2020-02-05 14:56 ` Paolo Bonzini
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Hankland @ 2020-02-04  1:25 UTC (permalink / raw)
  To: Paolo Bonzini, Jim Mattson, Peter Shier; +Cc: linux-kernel, kvm, Eric Hankland

Ensure that the value of the counter was successfully set to 0 after
writing it while the counter was running.

Signed-off-by: Eric Hankland <ehankland@google.com>
---
 x86/pmu.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/x86/pmu.c b/x86/pmu.c
index cb8c9e3..8a77993 100644
--- a/x86/pmu.c
+++ b/x86/pmu.c
@@ -419,6 +419,21 @@ static void check_rdpmc(void)
 	report_prefix_pop();
 }
 
+static void check_running_counter_wrmsr(void)
+{
+	pmu_counter_t evt = {
+		.ctr = MSR_IA32_PERFCTR0,
+		.config = EVNTSEL_OS | EVNTSEL_USR | gp_events[1].unit_sel,
+		.count = 0,
+	};
+
+	start_event(&evt);
+	loop();
+	wrmsr(MSR_IA32_PERFCTR0, 0);
+	stop_event(&evt);
+	report("running counter wrmsr", evt.count < gp_events[1].min);
+}
+
 int main(int ac, char **av)
 {
 	struct cpuid id = cpuid(10);
@@ -453,6 +468,7 @@ int main(int ac, char **av)
 	check_counters_many();
 	check_counter_overflow();
 	check_gp_counter_cmask();
+	check_running_counter_wrmsr();
 
 	return report_summary();
 }


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [kvm-unit-tests PATCH] x86: pmu: Test WRMSR on a running counter
  2020-02-04  1:25 [kvm-unit-tests PATCH] x86: pmu: Test WRMSR on a running counter Eric Hankland
@ 2020-02-05 11:45 ` Vitaly Kuznetsov
  2020-02-05 14:56 ` Paolo Bonzini
  1 sibling, 0 replies; 3+ messages in thread
From: Vitaly Kuznetsov @ 2020-02-05 11:45 UTC (permalink / raw)
  To: Eric Hankland
  Cc: linux-kernel, kvm, Eric Hankland, Paolo Bonzini, Jim Mattson,
	Peter Shier

Eric Hankland <ehankland@google.com> writes:

> Ensure that the value of the counter was successfully set to 0 after
> writing it while the counter was running.
>
> Signed-off-by: Eric Hankland <ehankland@google.com>
> ---
>  x86/pmu.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
>
> diff --git a/x86/pmu.c b/x86/pmu.c
> index cb8c9e3..8a77993 100644
> --- a/x86/pmu.c
> +++ b/x86/pmu.c
> @@ -419,6 +419,21 @@ static void check_rdpmc(void)
>  	report_prefix_pop();
>  }
>  
> +static void check_running_counter_wrmsr(void)
> +{
> +	pmu_counter_t evt = {
> +		.ctr = MSR_IA32_PERFCTR0,
> +		.config = EVNTSEL_OS | EVNTSEL_USR | gp_events[1].unit_sel,
> +		.count = 0,
> +	};
> +
> +	start_event(&evt);
> +	loop();
> +	wrmsr(MSR_IA32_PERFCTR0, 0);
> +	stop_event(&evt);
> +	report("running counter wrmsr", evt.count < gp_events[1].min);
> +}
> +
>  int main(int ac, char **av)
>  {
>  	struct cpuid id = cpuid(10);
> @@ -453,6 +468,7 @@ int main(int ac, char **av)
>  	check_counters_many();
>  	check_counter_overflow();
>  	check_gp_counter_cmask();
> +	check_running_counter_wrmsr();
>  
>  	return report_summary();
>  }
>

You shall not pass [-Werror]:

gcc  -mno-red-zone -mno-sse -mno-sse2 -m64 -O1 -g -MMD -MF x86/.pmu.d -fno-strict-aliasing -Wall -Wwrite-strings -Wempty-body -Wuninitialized -Wignored-qualifiers -Werror  -fno-omit-frame-pointer    -Wno-frame-address   -fno-pic  -no-pie  -Wclobbered  -Wunused-but-set-parameter  -Wmissing-parameter-type  -Wold-style-declaration -Woverride-init -Wmissing-prototypes -Wstrict-prototypes -std=gnu99 -ffreestanding -I /home/vitty/workspace/Upstream/kvm-unit-tests/lib -I /home/vitty/workspace/Upstream/kvm-unit-tests/lib/x86 -I lib   -c -o x86/pmu.o x86/pmu.c
x86/pmu.c: In function ‘check_running_counter_wrmsr’:
x86/pmu.c:435:44: error: passing argument 2 of ‘report’ makes pointer from integer without a cast [-Werror=int-conversion]
  435 |  report("running counter wrmsr", evt.count < gp_events[1].min);
      |                                  ~~~~~~~~~~^~~~~~~~~~~~~~~~~~
      |                                            |
      |                                            int
In file included from /home/vitty/workspace/Upstream/kvm-unit-tests/lib/x86/processor.h:4,
                 from x86/pmu.c:3:
/home/vitty/workspace/Upstream/kvm-unit-tests/lib/libcflat.h:102:43: note: expected ‘const char *’ but argument is of type ‘int’
  102 | extern void report(bool pass, const char *msg_fmt, ...)
      |                               ~~~~~~~~~~~~^~~~~~~
cc1: all warnings being treated as errors


-- 
Vitaly


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [kvm-unit-tests PATCH] x86: pmu: Test WRMSR on a running counter
  2020-02-04  1:25 [kvm-unit-tests PATCH] x86: pmu: Test WRMSR on a running counter Eric Hankland
  2020-02-05 11:45 ` Vitaly Kuznetsov
@ 2020-02-05 14:56 ` Paolo Bonzini
  1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2020-02-05 14:56 UTC (permalink / raw)
  To: Eric Hankland, Jim Mattson, Peter Shier; +Cc: linux-kernel, kvm

On 04/02/20 02:25, Eric Hankland wrote:
> Ensure that the value of the counter was successfully set to 0 after
> writing it while the counter was running.
> 
> Signed-off-by: Eric Hankland <ehankland@google.com>
> ---
>  x86/pmu.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/x86/pmu.c b/x86/pmu.c
> index cb8c9e3..8a77993 100644
> --- a/x86/pmu.c
> +++ b/x86/pmu.c
> @@ -419,6 +419,21 @@ static void check_rdpmc(void)
>  	report_prefix_pop();

Queued, thanks.

Paolo


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-02-05 14:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-04  1:25 [kvm-unit-tests PATCH] x86: pmu: Test WRMSR on a running counter Eric Hankland
2020-02-05 11:45 ` Vitaly Kuznetsov
2020-02-05 14:56 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).