aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/kernel.h4
-rw-r--r--include/linux/sched.h13
-rw-r--r--kernel/sched.c6
3 files changed, 18 insertions, 5 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 94bc99656963..a7283c9beadf 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -105,8 +105,8 @@ struct user;
105 * supposed to. 105 * supposed to.
106 */ 106 */
107#ifdef CONFIG_PREEMPT_VOLUNTARY 107#ifdef CONFIG_PREEMPT_VOLUNTARY
108extern int cond_resched(void); 108extern int _cond_resched(void);
109# define might_resched() cond_resched() 109# define might_resched() _cond_resched()
110#else 110#else
111# define might_resched() do { } while (0) 111# define might_resched() do { } while (0)
112#endif 112#endif
diff --git a/include/linux/sched.h b/include/linux/sched.h
index fe3f8fbc614e..7907845c2348 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1885,7 +1885,18 @@ static inline int need_resched(void)
1885 * cond_resched_lock() will drop the spinlock before scheduling, 1885 * cond_resched_lock() will drop the spinlock before scheduling,
1886 * cond_resched_softirq() will enable bhs before scheduling. 1886 * cond_resched_softirq() will enable bhs before scheduling.
1887 */ 1887 */
1888extern int cond_resched(void); 1888#ifdef CONFIG_PREEMPT
1889static inline int cond_resched(void)
1890{
1891 return 0;
1892}
1893#else
1894extern int _cond_resched(void);
1895static inline int cond_resched(void)
1896{
1897 return _cond_resched();
1898}
1899#endif
1889extern int cond_resched_lock(spinlock_t * lock); 1900extern int cond_resched_lock(spinlock_t * lock);
1890extern int cond_resched_softirq(void); 1901extern int cond_resched_softirq(void);
1891 1902
diff --git a/kernel/sched.c b/kernel/sched.c
index b9ee0f4db66a..6ee37602a6d8 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -4678,7 +4678,8 @@ static void __cond_resched(void)
4678 } while (need_resched()); 4678 } while (need_resched());
4679} 4679}
4680 4680
4681int __sched cond_resched(void) 4681#if !defined(CONFIG_PREEMPT) || defined(CONFIG_PREEMPT_VOLUNTARY)
4682int __sched _cond_resched(void)
4682{ 4683{
4683 if (need_resched() && !(preempt_count() & PREEMPT_ACTIVE) && 4684 if (need_resched() && !(preempt_count() & PREEMPT_ACTIVE) &&
4684 system_state == SYSTEM_RUNNING) { 4685 system_state == SYSTEM_RUNNING) {
@@ -4687,7 +4688,8 @@ int __sched cond_resched(void)
4687 } 4688 }
4688 return 0; 4689 return 0;
4689} 4690}
4690EXPORT_SYMBOL(cond_resched); 4691EXPORT_SYMBOL(_cond_resched);
4692#endif
4691 4693
4692/* 4694/*
4693 * cond_resched_lock() - if a reschedule is pending, drop the given lock, 4695 * cond_resched_lock() - if a reschedule is pending, drop the given lock,