aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/time/tick-sched.c
diff options
context:
space:
mode:
authorPaul E. McKenney <paul.mckenney@linaro.org>2011-09-30 15:10:22 -0400
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2011-12-11 13:31:24 -0500
commit9b2e4f1880b789be1f24f9684f7a54b90310b5c0 (patch)
tree1fa922e0616e298837a7079cb49118188a58186c /kernel/time/tick-sched.c
parentb804cb9e91c6c304959c69d4f9daeef4ffdba71c (diff)
rcu: Track idleness independent of idle tasks
Earlier versions of RCU used the scheduling-clock tick to detect idleness by checking for the idle task, but handled idleness differently for CONFIG_NO_HZ=y. But there are now a number of uses of RCU read-side critical sections in the idle task, for example, for tracing. A more fine-grained detection of idleness is therefore required. This commit presses the old dyntick-idle code into full-time service, so that rcu_idle_enter(), previously known as rcu_enter_nohz(), is always invoked at the beginning of an idle loop iteration. Similarly, rcu_idle_exit(), previously known as rcu_exit_nohz(), is always invoked at the end of an idle-loop iteration. This allows the idle task to use RCU everywhere except between consecutive rcu_idle_enter() and rcu_idle_exit() calls, in turn allowing architecture maintainers to specify exactly where in the idle loop that RCU may be used. Because some of the userspace upcall uses can result in what looks to RCU like half of an interrupt, it is not possible to expect that the irq_enter() and irq_exit() hooks will give exact counts. This patch therefore expands the ->dynticks_nesting counter to 64 bits and uses two separate bitfields to count process/idle transitions and interrupt entry/exit transitions. It is presumed that userspace upcalls do not happen in the idle loop or from usermode execution (though usermode might do a system call that results in an upcall). The counter is hard-reset on each process/idle transition, which avoids the interrupt entry/exit error from accumulating. Overflow is avoided by the 64-bitness of the ->dyntick_nesting counter. This commit also adds warnings if a non-idle task asks RCU to enter idle state (and these checks will need some adjustment before applying Frederic's OS-jitter patches (http://lkml.org/lkml/2011/10/7/246). In addition, validation of ->dynticks and ->dynticks_nesting is added. Signed-off-by: Paul E. McKenney <paul.mckenney@linaro.org> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Diffstat (limited to 'kernel/time/tick-sched.c')
-rw-r--r--kernel/time/tick-sched.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 40420644d0b..5d9d23665f1 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -434,7 +434,6 @@ void tick_nohz_stop_sched_tick(int inidle)
434 ts->idle_tick = hrtimer_get_expires(&ts->sched_timer); 434 ts->idle_tick = hrtimer_get_expires(&ts->sched_timer);
435 ts->tick_stopped = 1; 435 ts->tick_stopped = 1;
436 ts->idle_jiffies = last_jiffies; 436 ts->idle_jiffies = last_jiffies;
437 rcu_enter_nohz();
438 } 437 }
439 438
440 ts->idle_sleeps++; 439 ts->idle_sleeps++;
@@ -473,6 +472,8 @@ out:
473 ts->last_jiffies = last_jiffies; 472 ts->last_jiffies = last_jiffies;
474 ts->sleep_length = ktime_sub(dev->next_event, now); 473 ts->sleep_length = ktime_sub(dev->next_event, now);
475end: 474end:
475 if (inidle)
476 rcu_idle_enter();
476 local_irq_restore(flags); 477 local_irq_restore(flags);
477} 478}
478 479
@@ -529,6 +530,7 @@ void tick_nohz_restart_sched_tick(void)
529 ktime_t now; 530 ktime_t now;
530 531
531 local_irq_disable(); 532 local_irq_disable();
533 rcu_idle_exit();
532 if (ts->idle_active || (ts->inidle && ts->tick_stopped)) 534 if (ts->idle_active || (ts->inidle && ts->tick_stopped))
533 now = ktime_get(); 535 now = ktime_get();
534 536
@@ -543,8 +545,6 @@ void tick_nohz_restart_sched_tick(void)
543 545
544 ts->inidle = 0; 546 ts->inidle = 0;
545 547
546 rcu_exit_nohz();
547
548 /* Update jiffies first */ 548 /* Update jiffies first */
549 select_nohz_load_balancer(0); 549 select_nohz_load_balancer(0);
550 tick_do_update_jiffies64(now); 550 tick_do_update_jiffies64(now);