Re: [PATCH 04/24] kvm: x86/mmu: change TDP MMU yield function returns to match cond_resched

From: Paolo Bonzini
Date: Thu Jan 21 2021 - 15:30:41 EST


On 20/01/21 19:38, Sean Christopherson wrote:
Currently the TDP MMU yield / cond_resched functions either return
nothing or return true if the TLBs were not flushed. These are confusing
semantics, especially when making control flow decisions in calling
functions.

To clean things up, change both functions to have the same
return value semantics as cond_resched: true if the thread yielded,
false if it did not. If the function yielded in the_flush_ version,
then the TLBs will have been flushed.

My fault here. The return value was meant to simplify the assignments below. But it's clearer to return true if the cond_resched happened, indeed.


if (can_yield)
- flush_needed = tdp_mmu_iter_flush_cond_resched(kvm, &iter);
+ flush_needed = !tdp_mmu_iter_flush_cond_resched(kvm,
+ &iter);

As with the existing code, I'd let this poke out. Alternatively, this could be
written as:

flush_needed = !can_yield ||
!tdp_mmu_iter_flush_cond_resched(kvm, &iter);


Yeah, no new line here.

Paolo