public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Pavel Emelyanov <xemul@parallels.com>,
	Serge Hallyn <serge.hallyn@canonical.com>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Tejun Heo <tj@kernel.org>, Vasiliy Kulikov <segoon@openwall.com>,
	Andrew Vagin <avagin@openvz.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] fs, proc: Introduce the /proc/<pid>/children entry v2
Date: Thu, 8 Dec 2011 17:35:35 +0100	[thread overview]
Message-ID: <20111208163535.GA25023@redhat.com> (raw)
In-Reply-To: <20111207190340.GP21678@moon>

On 12/07, Cyrill Gorcunov wrote:
>
> On Wed, Dec 07, 2011 at 07:53:43PM +0100, Oleg Nesterov wrote:
> > Hi Cyrill,
> >
> > Sorry, I didn't read this patch yet, but
> >
> > On 12/06, Cyrill Gorcunov wrote:
> > >
> > > +static void *children_seq_start(struct seq_file *seq, loff_t *pos)
> > > +{
> > > +	struct task_struct *task;
> > > +
> > > +	rcu_read_lock();
> > > +	task = seq->private;
> > > +	if (task)
> > > +		return seq_list_start(&task->children, *pos);
> >
> > This looks "obviously wrong".
> >
> > We can not trust ->children->next after rcu_read_unlock(). Another
> > rcu_read_lock() can't help.
> >
> > Once again, I can be easily wrong, need to read the patch first.
> >
>
> Wait, Oleg, I might be wrong as well, but it's now a
>
> children_seq_open
>  get_proc_task (so ref to task increased)

Yes. task_struct itself can't go away.

> the children_seq_start/children_seq_stop work
> in iteration and every new iteration seq_list_next
> walks over the whole children list from the list
> head under rcu lock,

Yep, I misread this code, I though it does _next.

However, ->children list is not rcu-safe, this means that even
list_for_each() itself is not safe. Either you need tasklist or
we can probably make it rcu-safe...

As for /proc/pid/children, personally I think it is very useful.
But note that it obviously reports the children per-thread, while
in general this is the per-process thing. Not sure this really
makes sense, but perhaps /proc/pid/children and
/proc/pid/task/tid/children should act differently. Like, say,
proc_tid_stat/proc_tgid_stat. I won't insist.

Oleg.


  parent reply	other threads:[~2011-12-08 16:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-06 18:10 [PATCH] fs, proc: Introduce the /proc/<pid>/children entry v2 Cyrill Gorcunov
2011-12-06 22:33 ` Andrew Morton
2011-12-06 22:35   ` Cyrill Gorcunov
2011-12-07  9:41     ` Cyrill Gorcunov
2011-12-07 18:27       ` Tejun Heo
2011-12-07 18:43         ` Cyrill Gorcunov
2011-12-07 18:53 ` Oleg Nesterov
2011-12-07 19:03   ` Cyrill Gorcunov
2011-12-07 19:19     ` Cyrill Gorcunov
2011-12-07 20:34       ` Cyrill Gorcunov
2011-12-07 21:52         ` Cyrill Gorcunov
2011-12-08 16:35     ` Oleg Nesterov [this message]
2011-12-08 16:50       ` Cyrill Gorcunov
2011-12-08 21:28       ` Cyrill Gorcunov
2011-12-08 21:54         ` Andrew Morton
2011-12-08 22:21           ` Cyrill Gorcunov
2011-12-09 15:30           ` Oleg Nesterov
2011-12-09 15:49             ` Cyrill Gorcunov
2011-12-09 16:55               ` Oleg Nesterov
2011-12-09 17:11                 ` Cyrill Gorcunov

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=20111208163535.GA25023@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=avagin@openvz.org \
    --cc=gorcunov@gmail.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=segoon@openwall.com \
    --cc=serge.hallyn@canonical.com \
    --cc=tj@kernel.org \
    --cc=xemul@parallels.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox