lkml.org 
[lkml]   [2011]   [Jan]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] fix the theoretical task_cpu/task_curr problem in kick_process/task_oncpu_function_call
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@redhat.com>
---

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();
}


\
 
 \ /
  Last update: 2011-01-26 20:03    [W:0.116 / U:0.340 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site