Re: [PATCH v7 11/13] KVM: x86: Implement Intel Processor Trace MSRs read/write
From: Paolo Bonzini
Date: Fri May 04 2018 - 17:47:50 EST
On 04/05/2018 12:11, Alexander Shishkin wrote:
>> + */
>> + if ((data & RTIT_CTL_TRACEEN) && !(data & RTIT_CTL_TOPA) &&
>> + !(data & RTIT_CTL_FABRIC_EN) &&
>> + !__pt_cap_get(vmx->pt_desc.caps, PT_CAP_single_range_output))
> You seem to be doing a lot of __pt_cap_get()s on each wrmsr. Did you consider
> decoding the capabilities once and storing the decoded values instead, so
> that in functions like these you can access them by
>
> if (vmx->pt_desc.caps[PT_CAP_single_range_output]) ...
>
> ?
Or pt_cap_get could use a switch statement in pt_cap_get and make it
__always_inline. The argument is always a constant except for pt_cap_show.
What you say is also a possibility though. Are you okay with adding a
PT_CAP_first_unused at the end of enum pt_capabilities, so that the
array can be sized?
Thanks,
Paolo