Skip to contentSkip to conversation

v2 PF_DEAD: cleanup usage

PATCH New Oleg Nesterov 1 participant 1 message Nov 25, 2005 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 v2 PF_DEAD: cleanup usage

schedule() checks PF_DEAD on every context switch, and sets ->state = EXIT_DEAD to ensure that exited task will be deactivated.

It is possible to set new ->state value in do_exit(), along with PF_DEAD flag, and remove the check from schedule()'s hot path.

To avoid mixing ->state/->exit_state values, this patch adds new TASK_DEAD state.

include/linux/sched.h renamed from include/linux/sched.h~1_CLEAN +1 -0
@@ -127,6 +127,7 @@ extern unsigned long nr_iowait(void);
 #define EXIT_DEAD		32
 /* in tsk->state again */
 #define TASK_NONINTERACTIVE	64
+#define TASK_DEAD		128
 
 #define __set_task_state(tsk, state_value)		\
 	do { (tsk)->state = (state_value); } while (0)
kernel/exit.c renamed from kernel/exit.c~1_CLEAN +1 -0
@@ -875,6 +875,7 @@ fastcall NORET_TYPE void do_exit(long co
 	preempt_disable();
 	BUG_ON(tsk->flags & PF_DEAD);
 	tsk->flags |= PF_DEAD;
+	tsk->state = TASK_DEAD;
 
 	schedule();
 	BUG();
kernel/sched.c renamed from kernel/sched.c~1_CLEAN +0 -3
@@ -3000,9 +3000,6 @@ need_resched_nonpreemptible:
 
 	spin_lock_irq(&rq->lock);
 
-	if (unlikely(prev->flags & PF_DEAD))
-		prev->state = EXIT_DEAD;
-
 	switch_count = &prev->nivcsw;
 	if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) {
 		switch_count = &prev->nvcsw;