public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@tv-sign.ru>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Ingo Molnar <mingo@elte.hu>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@osdl.org>, Roland McGrath <roland@redhat.com>
Subject: Re: [PATCH 1/2] PF_DEAD: cleanup usage
Date: Sun, 27 Nov 2005 16:02:56 +0300	[thread overview]
Message-ID: <4389AE80.3ED0CA59@tv-sign.ru> (raw)
In-Reply-To: Pine.LNX.4.64.0511261023500.13959@g5.osdl.org

Linus Torvalds wrote:
> 
> HOWEVER. I just noticed something strange. EXIT_DEAD should be in
> "task->exit_state", not in "task->state". So there's something strange
> going on in that neck of the woods _anyway_. That whole
>
> 	...
>         if (unlikely(prev->flags & PF_DEAD))
>                 prev->state = EXIT_DEAD;
> 	...
>
> in kernel/sched.c seems totally bogus.

We can use any random value instead of EXIT_DEAD (except RUNNING,INTERRUPTIBLE,
and UNINTERRUPTIBLE). The only reason for changing the state's value is this
check below:

	if (->state && !PREEMPT_ACTIVE) {
		...
		deactivate_task();
	}

This state is invisible to proc/array.c because yes, we already have something
in ->exit_state.

We can add new TASK_DEAD or something for that. Or we can do:

-	if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) {
+	// PF_DEAD means that preemption was disabled
+	if (PF_DEAD || (prev->state && !(preempt_count() & PREEMPT_ACTIVE))) {

but this is so ugly.

> I think we should remove that thing entirely, since it's actually a total
> no-op, apart from doing something that is actively wrong. The "exit_state"
> flag should already _be_ EXIT_DEAD, no?

No, it could be EXIT_ZOMBIE if the task was not auto-reaped. So the task
should be deactivated when ->exit_state != 0. But see below.

> And now that "exit_state" is already separate from "state", the reason for
> PF_DEAD really is gone, and it could be replaced with a
>
> 	tsk->exit_state & EXIT_DEAD
>
> test instead.

No, I don't think this is right. After exit_notify() sets ->exit_state this
process is still valid from the scheduler POV, it may be preempted, may sleep.

So I beleive we really need to do something special when exiting process does
it's last context switch from do_exit(). If the process enters schedule() in
TASK_RUNNUNG, we should pass the hint to scheduler - PF_DEAD. Or we can change
the ->state before calling schedule().

Oleg.

  parent reply	other threads:[~2005-11-27 11:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-24 16:02 [PATCH 1/2] PF_DEAD: cleanup usage Oleg Nesterov
2005-11-25  5:12 ` Ingo Molnar
2005-11-25 18:01   ` Linus Torvalds
2005-11-26 10:46     ` Oleg Nesterov
2005-11-26 17:55       ` Linus Torvalds
2005-11-26 19:21         ` Oleg Nesterov
2005-11-26 18:47           ` Linus Torvalds
2005-11-27 12:18             ` Ingo Molnar
2005-11-27 13:02             ` Oleg Nesterov [this message]
2005-11-27 11:55     ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4389AE80.3ED0CA59@tv-sign.ru \
    --to=oleg@tv-sign.ru \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=roland@redhat.com \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox