From: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
To: Nathan Lynch <nathanl@linux.ibm.com>
Cc: linuxppc-dev@lists.ozlabs.org, npiggin@gmail.com
Subject: Re: [PATCH v2 1/2] powerpc/paravirt: vcpu_is_preempted() commentary
Date: Wed, 29 Sep 2021 13:00:12 +0530 [thread overview]
Message-ID: <20210929073012.GF2004@linux.vnet.ibm.com> (raw)
In-Reply-To: <20210928214147.312412-2-nathanl@linux.ibm.com>
* Nathan Lynch <nathanl@linux.ibm.com> [2021-09-28 16:41:46]:
> Add comments more clearly documenting that this function determines whether
> hypervisor-level preemption of the VM has occurred.
>
> Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
Looks good to me.
Reviewed-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
> ---
> arch/powerpc/include/asm/paravirt.h | 22 ++++++++++++++++++----
> 1 file changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/paravirt.h b/arch/powerpc/include/asm/paravirt.h
> index bcb7b5f917be..39f173961f6a 100644
> --- a/arch/powerpc/include/asm/paravirt.h
> +++ b/arch/powerpc/include/asm/paravirt.h
> @@ -21,7 +21,7 @@ static inline bool is_shared_processor(void)
> return static_branch_unlikely(&shared_processor);
> }
>
> -/* If bit 0 is set, the cpu has been preempted */
> +/* If bit 0 is set, the cpu has been ceded, conferred, or preempted */
> static inline u32 yield_count_of(int cpu)
> {
> __be32 yield_count = READ_ONCE(lppaca_of(cpu).yield_count);
> @@ -92,6 +92,19 @@ static inline void prod_cpu(int cpu)
> #define vcpu_is_preempted vcpu_is_preempted
> static inline bool vcpu_is_preempted(int cpu)
> {
> + /*
> + * The dispatch/yield bit alone is an imperfect indicator of
> + * whether the hypervisor has dispatched @cpu to run on a physical
> + * processor. When it is clear, @cpu is definitely not preempted.
> + * But when it is set, it means only that it *might* be, subject to
> + * other conditions. So we check other properties of the VM and
> + * @cpu first, resorting to the yield count last.
> + */
> +
> + /*
> + * Hypervisor preemption isn't possible in dedicated processor
> + * mode by definition.
> + */
> if (!is_shared_processor())
> return false;
>
> @@ -100,9 +113,10 @@ static inline bool vcpu_is_preempted(int cpu)
> int first_cpu = cpu_first_thread_sibling(smp_processor_id());
>
> /*
> - * Preemption can only happen at core granularity. This CPU
> - * is not preempted if one of the CPU of this core is not
> - * preempted.
> + * The PowerVM hypervisor dispatches VMs on a whole core
> + * basis. So we know that a thread sibling of the local CPU
> + * cannot have been preempted by the hypervisor, even if it
> + * has called H_CONFER, which will set the yield bit.
> */
> if (cpu_first_thread_sibling(cpu) == first_cpu)
> return false;
> --
> 2.31.1
>
--
Thanks and Regards
Srikar Dronamraju
next prev parent reply other threads:[~2021-09-29 7:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-28 21:41 [PATCH v2 0/2] powerpc/paravirt: vcpu_is_preempted() tweaks Nathan Lynch
2021-09-28 21:41 ` [PATCH v2 1/2] powerpc/paravirt: vcpu_is_preempted() commentary Nathan Lynch
2021-09-29 7:30 ` Srikar Dronamraju [this message]
2021-09-28 21:41 ` [PATCH v2 2/2] powerpc/paravirt: correct preempt debug splat in vcpu_is_preempted() Nathan Lynch
2021-09-29 7:30 ` Srikar Dronamraju
2021-10-11 12:06 ` [PATCH v2 0/2] powerpc/paravirt: vcpu_is_preempted() tweaks 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=20210929073012.GF2004@linux.vnet.ibm.com \
--to=srikar@linux.vnet.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=nathanl@linux.ibm.com \
--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).