[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1258892020.14325.39.camel@marge.simson.net>
Date: Sun, 22 Nov 2009 13:13:40 +0100
From: Mike Galbraith <efault@....de>
To: Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Ingo Molnar <mingo@...e.hu>
Cc: LKML <linux-kernel@...r.kernel.org>
Subject: [patch] sched: finish fixing kthread_bind()
sched: finish fixing kthread_bind()
kthread_bind() diddles task state without the task's runqueue locked,
which is against the rules. Lock the task's runqueue, and update both
runqueue clocks in the event that the task is being bound to a remote cpu.
Signed-off-by: Mike Galbraith <efault@....de>
Cc: Ingo Molnar <mingo@...e.hu>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
LKML-Reference: <new-submission>
---
kernel/sched.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
Index: linux-2.6/kernel/sched.c
===================================================================
--- linux-2.6.orig/kernel/sched.c
+++ linux-2.6/kernel/sched.c
@@ -2007,7 +2007,7 @@ static inline void check_class_changed(s
*/
void kthread_bind(struct task_struct *p, unsigned int cpu)
{
- struct rq *rq = cpu_rq(cpu);
+ struct rq *rq, *dest_rq = cpu_rq(cpu);
unsigned long flags;
/* Must have done schedule() in kthread() before we set_task_cpu */
@@ -2016,13 +2016,15 @@ void kthread_bind(struct task_struct *p,
return;
}
- spin_lock_irqsave(&rq->lock, flags);
+ rq = task_rq_lock(p, &flags);
update_rq_clock(rq);
+ if (rq != dest_rq)
+ update_rq_clock(dest_rq);
set_task_cpu(p, cpu);
p->cpus_allowed = cpumask_of_cpu(cpu);
p->rt.nr_cpus_allowed = 1;
p->flags |= PF_THREAD_BOUND;
- spin_unlock_irqrestore(&rq->lock, flags);
+ task_rq_unlock(rq, &flags);
}
EXPORT_SYMBOL(kthread_bind);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists