Message ID | 20230414110056.19665-5-cloudliang@tencent.com |
---|---|
State | Superseded |
Headers | show |
Series | KVM: selftests: Add tests for pmu event filter | expand |
Bagas Sanjaya <bagasdotme@gmail.com> 于2023年4月15日周六 11:24写道: > > On Fri, Apr 14, 2023 at 07:00:53PM +0800, Jinrong Liang wrote: > > +Specifically, KVM follows the following pseudo-code when determining whether to > > +allow the guest FixCtr[i] to count its pre-defined fixed event: > > + > > + FixCtr[i]_is_allowed = (action == ALLOW) && (bitmap & BIT(i)) || > > + (action == DENY) && !(bitmap & BIT(i)); > > + FixCtr[i]_is_denied = !FixCtr[i]_is_allowed; > > + > > As kernel test robot has reported [1], you need to wrap the code above > in a code block: I will make the changes as you suggested, i.e. wrap the code above in a code block. Thanks. > > ---- >8 ---- > diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst > index 036f5b1a39aff8..b5836767e0e76d 100644 > --- a/Documentation/virt/kvm/api.rst > +++ b/Documentation/virt/kvm/api.rst > @@ -5126,7 +5126,7 @@ Via this API, KVM userspace can also control the behavior of the VM's fixed > counters (if any) by configuring the "action" and "fixed_counter_bitmap" fields. > > Specifically, KVM follows the following pseudo-code when determining whether to > -allow the guest FixCtr[i] to count its pre-defined fixed event: > +allow the guest FixCtr[i] to count its pre-defined fixed event:: > > FixCtr[i]_is_allowed = (action == ALLOW) && (bitmap & BIT(i)) || > (action == DENY) && !(bitmap & BIT(i)); > > Thanks. > > [1]: https://lore.kernel.org/linux-doc/202304150850.rx4UDDsB-lkp@intel.com/ > > -- > An old man doll... just what I always wanted! - Clara
diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst index a69e91088d76..036f5b1a39af 100644 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@ -5122,6 +5122,27 @@ Valid values for 'action':: #define KVM_PMU_EVENT_ALLOW 0 #define KVM_PMU_EVENT_DENY 1 +Via this API, KVM userspace can also control the behavior of the VM's fixed +counters (if any) by configuring the "action" and "fixed_counter_bitmap" fields. + +Specifically, KVM follows the following pseudo-code when determining whether to +allow the guest FixCtr[i] to count its pre-defined fixed event: + + FixCtr[i]_is_allowed = (action == ALLOW) && (bitmap & BIT(i)) || + (action == DENY) && !(bitmap & BIT(i)); + FixCtr[i]_is_denied = !FixCtr[i]_is_allowed; + +Note once this API interface is called, the default zero value of the field +"fixed_counter_bitmap" will implicitly affect all fixed counters, even if it's +expected to be used only to control the events on generic counters. + +In addition, pre-defined performance events on the fixed counters already have +event_select and unit_mask values defined, which means userspace can also +control fixed counters by configuring "action"+ "events" fields. + +When there is a contradiction between these two polices, the fixed performance +counter will only follow the rule of the pseudo-code above. + 4.121 KVM_PPC_SVM_OFF ---------------------