Re: [PATCH v2 09/54] perf: core/x86: Register a new vector for KVM GUEST PMI

Yanfei Xu
2024-05-08T10:06:43Z

On 5/7/2024 5:12 PM, Peter Zijlstra wrote:
> On Mon, May 06, 2024 at 05:29:34AM +0000, Mingwei Zhang wrote:
>
>> +void kvm_set_guest_pmi_handler(void (*handler)(void))
>> +{
>> + if (handler) {
>> + kvm_guest_pmi_handler = handler;
>> + } else {
>> + kvm_guest_pmi_handler = dummy_handler;
>> + synchronize_rcu();
>> + }
>> +}
>> +EXPORT_SYMBOL_GPL(kvm_set_guest_pmi_handler);
>
> Just for my edification, after synchronize_rcu() nobody should observe
> the old handler, but what guarantees there's not still one running?

Interrupts handler can be regarded as RCU read-side critical section,
once synchronize_rcu returns, no one accessing the old handler lefts.

>
> I'm thinking the fact that these handlers run with IRQs disabled, and
> synchronize_rcu() also very much ensures all prior non-preempt sections
> are complete?

Yes :)

Thanks,
Yanfei

>
>
>