Thread (7 messages) 7 messages, 4 authors, 2023-12-21

Re: [PATCH] powerpc/sched: Cleanup vcpu_is_preempted()

From: Aneesh Kumar K V <hidden>
Date: 2023-11-14 09:30:35

On 11/14/23 2:53 PM, Shrikanth Hegde wrote:

On 11/14/23 12:42 PM, Aneesh Kumar K.V wrote:
quoted
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 <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help