Skip to content

Commit

Permalink
ipc: introduce ipc object locking helpers
Browse files Browse the repository at this point in the history
Simple helpers around the (kern_ipc_perm *)->lock spinlock.

Signed-off-by: Davidlohr Bueso <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Rik van Riel <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Davidlohr Bueso authored and torvalds committed Jul 9, 2013
1 parent dbfcd91 commit 1ca7003
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions ipc/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,23 +159,33 @@ static inline int ipc_checkid(struct kern_ipc_perm *ipcp, int uid)
return uid / SEQ_MULTIPLIER != ipcp->seq;
}

static inline void ipc_lock_by_ptr(struct kern_ipc_perm *perm)
static inline void ipc_lock_object(struct kern_ipc_perm *perm)
{
rcu_read_lock();
spin_lock(&perm->lock);
}

static inline void ipc_unlock(struct kern_ipc_perm *perm)
static inline void ipc_unlock_object(struct kern_ipc_perm *perm)
{
spin_unlock(&perm->lock);
rcu_read_unlock();
}

static inline void ipc_lock_object(struct kern_ipc_perm *perm)
static inline void ipc_assert_locked_object(struct kern_ipc_perm *perm)
{
assert_spin_locked(&perm->lock);
}

static inline void ipc_lock_by_ptr(struct kern_ipc_perm *perm)
{
rcu_read_lock();
spin_lock(&perm->lock);
}

static inline void ipc_unlock(struct kern_ipc_perm *perm)
{
spin_unlock(&perm->lock);
rcu_read_unlock();
}

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,
Expand Down

0 comments on commit 1ca7003

Please sign in to comment.