aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ipc/shm.c16
-rw-r--r--ipc/util.c19
-rw-r--r--ipc/util.h1
3 files changed, 13 insertions, 23 deletions
diff --git a/ipc/shm.c b/ipc/shm.c
index d20cc25c5bdf..8cf1cf3d5bec 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -63,8 +63,6 @@ static struct ipc_ids init_shm_ids;
63 ((struct shmid_kernel*)ipc_lock(&shm_ids(ns),id)) 63 ((struct shmid_kernel*)ipc_lock(&shm_ids(ns),id))
64#define shm_unlock(shp) \ 64#define shm_unlock(shp) \
65 ipc_unlock(&(shp)->shm_perm) 65 ipc_unlock(&(shp)->shm_perm)
66#define shm_get(ns, id) \
67 ((struct shmid_kernel*)ipc_get(&shm_ids(ns),id))
68#define shm_buildid(ns, id, seq) \ 66#define shm_buildid(ns, id, seq) \
69 ipc_buildid(&shm_ids(ns), id, seq) 67 ipc_buildid(&shm_ids(ns), id, seq)
70 68
@@ -563,7 +561,19 @@ static void shm_get_stat(struct ipc_namespace *ns, unsigned long *rss,
563 struct shmid_kernel *shp; 561 struct shmid_kernel *shp;
564 struct inode *inode; 562 struct inode *inode;
565 563
566 shp = shm_get(ns, next_id); 564 /*
565 * idr_find() is called via shm_get(), so with shm_ids.mutex
566 * locked. Since ipc_addid() is also called with
567 * shm_ids.mutex down, there is no need to add read barriers
568 * here to gurantee the writes in ipc_addid() are seen in
569 * order here (for Alpha).
570 * However idr_find() itself does not necessary require
571 * ipc_ids.mutex down. So if idr_find() is used by other
572 * places without ipc_ids.mutex down, then it needs read
573 * read memory barriers as ipc_lock() does.
574 */
575
576 shp = idr_find(&shm_ids(ns).ipcs_idr, next_id);
567 if (shp == NULL) 577 if (shp == NULL)
568 continue; 578 continue;
569 579
diff --git a/ipc/util.c b/ipc/util.c
index 03b88798f71f..e72865f677a7 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -669,25 +669,6 @@ void ipc64_perm_to_ipc_perm (struct ipc64_perm *in, struct ipc_perm *out)
669 out->seq = in->seq; 669 out->seq = in->seq;
670} 670}
671 671
672/*
673 * So far only shm_get_stat() calls ipc_get() via shm_get(), so ipc_get()
674 * is called with shm_ids.mutex locked. Since grow_ary() is also called with
675 * shm_ids.mutex down(for Shared Memory), there is no need to add read
676 * barriers here to gurantee the writes in grow_ary() are seen in order
677 * here (for Alpha).
678 *
679 * However ipc_get() itself does not necessary require ipc_ids.mutex down. So
680 * if in the future ipc_get() is used by other places without ipc_ids.mutex
681 * down, then ipc_get() needs read memery barriers as ipc_lock() does.
682 */
683struct kern_ipc_perm *ipc_get(struct ipc_ids *ids, int id)
684{
685 struct kern_ipc_perm *out;
686 int lid = id % SEQ_MULTIPLIER;
687 out = idr_find(&ids->ipcs_idr, lid);
688 return out;
689}
690
691struct kern_ipc_perm *ipc_lock(struct ipc_ids *ids, int id) 672struct kern_ipc_perm *ipc_lock(struct ipc_ids *ids, int id)
692{ 673{
693 struct kern_ipc_perm *out; 674 struct kern_ipc_perm *out;
diff --git a/ipc/util.h b/ipc/util.h
index 30b2a6d7cbed..1546eda7d99e 100644
--- a/ipc/util.h
+++ b/ipc/util.h
@@ -103,7 +103,6 @@ void* ipc_rcu_alloc(int size);
103void ipc_rcu_getref(void *ptr); 103void ipc_rcu_getref(void *ptr);
104void ipc_rcu_putref(void *ptr); 104void ipc_rcu_putref(void *ptr);
105 105
106struct kern_ipc_perm* ipc_get(struct ipc_ids* ids, int id);
107struct kern_ipc_perm* ipc_lock(struct ipc_ids* ids, int id); 106struct kern_ipc_perm* ipc_lock(struct ipc_ids* ids, int id);
108void ipc_lock_by_ptr(struct kern_ipc_perm *ipcp); 107void ipc_lock_by_ptr(struct kern_ipc_perm *ipcp);
109void ipc_unlock(struct kern_ipc_perm* perm); 108void ipc_unlock(struct kern_ipc_perm* perm);