From mboxrd@z Thu Jan 1 00:00:00 1970 From: Al Viro Subject: Re: [PATCH review 11/11] mnt: Honor MNT_LOCKED when detaching mounts Date: Sat, 10 Jan 2015 05:51:48 +0000 Message-ID: <20150110055148.GY22149@ZenIV.linux.org.uk> References: <87mw5xq7lt.fsf@x220.int.ebiederm.org> <1420490787-14387-11-git-send-email-ebiederm@xmission.com> <20150107184334.GZ22149@ZenIV.linux.org.uk> <87h9w2gzht.fsf@x220.int.ebiederm.org> <20150107205239.GB22149@ZenIV.linux.org.uk> <87iogi8dka.fsf@x220.int.ebiederm.org> <20150108002227.GC22149@ZenIV.linux.org.uk> <20150108223212.GF22149@ZenIV.linux.org.uk> <20150109203126.GI22149@ZenIV.linux.org.uk> <87h9vzryio.fsf@x220.int.ebiederm.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Andrey Vagin , Richard Weinberger , Linux Containers , Andy Lutomirski , linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Linus Torvalds To: "Eric W. Biederman" Return-path: Content-Disposition: inline In-Reply-To: <87h9vzryio.fsf-JOvCrm2gF+uungPnsOpG7nhyD016LWXt@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org List-Id: linux-fsdevel.vger.kernel.org On Fri, Jan 09, 2015 at 11:32:47PM -0600, Eric W. Biederman wrote: > I don't believe rcu anything in this function itself buys you anything, > but structuring this primitive so that it can be called from an rcu list > traversal seems interesting. ??? Without RCU, what would prevent it being freed right under us? The whole point is to avoid pinning it down - as it is, we can have several processes call ->kill() on the same object. The first one would end up doing cleanup, the rest would wait *without* *affecting* *fs_pin* *lifetime*. Note that I'm using autoremove there for wait.func(), then in the wait loop I check (without locks) wait.task_list being empty. It is racy; deliberately so. All I really care about in there is checking that wait.func has not been called until after rcu_read_lock(). If that is true, we know that p->wait hadn't been woken until that point, i.e. p hadn't reached rcu delay on the way to being freed until after our rcu_read_lock(). Ergo, it can't get freed until we do rcu_read_unlock() and we can safely take p->wait.lock. RCU is very much relevant there.