From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756072Ab2ATXsK (ORCPT ); Fri, 20 Jan 2012 18:48:10 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:54489 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754242Ab2ATXsI (ORCPT ); Fri, 20 Jan 2012 18:48:08 -0500 Date: Fri, 20 Jan 2012 15:48:07 -0800 From: Andrew Morton To: Hugh Dickins Cc: Tejun Heo , Eric Dumazet , Li Zefan , Manfred Spraul , KAMEZAWA Hiroyuki , Johannes Weiner , Ying Han , Greg Thelen , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] idr: make idr_get_next() good for rcu_read_lock() Message-Id: <20120120154807.c55c9ac7.akpm@linux-foundation.org> In-Reply-To: References: <1326958401.1113.22.camel@edumazet-laptop> <1326979818.2249.12.camel@edumazet-HP-Compaq-6005-Pro-SFF-PC> X-Mailer: Sylpheed 3.0.2 (GTK+ 2.20.1; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 19 Jan 2012 12:48:48 -0800 (PST) Hugh Dickins wrote: > Make one small adjustment to idr_get_next(): take the height from the > top layer (stable under RCU) instead of from the root (unprotected by > RCU), as idr_find() does: so that it can be used with RCU locking. > Copied comment on RCU locking from idr_find(). > > Signed-off-by: Hugh Dickins > Acked-by: KAMEZAWA Hiroyuki > Acked-by: Li Zefan > --- > lib/idr.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > --- 3.2.0+.orig/lib/idr.c 2012-01-04 15:55:44.000000000 -0800 > +++ 3.2.0+/lib/idr.c 2012-01-19 11:55:28.780206713 -0800 > @@ -595,8 +595,10 @@ EXPORT_SYMBOL(idr_for_each); > * Returns pointer to registered object with id, which is next number to > * given id. After being looked up, *@nextidp will be updated for the next > * iteration. > + * > + * This function can be called under rcu_read_lock(), given that the leaf > + * pointers lifetimes are correctly managed. Awkward comment. It translates to "..., because the leaf pointers lifetimes are correctly managed". Is that what we really meant? Or did we mean "..., provided the leaf pointers lifetimes are correctly managed"? Also, "pointers" should have been "pointer" or "pointer's"!