[PATCH] powerpc/sched: Cleanup vcpu_is_preempted()
Srikar Dronamraju
srikar at linux.vnet.ibm.com
Tue Nov 14 20:46:22 AEDT 2023
* Aneesh Kumar K.V <aneesh.kumar at 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.kumar at 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.
--
Thanks and Regards
Srikar Dronamraju
More information about the Linuxppc-dev
mailing list