LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@tv-sign.ru>
To: Roland McGrath <roland@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Alan Cox <alan@redhat.com>,
	Davide Libenzi <davidel@xmailserver.org>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Ingo Molnar <mingo@elte.hu>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/3] orphaned pgrp fixes
Date: Wed, 5 Mar 2008 20:11:09 +0300	[thread overview]
Message-ID: <20080305171109.GB6723@tv-sign.ru> (raw)
In-Reply-To: <20080304122654.7313227010A@magilla.localdomain>

On 03/04, Roland McGrath wrote:
>
> What seems most pedantically right for this check is:
> 		is_my_init(p, p->real_parent)
> i.e.
> 		if (task_session(p->real_parent) == task_session(p) &&
> 		    task_pgrp(p->real_parent) != pgrp &&
> 		    task_tgid_nr_ns(p->real_parent, p->nsproxy->pid_ns) != 1)
> 			return 0;
> It's excluded from counting as in your session if you consider to to be init.

Yes. Not that I really understand ;) But Eric also suggested to use
is_container_init().

> The write lock on
> tasklist_lock strictly serializes all exiting process's calls from
> exit_notify.  This call is after group_dead hits.  If some other
> process in the pgrp has ->signal->live > 0 then it has not exited yet
> and when it does it will do this same check, guaranteed to be after
> ours, and after our ->signal->live == 0.

Yes. I though about that too. But, unlike ->exit_state, signal->live
is not protected by tasklist, please see below.

> Since it's after our own
> group_dead hit, the "ignored_task" check for our own group leader is
> redundant with that.

Ah, good point. I didn't realize this when I was thinking about using
signal->live.

So perhaps it's:
> 
> 	do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
> 		if (task_session(p->real_parent) == task_session(p) &&
> 		    task_pgrp(p->real_parent) != pgrp &&
>  		    atomic_read(&p->signal->live) > 0 &&
> 		    task_tgid_nr_ns(p->real_parent, p->nsproxy->pid_ns) != 1)
> 			return 0;
> 	} while_each_pid_task(pgrp, PIDTYPE_PGID, p);

I am hopeless, I can't understand orphaned pgrps.

But still. Let's suppose that pgrp should be considered as orphaned when
2 tasks A and B exit. They both exit at the same time and decrement ->live
down to zero. Now, they both can send SIGHUP to the stopped tasks.

No?

That said. Even if I am right, I agree that the signal->live check is
better. I like very much the possibility to kill the ugly "ignored_task".

> Now, about has_stopped_jobs.  It's a waste for it to be a separate loop
> across the pgrp just after we did one in will_become_orphaned_pgrp.  They
> should be merged together.

Yes sure. Looking at the code I was surprised why we don't do that.

Oleg.


  parent reply	other threads:[~2008-03-05 17:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-02 18:44 Oleg Nesterov
2008-03-04 12:26 ` Roland McGrath
2008-03-04 15:51   ` Oleg Nesterov
2008-03-05  1:11     ` Roland McGrath
2008-03-05 16:48       ` Oleg Nesterov
2008-03-05 17:11   ` Oleg Nesterov [this message]
2008-03-06  1:14     ` Eric W. Biederman
2008-03-07  1:52       ` Oleg Nesterov
2008-03-07  3:53     ` Roland McGrath

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=20080305171109.GB6723@tv-sign.ru \
    --to=oleg@tv-sign.ru \
    --cc=akpm@linux-foundation.org \
    --cc=alan@redhat.com \
    --cc=davidel@xmailserver.org \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=roland@redhat.com \
    --cc=torvalds@linux-foundation.org \
    --subject='Re: [PATCH 0/3] orphaned pgrp fixes' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).