Skip to content

Commit

Permalink
sched: Update the clock of runqueue select_task_rq() selected
Browse files Browse the repository at this point in the history
In try_to_wake_up(), we update the runqueue clock, but
select_task_rq() may select a different runqueue than the one we
updated, leaving the new runqueue's clock stale for a bit.

This patch cures occasional huge latencies reported by latencytop
when coming out of idle on a mostly idle NO_HZ box.

Signed-off-by: Mike Galbraith <efault@gmx.de>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <1255070103.7639.30.camel@marge.simson.net>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Mike Galbraith authored and Ingo Molnar committed Oct 9, 2009
1 parent 36a0790 commit f5dc375
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -2311,15 +2311,15 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state,
{
int cpu, orig_cpu, this_cpu, success = 0;
unsigned long flags;
struct rq *rq;
struct rq *rq, *orig_rq;

if (!sched_feat(SYNC_WAKEUPS))
wake_flags &= ~WF_SYNC;

this_cpu = get_cpu();

smp_wmb();
rq = task_rq_lock(p, &flags);
rq = orig_rq = task_rq_lock(p, &flags);
update_rq_clock(rq);
if (!(p->state & state))
goto out;
Expand Down Expand Up @@ -2350,6 +2350,10 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state,
set_task_cpu(p, cpu);

rq = task_rq_lock(p, &flags);

if (rq != orig_rq)
update_rq_clock(rq);

WARN_ON(p->state != TASK_WAKING);
cpu = task_cpu(p);

Expand Down

0 comments on commit f5dc375

Please sign in to comment.