* [patch] sched: finish fixing kthread_bind()
@ 2009-11-22 12:13 Mike Galbraith
0 siblings, 0 replies; only message in thread
From: Mike Galbraith @ 2009-11-22 12:13 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar; +Cc: LKML
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@gmx.de>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <a.p.zijlstra@chello.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);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-11-22 12:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-22 12:13 [patch] sched: finish fixing kthread_bind() Mike Galbraith
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®