Skip to content

Commit 61eadef

Browse files
Mike GalbraithIngo Molnar
authored andcommitted
sched, rt: Update rq clock when unthrottling of an otherwise idle CPU
If an RT task is awakened while it's rt_rq is throttled, the time between wakeup/enqueue and unthrottle/selection may be accounted as rt_time if the CPU is idle. Set rq->skip_clock_update negative upon throttle release to tell put_prev_task() that we need a clock update. Reported-by: Thomas Giesel <skoe@directbox.com> Signed-off-by: Mike Galbraith <efault@gmx.de> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1304059010.7472.1.camel@marge.simson.net Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent 3e51e3e commit 61eadef

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

‎kernel/sched.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ struct rq {
466466
u64 nohz_stamp;
467467
unsigned char nohz_balance_kick;
468468
#endif
469-
unsigned int skip_clock_update;
469+
int skip_clock_update;
470470

471471
/* capture load from *all* tasks on this cpu: */
472472
struct load_weight load;
@@ -652,7 +652,7 @@ static void update_rq_clock(struct rq *rq)
652652
{
653653
s64 delta;
654654

655-
if (rq->skip_clock_update)
655+
if (rq->skip_clock_update > 0)
656656
return;
657657

658658
delta = sched_clock_cpu(cpu_of(rq)) - rq->clock;
@@ -4127,7 +4127,7 @@ static inline void schedule_debug(struct task_struct *prev)
41274127

41284128
static void put_prev_task(struct rq *rq, struct task_struct *prev)
41294129
{
4130-
if (prev->on_rq)
4130+
if (prev->on_rq || rq->skip_clock_update < 0)
41314131
update_rq_clock(rq);
41324132
prev->sched_class->put_prev_task(rq, prev);
41334133
}

‎kernel/sched_rt.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,13 @@ static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun)
562562
if (rt_rq->rt_throttled && rt_rq->rt_time < runtime) {
563563
rt_rq->rt_throttled = 0;
564564
enqueue = 1;
565+
566+
/*
567+
* Force a clock update if the CPU was idle,
568+
* lest wakeup -> unthrottle time accumulate.
569+
*/
570+
if (rt_rq->rt_nr_running && rq->curr == rq->idle)
571+
rq->skip_clock_update = -1;
565572
}
566573
if (rt_rq->rt_time || rt_rq->rt_nr_running)
567574
idle = 0;

0 commit comments

Comments
 (0)