mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 10:41:38 -04:00
ipc: merge ipc_rcu and kern_ipc_perm
ipc has two management structures that exist for every id: - struct kern_ipc_perm, it contains e.g. the permissions. - struct ipc_rcu, it contains the rcu head for rcu handling and the refcount. The patch merges both structures. As a bonus, we may save one cacheline, because both structures are cacheline aligned. In addition, it reduces the number of casts, instead most codepaths can use container_of. To simplify code, the ipc_rcu_alloc initializes the allocation to 0. [[email protected]: really include the memset() into ipc_alloc_rcu()] Link: http://lkml.kernel.org/r/[email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Manfred Spraul <[email protected]> Cc: Davidlohr Bueso <[email protected]> Cc: Kees Cook <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
1a23395672
commit
dba4cdd39e
6 changed files with 66 additions and 61 deletions
18
ipc/util.h
18
ipc/util.h
|
|
@ -47,13 +47,6 @@ static inline void msg_exit_ns(struct ipc_namespace *ns) { }
|
|||
static inline void shm_exit_ns(struct ipc_namespace *ns) { }
|
||||
#endif
|
||||
|
||||
struct ipc_rcu {
|
||||
struct rcu_head rcu;
|
||||
atomic_t refcount;
|
||||
} ____cacheline_aligned_in_smp;
|
||||
|
||||
#define ipc_rcu_to_struct(p) ((void *)(p+1))
|
||||
|
||||
/*
|
||||
* Structure that holds the parameters needed by the ipc operations
|
||||
* (see after)
|
||||
|
|
@ -125,11 +118,14 @@ void ipc_free(void *ptr);
|
|||
* Objects are reference counted, they start with reference count 1.
|
||||
* getref increases the refcount, the putref call that reduces the recount
|
||||
* to 0 schedules the rcu destruction. Caller must guarantee locking.
|
||||
*
|
||||
* struct kern_ipc_perm must be the first member in the allocated structure.
|
||||
*/
|
||||
void *ipc_rcu_alloc(int size);
|
||||
int ipc_rcu_getref(void *ptr);
|
||||
void ipc_rcu_putref(void *ptr, void (*func)(struct rcu_head *head));
|
||||
void ipc_rcu_free(struct rcu_head *head);
|
||||
struct kern_ipc_perm *ipc_rcu_alloc(int size);
|
||||
int ipc_rcu_getref(struct kern_ipc_perm *ptr);
|
||||
void ipc_rcu_putref(struct kern_ipc_perm *ptr,
|
||||
void (*func)(struct rcu_head *head));
|
||||
void ipc_rcu_free(struct rcu_head *h);
|
||||
|
||||
struct kern_ipc_perm *ipc_lock(struct ipc_ids *, int);
|
||||
struct kern_ipc_perm *ipc_obtain_object_idr(struct ipc_ids *ids, int id);
|
||||
|
|
|
|||
Loading…
Reference in a new issue