linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
To: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
Cc: linuxppc-dev@lists.ozlabs.org, npiggin@gmail.com
Subject: Re: [PATCH] powerpc/sched: Cleanup vcpu_is_preempted()
Date: Tue, 14 Nov 2023 15:16:22 +0530	[thread overview]
Message-ID: <20231114094622.GR2194132@linux.vnet.ibm.com> (raw)
In-Reply-To: <20231114071219.198222-1-aneesh.kumar@linux.ibm.com>

* Aneesh Kumar K.V <aneesh.kumar@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@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

  parent reply	other threads:[~2023-11-14  9:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-14  7:12 [PATCH] powerpc/sched: Cleanup vcpu_is_preempted() Aneesh Kumar K.V
2023-11-14  9:23 ` Shrikanth Hegde
2023-11-14  9:29   ` Aneesh Kumar K V
2023-11-14  9:46 ` Srikar Dronamraju [this message]
2023-11-14 10:15   ` Aneesh Kumar K V
2023-11-14 15:56     ` Srikar Dronamraju
2023-12-21 10:38 ` Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231114094622.GR2194132@linux.vnet.ibm.com \
    --to=srikar@linux.vnet.ibm.com \
    --cc=aneesh.kumar@linux.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=npiggin@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).