From: Kirill Tkhai <ktkhai@odin.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] exit: Clarify choice of new parent in forget_original_parent()
Date: Wed, 17 Jun 2015 20:23:14 +0300 [thread overview]
Message-ID: <1434561794.1711.50.camel@odin.com> (raw)
In-Reply-To: <20150616192759.GA28955@redhat.com>
В Вт, 16/06/2015 в 21:27 +0200, Oleg Nesterov пишет:
> On 06/16, Kirill Tkhai wrote:
> >
> > Second parameter of find_new_reaper() and the similarity of its name
> > and find_child_reaper()'s name confuse a reader.
>
> OK, I agree that
>
> reaper = find_child_reaper(father);
> ...
> reaper = find_new_reaper(father, reaper);
>
> can look confusing and probably deserves a cleanup. How about the patch
> below then?
Good, IMO it improves the readability.
>
> > Rename find_child_reaper() for better conformity of its name and its
> > function.
>
> I never argueus with renames ;) Probably the new name looks better.
>
> > Also delete the second parameter of find_new_reaper().
>
> Yes, we can do this. But this 2nd argument avoids another another
> task_active_pid_ns(father)->child_reaper, so this is optimization.
>
> I agree, this optimization is minor, but still I think this change
> needs some justification.
It looks like gcc inlines both of these function, so it seems there won't
be a problem...
>
> > +static struct task_struct *find_new_reaper(struct task_struct *father)
> > {
> > - struct task_struct *thread, *reaper;
> > + struct task_struct *thread, *reaper, *child_reaper;
> >
> > thread = find_alive_thread(father);
> > if (thread)
> > return thread;
> >
> > + child_reaper = task_active_pid_ns(father)->child_reaper;
> > + /*
> > + * child_reaper doesn't have children after zap_pid_ns_processes(),
> > + * therefore it can't enter this function.
> > + */
> > + BUG_ON(child_reaper == father);
>
> Yes, we can add this BUG_ON(). But please see the comments in
> zap_pid_ns_processes(). We can change zap_pid_ns_processes() so that
> it returns with non-empty ->children list due to EXIT_DEAD children.
Yes, I saw. Since zap_pid_ns_processes() waits for nr_hashed,
and __unhash_process() deletes from pid chain and sibling list
at the same time, pid_ns child_reaper can't have a child after
nr_hashed == init_pids.
> Unlikely we will actually do this, at least soon, so I won't argue
> with this BUG_ON().
>
> But. In this case it would be better to add it into forget_original_parent(),
>
> reaper = find_new_reaper(...);
> BUG_ON(reaper == father);
Yeah, I'm agree.
> Oh. Off-topic, but this reminds me that I forgot about another bug with
> ->has_child_subreaper... this needs another discussion.
>
> Oleg.
>
> --- x/kernel/exit.c
> +++ x/kernel/exit.c
> @@ -551,17 +551,17 @@ static void reparent_leader(struct task_
> static void forget_original_parent(struct task_struct *father,
> struct list_head *dead)
> {
> - struct task_struct *p, *t, *reaper;
> + struct task_struct *p, *t, *child_reaper, *reaper;
>
> if (unlikely(!list_empty(&father->ptraced)))
> exit_ptrace(father, dead);
>
> /* Can drop and reacquire tasklist_lock */
> - reaper = find_child_reaper(father);
> + child_reaper = find_child_reaper(father);
> if (list_empty(&father->children))
> return;
>
> - reaper = find_new_reaper(father, reaper);
> + reaper = find_new_reaper(father, child_reaper);
> list_for_each_entry(p, &father->children, sibling) {
> for_each_thread(p, t) {
> t->real_parent = reaper;
>
Thanks,
Kirill
prev parent reply other threads:[~2015-06-17 17:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-16 9:49 [PATCH] exit: Clarify choice of new parent in forget_original_parent() Kirill Tkhai
2015-06-16 19:27 ` Oleg Nesterov
2015-06-16 20:03 ` Oleg Nesterov
2015-06-17 17:24 ` Kirill Tkhai
2015-06-17 17:23 ` Kirill Tkhai [this message]
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=1434561794.1711.50.camel@odin.com \
--to=ktkhai@odin.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.