[PATCH] fix the theoretical task_cpu/task_curr problem inkick_process/task_oncpu_function_call

From: Oleg Nesterov
Date: Wed Jan 26 2011 - 14:00:00 EST


kick_process() and task_oncpu_function_call() are not right, they
can use the dead CPU for smp_send_reschedule/smp_call_function_single
if try_to_wake_up() makes this task running after we read task_cpu().

Given that task_curr() is inline this problem is pure theoretical,
compiler doesn't read task_cpu() twice, but the code looks wrong.

Signed-off-by: Oleg Nesterov <oleg@xxxxxxxxxx>
---

kernel/sched.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

--- perf/kernel/sched.c~task_cpu_vs_task_curr 2011-01-26 19:26:40.000000000 +0100
+++ perf/kernel/sched.c 2011-01-26 19:26:58.000000000 +0100
@@ -2269,7 +2269,7 @@ void kick_process(struct task_struct *p)

preempt_disable();
cpu = task_cpu(p);
- if ((cpu != smp_processor_id()) && task_curr(p))
+ if ((cpu != smp_processor_id()) && (cpu_curr(cpu) == p))
smp_send_reschedule(cpu);
preempt_enable();
}
@@ -2292,7 +2292,7 @@ void task_oncpu_function_call(struct tas

preempt_disable();
cpu = task_cpu(p);
- if (task_curr(p))
+ if (cpu_curr(cpu) == p)
smp_call_function_single(cpu, func, info, 1);
preempt_enable();
}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/