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

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

From: Srikar Dronamraju <hidden>
Date: 2023-11-14 09:47:30

* Aneesh Kumar K.V [off-list ref] [2023-11-14 12:42:19]:
quoted hunk ↗ jump to hunk
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
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help