diff mbox series

[v2,6/7] KVM: selftests: Check gp event filters without affecting fixed event filters

Message ID 20230420104622.12504-7-ljrcore@126.com (mailing list archive)
State New
Headers show
Series KVM: selftests: Add tests for pmu event filter | expand

Commit Message

Jinrong Liang April 20, 2023, 10:46 a.m. UTC
From: Jinrong Liang <cloudliang@tencent.com>

From: Jinrong Liang <cloudliang@tencent.com>

Add a test to ensure that setting both generic and fixed performance
event filters does not affect the consistency of the fixed performance
filter behavior in KVM. This test helps to ensure that the fixed
performance filter works as expected even when generic performance
event filters are also set.

Signed-off-by: Jinrong Liang <cloudliang@tencent.com>
---
 .../selftests/kvm/x86_64/pmu_event_filter_test.c   | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Sean Christopherson May 25, 2023, 6:12 p.m. UTC | #1
On Thu, Apr 20, 2023, Jinrong Liang wrote:
> From: Jinrong Liang <cloudliang@tencent.com>
> 
> From: Jinrong Liang <cloudliang@tencent.com>
> 
> Add a test to ensure that setting both generic and fixed performance
> event filters does not affect the consistency of the fixed performance
> filter behavior in KVM. This test helps to ensure that the fixed
> performance filter works as expected even when generic performance
> event filters are also set.
> 
> Signed-off-by: Jinrong Liang <cloudliang@tencent.com>
> ---
>  .../selftests/kvm/x86_64/pmu_event_filter_test.c   | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c b/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c
> index 0f54c53d7fff..9be4c6f8fb7e 100644
> --- a/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c
> @@ -889,6 +889,7 @@ static void test_fixed_ctr_action_and_bitmap(struct kvm_vcpu *vcpu,
>  	uint32_t bitmap;
>  	uint64_t count;
>  	bool expected;
> +	struct kvm_pmu_event_filter *f;
>  
>  	/*
>  	 * Check the fixed performance counter can count normally works when
> @@ -902,6 +903,19 @@ static void test_fixed_ctr_action_and_bitmap(struct kvm_vcpu *vcpu,
>  			expected = fixed_ctr_is_allowed(fixed_ctr_idx, actions[i], bitmap);
>  			count = test_fixed_ctr_with_filter(vcpu, actions[i], bitmap);
>  
> +			TEST_ASSERT(expected == !!count,
> +				    "Fixed event filter does not work as expected.");
> +
> +			/*
> +			 * Check that setting both events[] and fixed_counter_bitmap
> +			 * does not affect the consistency of the fixed ctrs' behaviour.
> +			 *
> +			 * Note, the fixed_counter_bitmap rule has high priority.

"high" is ambiguous without a baseline.  I believe what you want to say is
"the fixed_counter_bitmap has higher priority than the events list".

> +			 */
> +			f = event_filter(actions[i]);
> +			f->fixed_counter_bitmap = bitmap;
> +			count = test_with_filter(vcpu, f);
> +
>  			TEST_ASSERT(expected == !!count,
>  				    "Fixed event filter does not work as expected.");
>  		}
> -- 
> 2.31.1
>
diff mbox series

Patch

diff --git a/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c b/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c
index 0f54c53d7fff..9be4c6f8fb7e 100644
--- a/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c
+++ b/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c
@@ -889,6 +889,7 @@  static void test_fixed_ctr_action_and_bitmap(struct kvm_vcpu *vcpu,
 	uint32_t bitmap;
 	uint64_t count;
 	bool expected;
+	struct kvm_pmu_event_filter *f;
 
 	/*
 	 * Check the fixed performance counter can count normally works when
@@ -902,6 +903,19 @@  static void test_fixed_ctr_action_and_bitmap(struct kvm_vcpu *vcpu,
 			expected = fixed_ctr_is_allowed(fixed_ctr_idx, actions[i], bitmap);
 			count = test_fixed_ctr_with_filter(vcpu, actions[i], bitmap);
 
+			TEST_ASSERT(expected == !!count,
+				    "Fixed event filter does not work as expected.");
+
+			/*
+			 * Check that setting both events[] and fixed_counter_bitmap
+			 * does not affect the consistency of the fixed ctrs' behaviour.
+			 *
+			 * Note, the fixed_counter_bitmap rule has high priority.
+			 */
+			f = event_filter(actions[i]);
+			f->fixed_counter_bitmap = bitmap;
+			count = test_with_filter(vcpu, f);
+
 			TEST_ASSERT(expected == !!count,
 				    "Fixed event filter does not work as expected.");
 		}