public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] idr: document that idr_for_each may be used under rcu_read_lock()
@ 2010-05-10 16:55 Brice Goglin
  0 siblings, 0 replies; only message in thread
From: Brice Goglin @ 2010-05-10 16:55 UTC (permalink / raw)
  To: Nadia Derbey; +Cc: LKML, Paul E. McKenney, Jim Houston

Hello Nadia,

In commit f9c46d6ea5ce138a886c3a0f10a46130afab75f5, you converted
idr_find() and idr_for_each() to rcu_dereference(). The documentation
of idr_find() was updated to say that it may now be called under
rcu_read_lock(). But the doc of idr_for_each() still says:
"The caller must serialize idr_for_each() vs idr_get_new() and
idr_remove()."

I might be missing something, but assuming idr_for_each() may also be
called under rcu_read_lock(), we need something like the patch below,
right? (I just duplicated the doc update of idr_find())

thanks,
Brice


>From 35a05eba9cc16d7fe786a9a7ff17f88fcf8b06e2 Mon Sep 17 00:00:00 2001
From: Brice Goglin <Brice.Goglin@inria.fr>
Date: Mon, 10 May 2010 18:49:51 +0200
Subject: [PATCH] idr: document that idr_for_each may be used under rcu_read_lock()

Since commit f9c46d6ea5ce138a886c3a0f10a46130afab75f5, idr_for_each()
may be called under rcu_read_lock(). It does not need serialization
against idr_get_new() and idr_remove() anymore.

Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
---
 lib/idr.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/lib/idr.c b/lib/idr.c
index 2eb1dca..7eb435d 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -541,7 +541,8 @@ EXPORT_SYMBOL(idr_find);
  * We check the return of @fn each time. If it returns anything other
  * than 0, we break out and return that value.
  *
- * The caller must serialize idr_for_each() vs idr_get_new() and idr_remove().
+ * This function can be called under rcu_read_lock(), given that the leaf
+ * pointers lifetimes are correctly managed.
  */
 int idr_for_each(struct idr *idp,
 		 int (*fn)(int id, void *p, void *data), void *data)
-- 
1.7.1




^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2010-05-10 17:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-10 16:55 [PATCH] idr: document that idr_for_each may be used under rcu_read_lock() Brice Goglin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox