From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>
To: mingo@redhat.com, peterz@infradead.org
Cc: tglx@linutronix.de, hpa@zytor.com, konrad.wilk@oracle.com,
david.vrabel@citrix.com, masami.hiramatsu.pt@hitachi.com,
rostedt@goodmis.org, luto@amacapital.net, JBeulich@suse.com,
jgross@suse.com, bpoirier@suse.de, x86@kernel.org,
xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org,
"Luis R. Rodriguez" <mcgrof@suse.com>,
Borislav Petkov <bp@suse.de>
Subject: [PATCH v2 1/2] sched: add cond_resched_irq()
Date: Wed, 10 Dec 2014 15:34:46 -0800 [thread overview]
Message-ID: <1418254487-9988-2-git-send-email-mcgrof@do-not-panic.com> (raw)
In-Reply-To: <1418254487-9988-1-git-send-email-mcgrof@do-not-panic.com>
From: "Luis R. Rodriguez" <mcgrof@suse.com>
Under special circumstances we may want to force
voluntary preemption even for CONFIG_PREEMPT=n
with interrupts disabled. This adds helpers to
let us do that.
Cc: Borislav Petkov <bp@suse.de>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Jan Beulich <JBeulich@suse.com>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
---
include/linux/sched.h | 7 +++++++
kernel/sched/core.c | 10 ++++++++++
2 files changed, 17 insertions(+)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 5e344bb..92da927 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2759,6 +2759,13 @@ static inline int signal_pending_state(long state, struct task_struct *p)
*/
extern int _cond_resched(void);
+/*
+ * Voluntarily preempting the kernel even for CONFIG_PREEMPT=n kernels
+ * on very special circumstances. This is to be used with interrupts
+ * disabled.
+ */
+extern int cond_resched_irq(void);
+
#define cond_resched() ({ \
__might_sleep(__FILE__, __LINE__, 0); \
_cond_resched(); \
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 89e7283..573edb1 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4239,6 +4239,16 @@ int __sched _cond_resched(void)
}
EXPORT_SYMBOL(_cond_resched);
+int __sched cond_resched_irq(void)
+{
+ if (should_resched()) {
+ preempt_schedule_irq();
+ return 1;
+ }
+ return 0;
+}
+EXPORT_SYMBOL_GPL(cond_resched_irq);
+
/*
* __cond_resched_lock() - if a reschedule is pending, drop the given lock,
* call schedule, and on return reacquire the lock.
--
2.1.1
next prev parent reply other threads:[~2014-12-10 23:35 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-10 23:34 [PATCH v2 0/2] x86: add xen hypercall preemption Luis R. Rodriguez
2014-12-10 23:34 ` Luis R. Rodriguez [this message]
2014-12-11 13:31 ` [PATCH v2 1/2] sched: add cond_resched_irq() Jan Beulich
[not found] ` <5489AADA020000780004EFB9@suse.com>
2014-12-11 21:06 ` Luis R. Rodriguez
2014-12-10 23:34 ` [PATCH v2 2/2] x86/xen: allow privcmd hypercalls to be preempted Luis R. Rodriguez
2014-12-10 23:51 ` Andy Lutomirski
2014-12-11 0:55 ` Luis R. Rodriguez
2014-12-11 1:04 ` Andy Lutomirski
2014-12-11 11:09 ` [Xen-devel] " David Vrabel
2014-12-11 21:05 ` Luis R. Rodriguez
2014-12-11 0:29 ` H. Peter Anvin
2014-12-11 1:03 ` Luis R. Rodriguez
2014-12-11 18:47 ` H. Peter Anvin
2014-12-11 20:39 ` Luis R. Rodriguez
2014-12-18 19:23 ` [Xen-devel] " Konrad Rzeszutek Wilk
2015-01-13 21:21 ` Luis R. Rodriguez
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=1418254487-9988-2-git-send-email-mcgrof@do-not-panic.com \
--to=mcgrof@do-not-panic.com \
--cc=JBeulich@suse.com \
--cc=bp@suse.de \
--cc=bpoirier@suse.de \
--cc=david.vrabel@citrix.com \
--cc=hpa@zytor.com \
--cc=jgross@suse.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mcgrof@suse.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xenproject.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