Skip to content

Commit

Permalink
ipc: update locking scheme comments
Browse files Browse the repository at this point in the history
The initial documentation was a bit incomplete, update accordingly.

[[email protected]: make it more readable in 80 columns]
Signed-off-by: Davidlohr Bueso <[email protected]>
Acked-by: Manfred Spraul <[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 Oct 17, 2013
1 parent 9c56751 commit 18ccee2
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions ipc/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,27 @@
* Pavel Emelianov <[email protected]>
*
* General sysv ipc locking scheme:
* when doing ipc id lookups, take the ids->rwsem
* rcu_read_lock()
* obtain the ipc object (kern_ipc_perm)
* perform security, capabilities, auditing and permission checks, etc.
* acquire the ipc lock (kern_ipc_perm.lock) throught ipc_lock_object()
* perform data updates (ie: SET, RMID, LOCK/UNLOCK commands)
* rcu_read_lock()
* obtain the ipc object (kern_ipc_perm) by looking up the id in an idr
* tree.
* - perform initial checks (capabilities, auditing and permission,
* etc).
* - perform read-only operations, such as STAT, INFO commands.
* acquire the ipc lock (kern_ipc_perm.lock) through
* ipc_lock_object()
* - perform data updates, such as SET, RMID commands and
* mechanism-specific operations (semop/semtimedop,
* msgsnd/msgrcv, shmat/shmdt).
* drop the ipc lock, through ipc_unlock_object().
* rcu_read_unlock()
*
* The ids->rwsem must be taken when:
* - creating, removing and iterating the existing entries in ipc
* identifier sets.
* - iterating through files under /proc/sysvipc/
*
* Note that sems have a special fast path that avoids kern_ipc_perm.lock -
* see sem_lock().
*/

#include <linux/mm.h>
Expand Down

0 comments on commit 18ccee2

Please sign in to comment.