Re: [PATCH]CPU hotplug breaks wake_up_new_task

From: Nick Piggin
Date: Tue May 31 2005 - 04:47:07 EST


Srivatsa Vaddagiri wrote:
On Tue, May 31, 2005 at 07:29:39AM +0000, Shaohua Li wrote:

Hi,
There is a race condition at wake_up_new_task at CPU hotplug case.
Say do_fork
copy_process (which sets new forked task's current cpu, cpu_allowed)
<-------- the new forked task's current cpu is offline
wake_up_new_task
wake_up_new_task will put the forked task into a dead cpu.


This was noticed/fixed long back. Apparently somebody has reintroduced
the bug. The simple fix for this race is:


If you're looking at the -mm tree, then I think I must
have reintroduced the bug. It needs a comment.


--- kernel/fork.c.org 2005-05-31 14:57:15.000000000 +0530
+++ kernel/fork.c 2005-05-31 15:07:20.000000000 +0530
@@ -1024,8 +1024,7 @@ static task_t *copy_process(unsigned lon
* parent's CPU). This avoids alot of nasty races.
*/
p->cpus_allowed = current->cpus_allowed;
- if (unlikely(!cpu_isset(task_cpu(p), p->cpus_allowed)))
- set_task_cpu(p, smp_processor_id());
+ set_task_cpu(p, smp_processor_id());
/*
* Check for pending SIGKILL! The new thread should not be allowed

Could you test and check if it avoids whatever problem you are seeing?



And this patch will break balance-on-fork.
How about conditionally setting task_cpu if the task's current
CPU is offline?

Thanks,
Nick

--
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com -
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/