rcu: Motivate Tiny RCU forward progress
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Fri, 20 Jul 2018 21:18:23 +0000 (14:18 -0700)
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Thu, 30 Aug 2018 23:03:41 +0000 (16:03 -0700)
If a long-running CPU-bound in-kernel task invokes call_rcu(), the
callback won't be invoked until the next context switch.  If there are
no other runnable tasks (which is not an uncommon situation on deep
embedded systems), the callback might never be invoked.

This commit therefore causes rcu_check_callbacks() to ask the scheduler
for a context switch if there are callbacks posted that are still waiting
for a grace period.

Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
kernel/rcu/tiny.c

index a77853b73bfeb2e3e3b1fc0a00e11a15f4d68ca5..1745d30e170efdb69bac29fba1f4fda4489b5b4f 100644 (file)
@@ -78,8 +78,12 @@ void rcu_qs(void)
  */
 void rcu_check_callbacks(int user)
 {
-       if (user)
+       if (user) {
                rcu_qs();
+       } else if (rcu_ctrlblk.donetail != rcu_ctrlblk.curtail) {
+               set_tsk_need_resched(current);
+               set_preempt_need_resched();
+       }
 }
 
 /* Invoke the RCU callbacks whose grace period has elapsed.  */