On 11/14/23 3:16 PM, Srikar Dronamraju wrote: > * Aneesh Kumar K.V <aneesh.ku...@linux.ibm.com> [2023-11-14 12:42:19]: > >> No functional change in this patch. A helper is added to find if >> vcpu is dispatched by hypervisor. Use that instead of opencoding. >> Also clarify some of the comments. >> >> Signed-off-by: Aneesh Kumar K.V <aneesh.ku...@linux.ibm.com> >> --- >> arch/powerpc/include/asm/paravirt.h | 33 ++++++++++++++++++++++------- >> 1 file changed, 25 insertions(+), 8 deletions(-) >> >> diff --git a/arch/powerpc/include/asm/paravirt.h >> b/arch/powerpc/include/asm/paravirt.h >> index ac4279208d63..b78b82d66057 100644 >> --- a/arch/powerpc/include/asm/paravirt.h >> +++ b/arch/powerpc/include/asm/paravirt.h >> @@ -76,6 +76,17 @@ static inline bool is_vcpu_idle(int vcpu) >> { >> return lppaca_of(vcpu).idle; >> } >> + >> +static inline bool vcpu_is_dispatched(int vcpu) >> +{ >> + /* >> + * This is the yield_count. An "odd" value (low bit on) means that >> + * the processor is yielded (either because of an OS yield or a >> + * hypervisor preempt). An even value implies that the processor is >> + * currently executing. >> + */ >> + return (!(yield_count_of(vcpu) & 1)); >> +} >> #else >> static inline bool is_shared_processor(void) >> { >> @@ -109,6 +120,10 @@ static inline bool is_vcpu_idle(int vcpu) >> { >> return false; >> } >> +static inline bool vcpu_is_dispatched(int vcpu) >> +{ >> + return true; >> +} >> #endif > > If we are introducing vcpu_is_dispatched, we should remove > yield_count_of() and use vcpu_is_dispatched everwhere > > No point in having yield_count_of() and vcpu_is_dispatched, since > yield_count_of() is only used to check if we are running in OS or not. >
We do yield_count = yield_count_of(owner); yield_to_preempted(owner, yield_count); -aneesh