Re: [PATCH 1/2] kernel/sched: introduce vcpu preempted interface

From: xinhui
Date: Mon Jun 27 2016 - 05:43:34 EST




On 2016å06æ27æ 16:42, Peter Zijlstra wrote:
On Sun, Jun 26, 2016 at 06:41:54AM -0400, Pan Xinhui wrote:

+#ifdef arch_vcpu_is_preempted
+static inline bool vcpu_is_preempted(int cpu)
+{
+ return arch_vcpu_is_preempted(cpu);
+}
+#else
+static inline bool vcpu_is_preempted(int cpu)
+{
+ return 0;
+}
+#endif
+
+#ifdef arch_vcpu_get_yield_count
+static inline unsigned int vcpu_get_yield_count(int cpu)
+{
+ return arch_vcpu_get_yield_count(cpu);
+}
+#else
+static inline unsigned int vcpu_get_yield_count(int cpu)
+{
+ return 0;
+}
+#endif


Please, just do something like:

#ifndef vcpu_is_preempted
static inline bool vcpu_is_preempted(int cpu)
{
return false;
}
#endif

No point in making it more complicated.

right, vcpu_is_preempted() is good enough to handle our osq issue.

+static inline bool
+need_yield_to(int vcpu, unsigned int old_yield_count)

namespace... this thing should be called: vcpu_something()

+{
+ /* if we find the vcpu is preempted,
+ * then we may want to kick it, IOW, yield to it
+ */
+ return vcpu_is_preempted(vcpu) ||
+ (vcpu_get_yield_count(vcpu) != old_yield_count);
+}

And can you make doubly sure (and mention in the Changelog) that the OSQ
code compiles all this away when using these definitions.

vimdiff shows the osq_lock.o has a little difference because osq read the yield_count and prev, even they are not used.

however, as you suggest above, IF I remove the vcpu_get_yield_count() and relevant code in osq_lock, then the binary is same.