Re: [PATCH RFC 0/1] Make vCPUs that are HLT state candidates for load balancing
From: Peter Zijlstra
Date: Wed May 26 2021 - 10:43:19 EST
On Wed, May 26, 2021 at 10:37:26PM +0900, Masanori Misono wrote:
> is_vcpu_preempted() is also used in PV spinlock implementations to mitigate
> lock holder preemption problems,
It's used to abort optimistic spinners.
> etc. A vCPU holding a lock does not do HLT,
Optimistic spinning is actually part of mutexes and rwsems too, and in
those cases we might very well end up in idle while holding the lock.
However; in that case the task will have been scheduled out and the
optimistic spin loop will terminate due to that (see the ->on_cpu
condition).
> so I think this patch doesn't affect them.
That is correct.
> However, pCPU may be
> running the host's thread that has higher priority than a vCPU thread, and
> in that case, is_vcpu_preempted() should return 0 ideally.
No, in that case vcpu_is_preempted() really should return true. There is
no saying how long the vcpu is gone for.