From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932872AbcA2Sqb (ORCPT ); Fri, 29 Jan 2016 13:46:31 -0500 Received: from mail-pa0-f44.google.com ([209.85.220.44]:33874 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753296AbcA2Sqa (ORCPT ); Fri, 29 Jan 2016 13:46:30 -0500 Date: Fri, 29 Jan 2016 10:46:22 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Davidlohr Bueso cc: Hugh Dickins , Davidlohr Bueso , Mel Gorman , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Sebastian Andrzej Siewior , Chris Mason , Darren Hart , linux-kernel@vger.kernel.org, Mel Gorman Subject: Re: [PATCH v4] futex: Remove requirement for lock_page in get_futex_key In-Reply-To: <20160129183557.GA16147@linux-uzut.site> Message-ID: References: <1453569254-25928-1-git-send-email-dbueso@suse.de> <20160129183557.GA16147@linux-uzut.site> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 29 Jan 2016, Davidlohr Bueso wrote: > On Wed, 27 Jan 2016, Hugh Dickins wrote: > > > > + * > > > + * The RCU read lock is taken as the inode is finally freed > > > + * under RCU. If the mapping still matches expectations then > > > the > > > + * mapping->host can be safely accessed as being a valid > > > inode. > > > + */ > > > + rcu_read_lock(); > > > + if (READ_ONCE(page->mapping) != mapping || > > > + !mapping->host) { > > > > If you're being as paranoid as all the WARN_ON_ONCEs hereabouts imply, > > then it would be better to do the inode = READ_ONCE(mapping->host) > > before checking !inode rather than !mapping->host. > > Ok, it also reads a bit nicer than the above, which was simply avoiding > a load in the again case. > > rcu_read_lock(); > inode = READ_ONCE(mapping->host); Just a quick unthinking from-the-hip response to that, something for you to think over before sending v5: without looking back at the code, it's not obvious to me that it's safe to read mapping->host before we've confirmed under rcu_read_lock() that page->mapping still matches mapping. > > if (!inode || READ_ONCE(page->mapping) != mapping) > rcu_read_unlock(); > put_page(page); > > goto again; > }