Re: [RFC] KVM: x86: conditionally acquire/release slots_lock on entry/exit

Avi Kivity
2009-09-14T05:03:53Z

On 09/14/2009 01:49 AM, Marcelo Tosatti wrote:
>
>>> I think synchronize_srcu() will be deferred until the fault path is
>>> complete (and srcu_read_unlock() runs). Copying someone who knows for
>>> sure.
>>>
>> Yes, synchronize_srcu() will block until srcu_read_unlock() in this
>> scenario, assuming that the same srcu_struct is used by both.
>>
> Right it will. But this does not stop the fault path from creating
> shadow pages with stale sp->gfn (the only way to do that would be mutual
> exclusion AFAICS).
>

So we put the kvm_mmu_zap_pages() call as part of the synchronize_srcu()
callback to take advantage of the srcu guarantees. We know that when
when the callback is called all new reads see the new slots and all old
readers have completed.

> The RCU read-protected side does not stop a new memslots pointer from
> being assigned (with rcu_assign_pointer), does it?
>
>

It doesn't. It only gives you a point in time where you know no one is
using the old pointer, but before it has been deleted.

--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.