Re: [PATCH 1/3] idr: make idr_get_next() good for rcu_read_lock()

From: Andrew Morton
Date: Fri Jan 20 2012 - 18:48:08 EST


On Thu, 19 Jan 2012 12:48:48 -0800 (PST)
Hugh Dickins <hughd@xxxxxxxxxx> 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 <hughd@xxxxxxxxxx>
> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>
> Acked-by: Li Zefan <lizf@xxxxxxxxxxxxxx>
> ---
> 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"!


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/