From: Aneesh Kumar K V <aneesh.kumar@linux.ibm.com>
To: Shrikanth Hegde <sshegde@linux.vnet.ibm.com>
Cc: linuxppc-dev@lists.ozlabs.org,
Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
npiggin@gmail.com
Subject: Re: [PATCH] powerpc/sched: Cleanup vcpu_is_preempted()
Date: Tue, 14 Nov 2023 14:59:29 +0530 [thread overview]
Message-ID: <3e609a7f-59c8-487e-8c72-81b5d902c29f@linux.ibm.com> (raw)
In-Reply-To: <a326ce8a-431f-45dd-a225-691f6f965b6f@linux.vnet.ibm.com>
On 11/14/23 2:53 PM, Shrikanth Hegde wrote:
>
>
> On 11/14/23 12:42 PM, Aneesh Kumar K.V wrote:
>> 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
>>
>
> Similar code can be changed in lib/qspinlock.c and lib/locks.c as well.
I avoided doing that because they used the fetched yield_count value
yield_to_preempted(owner, yield_count);
and the checking comes with a comment
if ((yield_count & 1) == 0)
goto relax; /* owner vcpu is running */
-aneesh
next prev parent reply other threads:[~2023-11-14 9:30 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 [this message]
2023-11-14 9:46 ` Srikar Dronamraju
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=3e609a7f-59c8-487e-8c72-81b5d902c29f@linux.ibm.com \
--to=aneesh.kumar@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=npiggin@gmail.com \
--cc=srikar@linux.vnet.ibm.com \
--cc=sshegde@linux.vnet.ibm.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).