aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sched/core.c')
-rw-r--r--kernel/sched/core.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 0a7251678982..71d9a9c93954 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4084,6 +4084,7 @@ static void __cond_resched(void)
4084 4084
4085int __sched _cond_resched(void) 4085int __sched _cond_resched(void)
4086{ 4086{
4087 rcu_cond_resched();
4087 if (should_resched()) { 4088 if (should_resched()) {
4088 __cond_resched(); 4089 __cond_resched();
4089 return 1; 4090 return 1;
@@ -4102,15 +4103,18 @@ EXPORT_SYMBOL(_cond_resched);
4102 */ 4103 */
4103int __cond_resched_lock(spinlock_t *lock) 4104int __cond_resched_lock(spinlock_t *lock)
4104{ 4105{
4106 bool need_rcu_resched = rcu_should_resched();
4105 int resched = should_resched(); 4107 int resched = should_resched();
4106 int ret = 0; 4108 int ret = 0;
4107 4109
4108 lockdep_assert_held(lock); 4110 lockdep_assert_held(lock);
4109 4111
4110 if (spin_needbreak(lock) || resched) { 4112 if (spin_needbreak(lock) || resched || need_rcu_resched) {
4111 spin_unlock(lock); 4113 spin_unlock(lock);
4112 if (resched) 4114 if (resched)
4113 __cond_resched(); 4115 __cond_resched();
4116 else if (unlikely(need_rcu_resched))
4117 rcu_resched();
4114 else 4118 else
4115 cpu_relax(); 4119 cpu_relax();
4116 ret = 1; 4120 ret = 1;
@@ -4124,6 +4128,7 @@ int __sched __cond_resched_softirq(void)
4124{ 4128{
4125 BUG_ON(!in_softirq()); 4129 BUG_ON(!in_softirq());
4126 4130
4131 rcu_cond_resched(); /* BH disabled OK, just recording QSes. */
4127 if (should_resched()) { 4132 if (should_resched()) {
4128 local_bh_enable(); 4133 local_bh_enable();
4129 __cond_resched(); 4134 __cond_resched();