On Thu, Apr 20, 2023, Jinrong Liang wrote: > From: Jinrong Liang <cloudliang@xxxxxxxxxxx> > > From: Jinrong Liang <cloudliang@xxxxxxxxxxx> > > 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@xxxxxxxxxxx> > --- > .../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 >