History

timers/tick/broadcast-hrtimer: Fix suspicious RCU usage in idle loop

The hrtimer mode of broadcast queues hrtimers in the idle entry path so as to wakeup cpus in deep idle states. The associated call graph is : cpuidle_idle_call() |____ clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, ....)) |_____tick_broadcast_set_event() |____clockevents_program_event() |____bc_set_next() The hrtimer_{start/cancel} functions call into tracing which uses RCU. But it is not legal to call into RCU in cpuidle because it is one of the quiescent states. Hence protect this region with RCU_NONIDLE which informs RCU that the cpu is momentarily non-idle. As an aside it is helpful to point out that the clock event device that is programmed here is not a per-cpu clock device; it is a pseudo clock device, used by the broadcast framework alone. The per-cpu clock device programming never goes through bc_set_next().

Preeti U Murthy committed 11 years ago

Commit a127d2b1 parent bc465aa1 file · +9 −2Browse files

Unified · Split

kernel/time/tick-broadcast-hrtimer.c+9−2
@@ -49,6 +49,7 @@ static void bc_set_mode(enum clock_event_mode mode, · 48 unmodified lines
49 */49 */
50static int bc_set_next(ktime_t expires, struct clock_event_device *bc)50static int bc_set_next(ktime_t expires, struct clock_event_device *bc)
51{51{
52 int bc_moved;
52 /*53 /*
53 * We try to cancel the timer first. If the callback is on54 * We try to cancel the timer first. If the callback is on
54 * flight on some other cpu then we let it handle it. If we55 * flight on some other cpu then we let it handle it. If we
@@ -60,9 +61,15 @@ static int bc_set_next(ktime_t expires, struct clock_event_device *bc) · 5 unmodified lines
60 * restart the timer because we are in the callback, but we61 * restart the timer because we are in the callback, but we
61 * can set the expiry time and let the callback return62 * can set the expiry time and let the callback return
62 * HRTIMER_RESTART.63 * HRTIMER_RESTART.
64 *
65 * Since we are in the idle loop at this point and because
66 * hrtimer_{start/cancel} functions call into tracing,
67 * calls to these functions must be bound within RCU_NONIDLE.
63 */68 */
64 if (hrtimer_try_to_cancel(&bctimer) >= 0) {69 RCU_NONIDLE(bc_moved = (hrtimer_try_to_cancel(&bctimer) >= 0) ?
65 hrtimer_start(&bctimer, expires, HRTIMER_MODE_ABS_PINNED);70 !hrtimer_start(&bctimer, expires, HRTIMER_MODE_ABS_PINNED) :
71 0);
72 if (bc_moved) {
66 /* Bind the "device" to the cpu */73 /* Bind the "device" to the cpu */
67 bc->bound_on = smp_processor_id();74 bc->bound_on = smp_processor_id();
68 } else if (bc->bound_on == smp_processor_id()) {75 } else if (bc->bound_on == smp_processor_id()) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t