Messages in this thread Patches in this message | | | Date | Mon, 5 Apr 2004 01:57:40 +0200 | From | Andrea Arcangeli <> | Subject | one more kthread_should_stop smp race |
| |
reviewing the patchsets between 2.6.5-rc3 and 2.6.5 I noticed another race like in do_softirq:
--------------- PatchSet 17177 Date: 2004/03/30 19:49:13 Author: vatsa Branch: HEAD Tag: (none) Log: [PATCH] Fix obvious stupid race in do_stop
We don't set the task state to TASK_INTERRUPTIBLE _before_ checking for kthread_should_stop in do_stop.
BKrev: 4069c129adimxhudm2NaqM222iNj9A
Members: ChangeSet:1.17177->1.17178 kernel/stop_machine.c:1.3->1.4
Index: linux-2.5/kernel/stop_machine.c diff -u linux-2.5/kernel/stop_machine.c:1.3 linux-2.5/kernel/stop_machine.c:1.4 --- linux-2.5/kernel/stop_machine.c:1.3 Wed Mar 10 02:03:28 2004 +++ linux-2.5/kernel/stop_machine.c Tue Mar 30 20:49:13 2004 @@ -149,10 +149,12 @@ complete(&smdata->done);
/* Wait for kthread_stop */ + __set_current_state(TASK_INTERRUPTIBLE); while (!kthread_should_stop()) { - __set_current_state(TASK_INTERRUPTIBLE); schedule(); + __set_current_state(TASK_INTERRUPTIBLE); } + __set_current_state(TASK_RUNNING); return ret; } --------------- the TASK_INTERRUPTIBLE may become visible to other cpus after the current cpu read kthread_should_stop.
Fix:
--- x/kernel/stop_machine.c.~1~ 2004-04-04 08:09:33.000000000 +0200 +++ x/kernel/stop_machine.c 2004-04-05 01:54:00.719800824 +0200 @@ -149,10 +149,10 @@ static int do_stop(void *_smdata) complete(&smdata->done); /* Wait for kthread_stop */ - __set_current_state(TASK_INTERRUPTIBLE); + set_current_state(TASK_INTERRUPTIBLE); while (!kthread_should_stop()) { schedule(); - __set_current_state(TASK_INTERRUPTIBLE); + set_current_state(TASK_INTERRUPTIBLE); } __set_current_state(TASK_RUNNING); return ret; - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |