Re: [PATCH 4/4] KVM: x86: remove notifiers from PIT discard policy

From: Radim KrÄmÃÅ
Date: Thu Feb 04 2016 - 08:16:14 EST


2016-02-03 17:51+0100, Paolo Bonzini:
> On 03/02/2016 17:23, Radim KrÄmÃÅ wrote:
>> Discard policy doesn't rely on information from notifiers, so we don't
>> need to register notifiers unconditionally.
>>
>> Use of ps->lock doesn't make sense, but isn't any worse than before.

Oops, it is worse than before ... toggling KVM_REINJECT_CONTROL when the
guest is running and reading reinject without locking is now far more
complex. This patch should have also ignored KVM_REINJECT_CONTROL when
PIT has been started.

> Oh, it's perfectly okay. Too fine-grained locks are bad, and lock
> contention on ps->lock is a non-issue.
>
> Can you however add a patch that says what fields of kvm_kpit_state are
> protected by which locks?

Ok. (I'll be careful to not rewrite the whole PIT while at it. :])

> Then this patch will just add
>
> /* Protected by kvm_kpit_state lock. */
>
> above the reinject field.

There was no need to lock reinject in the past and v2 will hopefully
achieve it again.

> Otherwise
>
> Reviewed-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>

Thanks. (Might not be applicable to v2, though; sorry.)