Skip to content

Commit c34bec5

Browse files
KAGA-KOKOThomas Gleixner
authored andcommitted
NOHZ: split tick_nohz_restart_sched_tick()
Split out the clock event device reprogramming. Preparatory patch. Signed-off-by: Thomas Gleixner <[email protected]>
1 parent 719254f commit c34bec5

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

kernel/time/tick-sched.c

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,32 @@ ktime_t tick_nohz_get_sleep_length(void)
377377
return ts->sleep_length;
378378
}
379379

380+
static void tick_nohz_restart(struct tick_sched *ts, ktime_t now)
381+
{
382+
hrtimer_cancel(&ts->sched_timer);
383+
ts->sched_timer.expires = ts->idle_tick;
384+
385+
while (1) {
386+
/* Forward the time to expire in the future */
387+
hrtimer_forward(&ts->sched_timer, now, tick_period);
388+
389+
if (ts->nohz_mode == NOHZ_MODE_HIGHRES) {
390+
hrtimer_start(&ts->sched_timer,
391+
ts->sched_timer.expires,
392+
HRTIMER_MODE_ABS);
393+
/* Check, if the timer was already in the past */
394+
if (hrtimer_active(&ts->sched_timer))
395+
break;
396+
} else {
397+
if (!tick_program_event(ts->sched_timer.expires, 0))
398+
break;
399+
}
400+
/* Update jiffies and reread time */
401+
tick_do_update_jiffies64(now);
402+
now = ktime_get();
403+
}
404+
}
405+
380406
/**
381407
* tick_nohz_restart_sched_tick - restart the idle tick from the idle task
382408
*
@@ -430,28 +456,7 @@ void tick_nohz_restart_sched_tick(void)
430456
*/
431457
ts->tick_stopped = 0;
432458
ts->idle_exittime = now;
433-
hrtimer_cancel(&ts->sched_timer);
434-
ts->sched_timer.expires = ts->idle_tick;
435-
436-
while (1) {
437-
/* Forward the time to expire in the future */
438-
hrtimer_forward(&ts->sched_timer, now, tick_period);
439-
440-
if (ts->nohz_mode == NOHZ_MODE_HIGHRES) {
441-
hrtimer_start(&ts->sched_timer,
442-
ts->sched_timer.expires,
443-
HRTIMER_MODE_ABS);
444-
/* Check, if the timer was already in the past */
445-
if (hrtimer_active(&ts->sched_timer))
446-
break;
447-
} else {
448-
if (!tick_program_event(ts->sched_timer.expires, 0))
449-
break;
450-
}
451-
/* Update jiffies and reread time */
452-
tick_do_update_jiffies64(now);
453-
now = ktime_get();
454-
}
459+
tick_nohz_restart(ts, now);
455460
local_irq_enable();
456461
}
457462

0 commit comments

Comments
 (0)