linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: sergey.senozhatsky@gmail.com, viro@zeniv.linux.org.uk,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	akpm@linux-foundation.org, mingo@elte.hu
Subject: Re: [PATCH] rcu_read_lock/unlock protect find_task_by_vpid call
Date: Sat, 30 Oct 2010 14:02:44 -0700	[thread overview]
Message-ID: <20101030210244.GE2664@linux.vnet.ibm.com> (raw)
In-Reply-To: <201010302214.DDF98906.MSFJOFtFHOLQVO@I-love.SAKURA.ne.jp>

On Sat, Oct 30, 2010 at 10:14:23PM +0900, Tetsuo Handa wrote:
> Sergey Senozhatsky wrote:
> > On (10/29/10 13:16), Paul E. McKenney wrote:
> > > Interesting...
> > > 
> > > The task-list lock is read-held at this point, which should mean that
> > > the PID mapping cannot change.  The lockdep_tasklist_lock_is_held()
> > > function does lockdep_is_held(&tasklist_lock), which must therefore
> > > only be checking for write-holding the lock.  The fix would be to
> > > make lockdep_tasklist_lock_is_held() check for either read-holding or
> > > write-holding tasklist lock.
> > > 
> > > Or is there some subtle reason that read-holding the tasklist lock is
> > > not sufficient?
> 
> This was discussed in the thread at http://kerneltrap.org/mailarchive/linux-kernel/2009/12/10/4517520 .
> Quoting from one of posts in that thead http://kerneltrap.org/mailarchive/linux-kernel/2010/2/8/4536388
> 
> | Usually tasklist gives enough protection, but if copy_process() fails
> | it calls free_pid() lockless and does call_rcu(delayed_put_pid().
> | This means, without rcu lock find_pid_ns() can't scan the hash table
> | safely.
> 
> And now the patch that adds
> 
> 	rcu_lockdep_assert(rcu_read_lock_held());
> 
> was merged in accordance with that comment.
> Therefore, I thing below change is not good.
> 
> > Should it be changed to (let's say)
> > 
> > struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
> > {
> > -	rcu_lockdep_assert(rcu_read_lock_held());
> > +	rcu_lockdep_assert(rcu_read_lock_held() || lockdep_tasklist_lock_is_held());
> > 	return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
> > }

So we should remove the lockdep_tasklist_lock_is_held() and then
apply Sergey's patch, correct?

							Thanx, Paul

  reply	other threads:[~2010-10-30 21:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-29 12:55 [PATCH] rcu_read_lock/unlock protect find_task_by_vpid call Sergey Senozhatsky
2010-10-29 20:16 ` Paul E. McKenney
2010-10-30  9:32   ` Sergey Senozhatsky
2010-10-30 13:14     ` Tetsuo Handa
2010-10-30 21:02       ` Paul E. McKenney [this message]
2010-10-30 23:33         ` Tetsuo Handa
2010-11-07 19:43           ` Paul E. McKenney
2010-11-07 22:04             ` Tetsuo Handa
2010-11-08  3:01               ` Paul E. McKenney
2010-11-08 10:28                 ` Sergey Senozhatsky
2010-11-08 13:19                   ` Paul E. McKenney
2010-11-08 16:01 ` Davidlohr Bueso
2010-11-08 16:18   ` Sergey Senozhatsky
2010-11-08 16:37     ` Davidlohr Bueso

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=20101030210244.GE2664@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).