From: Nadia.Derbey@bull.net
To: efault@gmx.de
Cc: manfred@colorfullife.com, linux-kernel@vger.kernel.org,
paulmck@linux.vnet.ibm.com, akpm@linux-foundation.org,
peterz@infradead.org, xemul@openvz.org,
Nadia Derbey <Nadia.Derbey@bull.net>
Subject: [PATCH 12/13] Integrate the ridr code into IPC code
Date: Fri, 11 Apr 2008 18:17:14 +0200 [thread overview]
Message-ID: <20080411162003.281069000@bull.net> (raw)
In-Reply-To: 20080411161702.460410000@bull.net
[-- Attachment #1: ipc_use_ridr.patch --]
[-- Type: text/plain, Size: 7497 bytes --]
[PATCH 12/13]
This patche makes the ipc ode use the ridr api.
Signed-off-by: Nadia Derbey <Nadia.Derbey@bull.net>
---
include/linux/ipc_namespace.h | 4 +--
ipc/namespace.c | 2 -
ipc/shm.c | 2 -
ipc/util.c | 44 ++++++++++++++++++------------------------
4 files changed, 23 insertions(+), 29 deletions(-)
Index: linux-2.6.25-rc8-mm1/include/linux/ipc_namespace.h
===================================================================
--- linux-2.6.25-rc8-mm1.orig/include/linux/ipc_namespace.h 2008-04-11 17:14:05.000000000 +0200
+++ linux-2.6.25-rc8-mm1/include/linux/ipc_namespace.h 2008-04-11 18:12:18.000000000 +0200
@@ -2,7 +2,7 @@
#define __IPC_NAMESPACE_H__
#include <linux/err.h>
-#include <linux/idr.h>
+#include <linux/ridr.h>
#include <linux/rwsem.h>
#include <linux/notifier.h>
@@ -21,7 +21,7 @@ struct ipc_ids {
unsigned short seq;
unsigned short seq_max;
struct rw_semaphore rw_mutex;
- struct idr ipcs_idr;
+ struct ridr ipcs_ridr;
};
struct ipc_namespace {
Index: linux-2.6.25-rc8-mm1/ipc/namespace.c
===================================================================
--- linux-2.6.25-rc8-mm1.orig/ipc/namespace.c 2008-04-11 17:14:32.000000000 +0200
+++ linux-2.6.25-rc8-mm1/ipc/namespace.c 2008-04-11 18:12:51.000000000 +0200
@@ -74,7 +74,7 @@ void free_ipcs(struct ipc_namespace *ns,
in_use = ids->in_use;
for (total = 0, next_id = 0; total < in_use; next_id++) {
- perm = idr_find(&ids->ipcs_idr, next_id);
+ perm = ridr_find(&ids->ipcs_ridr, next_id);
if (perm == NULL)
continue;
ipc_lock_by_ptr(perm);
Index: linux-2.6.25-rc8-mm1/ipc/shm.c
===================================================================
--- linux-2.6.25-rc8-mm1.orig/ipc/shm.c 2008-04-11 17:14:32.000000000 +0200
+++ linux-2.6.25-rc8-mm1/ipc/shm.c 2008-04-11 18:13:13.000000000 +0200
@@ -571,7 +571,7 @@ static void shm_get_stat(struct ipc_name
struct shmid_kernel *shp;
struct inode *inode;
- shp = idr_find(&shm_ids(ns).ipcs_idr, next_id);
+ shp = ridr_find(&shm_ids(ns).ipcs_ridr, next_id);
if (shp == NULL)
continue;
Index: linux-2.6.25-rc8-mm1/ipc/util.c
===================================================================
--- linux-2.6.25-rc8-mm1.orig/ipc/util.c 2008-04-11 17:14:32.000000000 +0200
+++ linux-2.6.25-rc8-mm1/ipc/util.c 2008-04-11 18:17:08.000000000 +0200
@@ -122,7 +122,7 @@ __initcall(ipc_init);
* @ids: Identifier set
*
* Set up the sequence range to use for the ipc identifier range (limited
- * below IPCMNI) then initialise the ids idr.
+ * below IPCMNI) then initialise the ids ridr.
*/
void ipc_init_ids(struct ipc_ids *ids)
@@ -139,7 +139,7 @@ void ipc_init_ids(struct ipc_ids *ids)
ids->seq_max = seq_limit;
}
- idr_init(&ids->ipcs_idr);
+ INIT_RIDR(&ids->ipcs_ridr, GFP_KERNEL);
}
#ifdef CONFIG_PROC_FS
@@ -195,7 +195,7 @@ static struct kern_ipc_perm *ipc_findkey
int total;
for (total = 0, next_id = 0; total < ids->in_use; next_id++) {
- ipc = idr_find(&ids->ipcs_idr, next_id);
+ ipc = ridr_find(&ids->ipcs_ridr, next_id);
if (ipc == NULL)
continue;
@@ -234,7 +234,7 @@ int ipc_get_maxid(struct ipc_ids *ids)
/* Look for the last assigned id */
total = 0;
for (id = 0; id < IPCMNI && total < ids->in_use; id++) {
- ipc = idr_find(&ids->ipcs_idr, id);
+ ipc = ridr_find(&ids->ipcs_ridr, id);
if (ipc != NULL) {
max_id = id;
total++;
@@ -249,7 +249,7 @@ int ipc_get_maxid(struct ipc_ids *ids)
* @new: new IPC permission set
* @size: limit for the number of used ids
*
- * Add an entry 'new' to the IPC ids idr. The permissions object is
+ * Add an entry 'new' to the IPC ids ridr. The permissions object is
* initialised and the first free entry is set up and the id assigned
* is returned. The 'new' entry is returned in a locked state on success.
* On failure the entry is not locked and a negative err-code is returned.
@@ -267,7 +267,7 @@ int ipc_addid(struct ipc_ids* ids, struc
if (ids->in_use >= size)
return -ENOSPC;
- err = idr_get_new(&ids->ipcs_idr, new, &id);
+ err = ridr_get_new(&ids->ipcs_ridr, new, &id);
if (err)
return err;
@@ -303,7 +303,7 @@ static int ipcget_new(struct ipc_namespa
{
int err;
retry:
- err = idr_pre_get(&ids->ipcs_idr, GFP_KERNEL);
+ err = ridr_pre_get(GFP_KERNEL);
if (!err)
return -ENOMEM;
@@ -312,6 +312,8 @@ retry:
err = ops->getnew(ns, params);
up_write(&ids->rw_mutex);
+ ridr_pre_get_end();
+
if (err == -EAGAIN)
goto retry;
@@ -369,7 +371,7 @@ static int ipcget_public(struct ipc_name
int flg = params->flg;
int err;
retry:
- err = idr_pre_get(&ids->ipcs_idr, GFP_KERNEL);
+ err = ridr_pre_get(GFP_KERNEL);
/*
* Take the lock as a writer since we are potentially going to add
@@ -404,6 +406,7 @@ retry:
ipc_unlock(ipcp);
}
up_write(&ids->rw_mutex);
+ ridr_pre_get_end();
if (err == -EAGAIN)
goto retry;
@@ -425,7 +428,7 @@ void ipc_rmid(struct ipc_ids *ids, struc
{
int lid = ipcid_to_idx(ipcp->id);
- idr_remove(&ids->ipcs_idr, lid);
+ ridr_remove(&ids->ipcs_ridr, lid);
ids->in_use--;
@@ -686,13 +689,9 @@ void ipc64_perm_to_ipc_perm (struct ipc6
* @ids: IPC identifier set
* @id: ipc id to look for
*
- * Look for an id in the ipc ids idr and lock the associated ipc object.
+ * Look for an id in the ipc ids ridr and lock the associated ipc object.
*
* The ipc object is locked on exit.
- *
- * This is the routine that should be called when the rw_mutex is not already
- * held, i.e. idr tree not protected: it protects the idr tree in read mode
- * during the idr_find().
*/
struct kern_ipc_perm *ipc_lock(struct ipc_ids *ids, int id)
@@ -700,18 +699,13 @@ struct kern_ipc_perm *ipc_lock(struct ip
struct kern_ipc_perm *out;
int lid = ipcid_to_idx(id);
- down_read(&ids->rw_mutex);
-
rcu_read_lock();
- out = idr_find(&ids->ipcs_idr, lid);
+ out = ridr_find(&ids->ipcs_ridr, lid);
if (out == NULL) {
rcu_read_unlock();
- up_read(&ids->rw_mutex);
return ERR_PTR(-EINVAL);
}
- up_read(&ids->rw_mutex);
-
spin_lock(&out->lock);
/* ipc_rmid() may have already freed the ID while ipc_lock
@@ -731,12 +725,12 @@ struct kern_ipc_perm *ipc_lock(struct ip
* @ids: IPC identifier set
* @id: ipc id to look for
*
- * Look for an id in the ipc ids idr and lock the associated ipc object.
+ * Look for an id in the ipc ids ridr and lock the associated ipc object.
*
* The ipc object is locked on exit.
*
* This is the routine that should be called when the rw_mutex is already
- * held, i.e. idr tree protected.
+ * held, i.e. ridr tree protected.
*/
struct kern_ipc_perm *ipc_lock_down(struct ipc_ids *ids, int id)
@@ -745,7 +739,7 @@ struct kern_ipc_perm *ipc_lock_down(stru
int lid = ipcid_to_idx(id);
rcu_read_lock();
- out = idr_find(&ids->ipcs_idr, lid);
+ out = ridr_find(&ids->ipcs_ridr, lid);
if (out == NULL) {
rcu_read_unlock();
return ERR_PTR(-EINVAL);
@@ -916,7 +910,7 @@ static struct kern_ipc_perm *sysvipc_fin
total = 0;
for (id = 0; id < pos && total < ids->in_use; id++) {
- ipc = idr_find(&ids->ipcs_idr, id);
+ ipc = ridr_find(&ids->ipcs_ridr, id);
if (ipc != NULL)
total++;
}
@@ -925,7 +919,7 @@ static struct kern_ipc_perm *sysvipc_fin
return NULL;
for ( ; pos < IPCMNI; pos++) {
- ipc = idr_find(&ids->ipcs_idr, pos);
+ ipc = ridr_find(&ids->ipcs_ridr, pos);
if (ipc != NULL) {
*new_pos = pos + 1;
ipc_lock_by_ptr(ipc);
--
next prev parent reply other threads:[~2008-04-11 16:23 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-11 16:17 [PATCH 00/13] Re: Scalability requirements for sysv ipc Nadia.Derbey
2008-04-11 16:17 ` [PATCH 01/13] duplicate idr code Nadia.Derbey
2008-04-11 16:17 ` [PATCH 02/13] Change ridr structure Nadia.Derbey
2008-04-11 16:17 ` [PATCH 03/13] Fix ridr_pre_get() Nadia.Derbey
2008-04-11 16:17 ` [PATCH 04/13] Fix ridr_alloc_layer() Nadia.Derbey
2008-04-11 16:17 ` [PATCH 05/13] Fix free_layer() Nadia.Derbey
2008-04-11 16:17 ` [PATCH 06/13] Fix sub_alloc() Nadia.Derbey
2008-04-11 16:17 ` [PATCH 07/13] Fix get_empty_slot() Nadia.Derbey
2008-04-11 16:17 ` [PATCH 08/13] Fix ridr_get_new_above_int() Nadia.Derbey
2008-04-11 16:17 ` [PATCH 09/13] Fix ridr_remove() Nadia.Derbey
2008-04-11 16:17 ` [PATCH 10/13] Fix ridr_find() Nadia.Derbey
2008-04-11 16:17 ` [PATCH 11/13] Integrate the ridr code Nadia.Derbey
2008-04-11 16:17 ` Nadia.Derbey [this message]
2008-04-11 16:17 ` [PATCH 13/13] Get rid of ipc_lock_down() Nadia.Derbey
2008-04-11 16:27 ` [PATCH 00/13] Re: Scalability requirements for sysv ipc Peter Zijlstra
2008-04-14 5:18 ` Nadia Derbey
2008-04-14 7:15 ` Peter Zijlstra
2008-04-14 8:33 ` Nadia Derbey
2008-04-14 10:52 ` Nadia Derbey
2008-04-14 18:54 ` Manfred Spraul
2008-04-15 6:13 ` Nadia Derbey
2008-04-19 23:28 ` Paul E. McKenney
2008-04-21 8:07 ` Nadia Derbey
2008-04-21 14:44 ` Paul E. McKenney
2008-04-14 13:54 ` Mike Galbraith
2008-04-14 15:01 ` Nadia Derbey
2008-04-19 23:24 ` Paul E. McKenney
2008-04-19 23:25 ` Paul E. McKenney
2008-04-21 5:59 ` Nadia Derbey
2008-04-29 14:35 ` Nadia Derbey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080411162003.281069000@bull.net \
--to=nadia.derbey@bull.net \
--cc=akpm@linux-foundation.org \
--cc=efault@gmx.de \
--cc=linux-kernel@vger.kernel.org \
--cc=manfred@colorfullife.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=xemul@openvz.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox