projects/linux·commit 983bfb7d

ipc: call idr_find() without locking in ipc_lock()

983bfb7d · Nadia Derbey <[email protected]> · 2008-07-25 01:48:03 -07:00

Call idr_find() locklessly from ipc_lock(), since the idr tree is now RCU
protected.

Signed-off-by: Nadia Derbey <[email protected]>
Acked-by: "Paul E. McKenney" <[email protected]>
Cc: Manfred Spraul <[email protected]>
Cc: Jim Houston <[email protected]>
Cc: Pierre Peiffer <[email protected]>
Acked-by: Rik van Riel <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Commit
983bfb7db303cfde56ae5bbf4e0f2f46e38c9576
Parents
cf481c20

Changes

1 files changed · +0 −9

FileStatusAddDelContent
ipc/util.cmodified+0−9View file

ipc/util.c

View file
diff --git a/ipc/util.c b/ipc/util.c
index 3339177..0f468c3 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -688,10 +688,6 @@ void ipc64_perm_to_ipc_perm (struct ipc64_perm *in, struct ipc_perm *out)
* Look for an id in the ipc ids idr and lock the associated ipc object.
*
* The ipc object is locked on exit.
- *
- * This is the routine that should be called when the rw_mutex is not already
- * held, i.e. idr tree not protected: it protects the idr tree in read mode
- * during the idr_find().
*/
struct kern_ipc_perm *ipc_lock(struct ipc_ids *ids, int id)
@@ -699,18 +695,13 @@ struct kern_ipc_perm *ipc_lock(struct ipc_ids *ids, int id)
struct kern_ipc_perm *out;
int lid = ipcid_to_idx(id);
- down_read(&ids->rw_mutex);
-
rcu_read_lock();
out = idr_find(&ids->ipcs_idr, lid);
if (out == NULL) {
rcu_read_unlock();
- up_read(&ids->rw_mutex);
return ERR_PTR(-EINVAL);
}
- up_read(&ids->rw_mutex);
-
spin_lock(&out->lock);
/* ipc_rmid() may have already freed the ID while ipc_lock