summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2005-01-07 21:49:52 -0800
committerLinus Torvalds <torvalds@evo.osdl.org>2005-01-07 21:49:52 -0800
commita298f2eefe18888907e9feffb477b66843912d10 (patch)
tree9bc83a440552e8a9c91cd1590b2db0c14355eb30
parentf6aaca35e0aa4c7e3de79ace85f7380f4d451648 (diff)
[PATCH] sched: add cond_resched_softirq()
It adds cond_resched_softirq() which can be used by _process context_ softirqs-disabled codepaths to preempt if necessary. The function will enable softirqs before scheduling. (Later patches will use this primitive.) Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--include/linux/sched.h3
-rw-r--r--kernel/sched.c16
2 files changed, 19 insertions, 0 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index c69d26d50fb0..fa3cb372c554 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1069,9 +1069,12 @@ static inline int need_resched(void)
* cond_resched() and cond_resched_lock(): latency reduction via
* explicit rescheduling in places that are safe. The return
* value indicates whether a reschedule was done in fact.
+ * cond_resched_lock() will drop the spinlock before scheduling,
+ * cond_resched_softirq() will enable bhs before scheduling.
*/
extern int cond_resched(void);
extern int cond_resched_lock(spinlock_t * lock);
+extern int cond_resched_softirq(void);
/*
* Does a critical section need to be broken due to another
diff --git a/kernel/sched.c b/kernel/sched.c
index a55af06f9976..c0d7126b2c7b 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3483,6 +3483,22 @@ int cond_resched_lock(spinlock_t * lock)
EXPORT_SYMBOL(cond_resched_lock);
+int __sched cond_resched_softirq(void)
+{
+ BUG_ON(!in_softirq());
+
+ if (need_resched()) {
+ __local_bh_enable();
+ __cond_resched();
+ local_bh_disable();
+ return 1;
+ }
+ return 0;
+}
+
+EXPORT_SYMBOL(cond_resched_softirq);
+
+
/**
* yield - yield the current processor to other threads.
*