sched/rt: Add schedule_preempt_disabled()
authorThomas Gleixner <tglx@linutronix.de>
Mon, 21 Mar 2011 11:09:35 +0000 (12:09 +0100)
committerIngo Molnar <mingo@elte.hu>
Thu, 1 Mar 2012 09:28:03 +0000 (10:28 +0100)
Add helper to get rid of the ever repeating:

    preempt_enable_no_resched();
    schedule();
    preempt_disable();

patterns.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-wxx7btox7coby6ifv5vzhzgp@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@elte.hu>
include/linux/sched.h
kernel/sched/core.c

index 1a6398424fab6752337d767937a081d22ca1497c..03dd224d066748266a00dbac9aeefa6f04320a66 100644 (file)
@@ -361,6 +361,7 @@ extern signed long schedule_timeout_interruptible(signed long timeout);
 extern signed long schedule_timeout_killable(signed long timeout);
 extern signed long schedule_timeout_uninterruptible(signed long timeout);
 asmlinkage void schedule(void);
+extern void schedule_preempt_disabled(void);
 extern int mutex_spin_on_owner(struct mutex *lock, struct task_struct *owner);
 
 struct nsproxy;
index 91fe6a0e9098bbd9fceb9caf28baf677f114a0bb..73022395c00e7898a775d2a30ce14b45de9d6ff7 100644 (file)
@@ -3246,6 +3246,18 @@ asmlinkage void __sched schedule(void)
 }
 EXPORT_SYMBOL(schedule);
 
+/**
+ * schedule_preempt_disabled - called with preemption disabled
+ *
+ * Returns with preemption disabled. Note: preempt_count must be 1
+ */
+void __sched schedule_preempt_disabled(void)
+{
+       preempt_enable_no_resched();
+       schedule();
+       preempt_disable();
+}
+
 #ifdef CONFIG_MUTEX_SPIN_ON_OWNER
 
 static inline bool owner_running(struct mutex *lock, struct task_struct *owner)