lkml.org 
[lkml]   [2011]   [Dec]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] fs, proc: Introduce the /proc/<pid>/children entry v2
On Wed, Dec 07, 2011 at 11:19:16PM +0400, Cyrill Gorcunov wrote:
...
> > >
> > > 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 as
> >
> > children_seq_open
> > get_proc_task (so ref to task increased)
> >
> > the children_seq_start/children_seq_stop works
> > in iteration and every new iteration seq_list_next
> > walks over the whole children list from the list
> > head under rcu lock, so even if task is removed
> > or added the link should exsist until rcu is unlocked
> > and sync'ed no?
> >
>
> On the other hands some if (task) tests are redundant
> and might be dropped since we have a reference to a
> task until seq-file is not released. I'll update it
> and shrink a patch some more.
>

So while adding new task to a list is not a problem (the reader
will simply not notice it) removing task from a list is a bit
tricky, but as far as I see switch_task_namespaces (from exit_notify)
uses synchronize_rcu as well as release_task calls for call_rcu
for put_task_struct) so I think we will not get any wrong dereference
in

static int children_seq_show(struct seq_file *seq, void *v)
{
struct task_struct *task = container_of(v, struct task_struct, sibling);
return seq_printf(seq, " %lu", (unsigned long)pid_vnr(task_pid(task)));
}

while we're in rcu reader section. I might be wrong of course, so
please verify this claim.

Cyrill


\
 
 \ /
  Last update: 2011-12-07 21:37    [W:0.187 / U:0.272 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site