Re: [PATCH] kvm: x86: keep srcu writer side operation mutually exclusive

From: Sean Christopherson
Date: Fri Oct 07 2022 - 13:13:21 EST


On Sat, Oct 08, 2022, Hao Peng wrote:
> From: Peng Hao <flyingpeng@xxxxxxxxxxx>
>
> Synchronization operations on the writer side of SRCU should be
> invoked within the mutex.

Why? Synchronizing SRCU is necessary only to ensure that all previous readers go
away before the old filter is freed. There's no need to serialize synchronization
between writers. The mutex ensures each writer operates on the "new" filter that's
set by the previous writer, i.e. there's no danger of a double-free. And the next
writer will wait for readers to _its_ "new" filter.

I think it's a moot point though, as this is a subset of patch I posted[*] to fix
other issues with the PMU event filter.

[*] https://lore.kernel.org/all/20220923001355.3741194-2-seanjc@xxxxxxxxxx