diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/sched.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index e6c24f2bfadd..b132cc3952ea 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -956,6 +956,34 @@ static inline void cond_resched(void) __cond_resched(); } +#ifdef CONFIG_PREEMPT + +/* + * cond_resched_lock() - if a reschedule is pending, drop the given lock, + * call schedule, and on return reacquire the lock. + * + * Note: this does not assume the given lock is the _only_ lock held. + * The kernel preemption counter gives us "free" checking that we are + * atomic -- let's use it. + */ +static inline void cond_resched_lock(spinlock_t * lock) +{ + if (need_resched() && preempt_count() == 1) { + _raw_spin_unlock(lock); + preempt_enable_no_resched(); + __cond_resched(); + spin_lock(lock); + } +} + +#else + +static inline void cond_resched_lock(spinlock_t * lock) +{ +} + +#endif + /* Reevaluate whether the task has signals pending delivery. This is required every time the blocked sigset_t changes. Athread cathreaders should have t->sigmask_lock. */ |
