From 4d2bff5eb86e8d7b4a20934cccb93bdeebed3558 Mon Sep 17 00:00:00 2001 From: Davidlohr Bueso Date: Tue, 30 Apr 2013 19:15:19 -0700 Subject: ipc: introduce obtaining a lockless ipc object Through ipc_lock() and therefore ipc_lock_check() we currently return the locked ipc object. This is not necessary for all situations and can, therefore, cause unnecessary ipc lock contention. Introduce analogous ipc_obtain_object() and ipc_obtain_object_check() functions that only lookup and return the ipc object. Both these functions must be called within the RCU read critical section. [akpm@linux-foundation.org: propagate the ipc_obtain_object() errno from ipc_lock()] Signed-off-by: Davidlohr Bueso Signed-off-by: Rik van Riel Reviewed-by: Chegu Vinod Acked-by: Michel Lespinasse Cc: Emmanuel Benisty Cc: Jason Low Cc: Peter Hurley Cc: Stanislav Kinsbursky Tested-by: Sedat Dilek Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- ipc/util.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'ipc/util.h') diff --git a/ipc/util.h b/ipc/util.h index ac1480a4efd..bfc8d4ea6e4 100644 --- a/ipc/util.h +++ b/ipc/util.h @@ -123,6 +123,7 @@ void ipc_rcu_getref(void *ptr); void ipc_rcu_putref(void *ptr); struct kern_ipc_perm *ipc_lock(struct ipc_ids *, int); +struct kern_ipc_perm *ipc_obtain_object(struct ipc_ids *ids, int id); void kernel_to_ipc64_perm(struct kern_ipc_perm *in, struct ipc64_perm *out); void ipc64_perm_to_ipc_perm(struct ipc64_perm *in, struct ipc_perm *out); @@ -168,6 +169,7 @@ static inline void ipc_unlock(struct kern_ipc_perm *perm) } struct kern_ipc_perm *ipc_lock_check(struct ipc_ids *ids, int id); +struct kern_ipc_perm *ipc_obtain_object_check(struct ipc_ids *ids, int id); int ipcget(struct ipc_namespace *ns, struct ipc_ids *ids, struct ipc_ops *ops, struct ipc_params *params); void free_ipcs(struct ipc_namespace *ns, struct ipc_ids *ids, -- cgit v1.2.3