mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pan Xinhui <xinhui.pan@linux.vnet.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: peterz@infradead.org, mingo@redhat.com, boqun.feng@gmail.com,
	pan xinhui <xinhui.pan@linux.vnet.ibm.com>
Subject: [PATCH 1/2] kernel/sched: introduce vcpu preempted interface
Date: Sun, 26 Jun 2016 06:41:54 -0400	[thread overview]
Message-ID: <1466937715-6683-2-git-send-email-xinhui.pan@linux.vnet.ibm.com> (raw)
In-Reply-To: <1466937715-6683-1-git-send-email-xinhui.pan@linux.vnet.ibm.com>

From: pan xinhui <xinhui.pan@linux.vnet.ibm.com>

this supports to fix lock holder preempted issue which run as a guest

two interfaces,
bool vcpu_is_preempted(int cpu);
unsigned int vcpu_get_yield_count(int cpu);
arch may need implement anyone of them.

some spinneris may also need call need_yield_to(int cpu, unsigned int
old_yield_count) to know if it need stop the spinning.

Signed-off-by: Pan Xinhui <xinhui.pan@linux.vnet.ibm.com>
---
 include/linux/sched.h | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 6e42ada..9c565d2 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -3293,6 +3293,40 @@ static inline void set_task_cpu(struct task_struct *p, unsigned int cpu)
 
 #endif /* CONFIG_SMP */
 
+#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
+
+static inline bool
+need_yield_to(int vcpu, unsigned int old_yield_count)
+{
+	/* 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);
+}
+
 extern long sched_setaffinity(pid_t pid, const struct cpumask *new_mask);
 extern long sched_getaffinity(pid_t pid, struct cpumask *mask);
 
-- 
2.4.11

  reply	other threads:[~2016-06-26  6:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-26 10:41 [PATCH 0/2] implement vcpu preempted check Pan Xinhui
2016-06-26 10:41 ` Pan Xinhui [this message]
2016-06-27  8:42   ` [PATCH 1/2] kernel/sched: introduce vcpu preempted interface Peter Zijlstra
2016-06-27  9:42     ` xinhui
2016-06-26 10:41 ` [PATCH 2/2] locking/osq: Drop the overload of osq_lock() Pan Xinhui
2016-06-26  7:12   ` panxinhui

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=1466937715-6683-2-git-send-email-xinhui.pan@linux.vnet.ibm.com \
    --to=xinhui.pan@linux.vnet.ibm.com \
    --cc=boqun.feng@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    /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

all inboxes | Powered by JetHome®