aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@tv-sign.ru>2006-09-29 05:01:09 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-09-29 12:18:20 -0400
commit29b884921634e1e01cbd276e1c9b8fc07a7e4a90 (patch)
tree951fce8626715b1ad26ca81bec9002cfcb8242af
parente8106b941ceab68cc5ff713df7b1276484554584 (diff)
[PATCH] set EXIT_DEAD state in do_exit(), not in schedule()
schedule() checks PF_DEAD on every context switch and sets ->state = EXIT_DEAD to ensure that the exiting task will be deactivated. Note that this EXIT_DEAD is in fact a "random" value, we can use any bit except normal TASK_XXX values. It is better to set this state in do_exit() along with PF_DEAD flag and remove that check in schedule(). We are safe wrt concurrent try_to_wake_up() (for example ptrace, tkill), it can not change task's ->state: the 'state' argument of try_to_wake_up() can't have EXIT_DEAD bit. And in case when try_to_wake_up() sees a stale value of ->state == TASK_RUNNING it will do nothing. Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Cc: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--kernel/exit.c1
-rw-r--r--kernel/sched.c3
2 files changed, 1 insertions, 3 deletions
diff --git a/kernel/exit.c b/kernel/exit.c
index 4a280856acd2..3d759c98fb11 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -957,6 +957,7 @@ fastcall NORET_TYPE void do_exit(long code)
957 preempt_disable(); 957 preempt_disable();
958 BUG_ON(tsk->flags & PF_DEAD); 958 BUG_ON(tsk->flags & PF_DEAD);
959 tsk->flags |= PF_DEAD; 959 tsk->flags |= PF_DEAD;
960 tsk->state = EXIT_DEAD;
960 961
961 schedule(); 962 schedule();
962 BUG(); 963 BUG();
diff --git a/kernel/sched.c b/kernel/sched.c
index 155a33da7aa7..e1646b044b69 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3348,9 +3348,6 @@ need_resched_nonpreemptible:
3348 3348
3349 spin_lock_irq(&rq->lock); 3349 spin_lock_irq(&rq->lock);
3350 3350
3351 if (unlikely(prev->flags & PF_DEAD))
3352 prev->state = EXIT_DEAD;
3353
3354 switch_count = &prev->nivcsw; 3351 switch_count = &prev->nivcsw;
3355 if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) { 3352 if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) {
3356 switch_count = &prev->nvcsw; 3353 switch_count = &prev->nvcsw;