Re: [RFC][PATCH 1/6] Storing ipcs into IDRs

2007-09-10 Thread Andrew Morton
On Fri, 31 Aug 2007 13:24:46 +0200 [EMAIL PROTECTED] wrote:

> [PATCH 01/06]
> 
> 
> This patch introduces ipcs storage into IDRs. The main changes are:
>   . This ipc_ids structure is changed: the entries array is changed into a
> root idr structure.
>   . The grow_ary() routine is removed: it is not needed anymore when adding
> an ipc structure, since we are now using the IDR facility.
>   . The ipc_rmid() routine interface is changed:
>. there is no need for this routine to return the pointer passed in as
>  argument: it is now declared as a void
>. since the id is now part of the kern_ipc_perm structure, no need to
>  have it as an argument to the routine
> 
> 

This is a large patch, and I have neither the time nor competence to review
it :(

I hope that someone will find the time to do a detailed review-n-test of
this code, because the IPC code is pretty touchy and isn't well-maintained,
as I'm sure you have noticed.

Meanwhile I'll queue the patches up for a bit of compile-time and runtime
testing, thanks.


> ...
>
> + msq = (struct msg_queue *) ipc_findkey(_ids(ns), key);

As a separate cleanup: the code casts the ipc_findkey to some outer struct
in all cases.  It would be nicer to convert this to container_of().  It'll
generate the same code, but it actually represents what the code is doing
and perhaps means that the code will continue to work if the `struct
kern_ipc_perm' is not at the start of the containing struct.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC][PATCH 1/6] Storing ipcs into IDRs

2007-09-10 Thread Andrew Morton
On Fri, 31 Aug 2007 13:24:46 +0200 [EMAIL PROTECTED] wrote:

 [PATCH 01/06]
 
 
 This patch introduces ipcs storage into IDRs. The main changes are:
   . This ipc_ids structure is changed: the entries array is changed into a
 root idr structure.
   . The grow_ary() routine is removed: it is not needed anymore when adding
 an ipc structure, since we are now using the IDR facility.
   . The ipc_rmid() routine interface is changed:
. there is no need for this routine to return the pointer passed in as
  argument: it is now declared as a void
. since the id is now part of the kern_ipc_perm structure, no need to
  have it as an argument to the routine
 
 

This is a large patch, and I have neither the time nor competence to review
it :(

I hope that someone will find the time to do a detailed review-n-test of
this code, because the IPC code is pretty touchy and isn't well-maintained,
as I'm sure you have noticed.

Meanwhile I'll queue the patches up for a bit of compile-time and runtime
testing, thanks.


 ...

 + msq = (struct msg_queue *) ipc_findkey(msg_ids(ns), key);

As a separate cleanup: the code casts the ipc_findkey to some outer struct
in all cases.  It would be nicer to convert this to container_of().  It'll
generate the same code, but it actually represents what the code is doing
and perhaps means that the code will continue to work if the `struct
kern_ipc_perm' is not at the start of the containing struct.


-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC][PATCH 1/6] Storing ipcs into IDRs

2007-09-07 Thread Nadia Derbey

Nadia Derbey wrote:

Andi Kleen wrote:


[EMAIL PROTECTED] writes:



This patch introduces ipcs storage into IDRs. The main changes are:
 . This ipc_ids structure is changed: the entries array is changed 
into a

   root idr structure.
 . The grow_ary() routine is removed: it is not needed anymore when 
adding

   an ipc structure, since we are now using the IDR facility.
 . The ipc_rmid() routine interface is changed:
  . there is no need for this routine to return the pointer 
passed in as

argument: it is now declared as a void
  . since the id is now part of the kern_ipc_perm structure, no 
need to

have it as an argument to the routine




Thanks for doing this work. It was long overdue.

Do you have any data how this changes memory consumption with many 
objects?

-Andi



Andi,

Here are the results I got when creating 32768 (IPCMNI) msg queues with 
the patched kernel:


http://akt.sourceforge.net/results/2.6.23-rc2-idr/msg11/output.new

It's the output from msg11.c. This script does what follows:
. gets sysinfo(2) results
. captures /proc/meminfo
. captures /proc/slabinfo
. creates XX msg queues (XX given as parameter)
. captures /proc/meminfo
. captures /proc/slabinfo
. gets sysinfo results
. outputs all the results
. removes the created ipcs

sysinfo results: a BEFORE and an AFTER column are output where necessary.
BEFORE means "before creating the objects"
AFTER means "after the objects have been created"

meminfo results: the BEFORE and AFTER files are pasted

slabinfo results: only the differences between the BEFORE and the AFTER 
are output.



Here are also the sizes for the ref and the patched kernel:

size linux-2.6.23-rc2.ref/vmlinux linux-2.6.23-rc2/vmlinux
   textdata bss dec hex filename
4432697  496450  602112 5531259  54667b linux-2.6.23-rc2.ref/vmlinux
4430747  496450  602112 5529309  545edd linux-2.6.23-rc2/vmlinux



The http://akt.sourceforge.net/results/2.6.23-rc2-idr/msg11 directory is 
structured as follows:


msg11.c: the script I used to generate the results
output.ref: the output from msg11 with the ref kernel
output.new: the output from msg11 with the patched kernel
size: the output from the size command
ref: directory with the results files for the ref kernel
new: directory with the results files for the patched kernel
In these 2 directories:
*_mem_*before: /proc/meminfo before creating the msg queues
*_mem_*after: /proc/meminfo after creating the msg queues
*_slab_*before: /proc/slabinfo before creating the msg queues
*_slab_*after: /proc/slabinfo after creating the msg queues



Andi,

Here is an annalysis of the results I sent you yesterday (I guess you 
don't have enoguh time to look at everything):


ref code:

1) since /proc/sys/kernel/msgmni has been set to 32768, vmalloc(0x20014) 
is called to allocate the entries[] array (see grow_ary() --> 
ipc_rcu_alloc()).


==>

Before msg queues allocation:  VmallocUsed = 2860 kB
After msg queues allocation:   VmallocUsed = 2996 KB

Once allocated this array is never freed.

Unfortunately, in the result I sent you yesterday, you can't see the 
evolution since it was not the 1st time I was running the test, so the 
vmalloc() has not been called.



2) Since 32768 msg queues have been created and a msg_queue structure <
PAGE_SIZE, kmalloc(0x6C) is called 32768 times

==> size-128 in slabinfo: (I slighty simplified the output to make it 
fit in the mail):


  objs  slabs
 # name   :  
before : size-128 1070   1320128 :   4444
after  : size-12833840  33840128 : 1128  1128


patched code:
1) since 32768 msg queues are created, idr_pre_get() is called 32768 times
==> idr_layer_cache in slabinfo:

objs  slabs
 # name   :  
before : idr_layer_cache   112116136 :4 4
after  : idr_layer_cache  1189   1189136 :   4141

2) This point remains unchanged compared to the ref code.



Regards,
Nadia
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC][PATCH 1/6] Storing ipcs into IDRs

2007-09-07 Thread Nadia Derbey

Nadia Derbey wrote:

Andi Kleen wrote:


[EMAIL PROTECTED] writes:



This patch introduces ipcs storage into IDRs. The main changes are:
 . This ipc_ids structure is changed: the entries array is changed 
into a

   root idr structure.
 . The grow_ary() routine is removed: it is not needed anymore when 
adding

   an ipc structure, since we are now using the IDR facility.
 . The ipc_rmid() routine interface is changed:
  . there is no need for this routine to return the pointer 
passed in as

argument: it is now declared as a void
  . since the id is now part of the kern_ipc_perm structure, no 
need to

have it as an argument to the routine




Thanks for doing this work. It was long overdue.

Do you have any data how this changes memory consumption with many 
objects?

-Andi



Andi,

Here are the results I got when creating 32768 (IPCMNI) msg queues with 
the patched kernel:


http://akt.sourceforge.net/results/2.6.23-rc2-idr/msg11/output.new

It's the output from msg11.c. This script does what follows:
. gets sysinfo(2) results
. captures /proc/meminfo
. captures /proc/slabinfo
. creates XX msg queues (XX given as parameter)
. captures /proc/meminfo
. captures /proc/slabinfo
. gets sysinfo results
. outputs all the results
. removes the created ipcs

sysinfo results: a BEFORE and an AFTER column are output where necessary.
BEFORE means before creating the objects
AFTER means after the objects have been created

meminfo results: the BEFORE and AFTER files are pasted

slabinfo results: only the differences between the BEFORE and the AFTER 
are output.



Here are also the sizes for the ref and the patched kernel:

size linux-2.6.23-rc2.ref/vmlinux linux-2.6.23-rc2/vmlinux
   textdata bss dec hex filename
4432697  496450  602112 5531259  54667b linux-2.6.23-rc2.ref/vmlinux
4430747  496450  602112 5529309  545edd linux-2.6.23-rc2/vmlinux



The http://akt.sourceforge.net/results/2.6.23-rc2-idr/msg11 directory is 
structured as follows:


msg11.c: the script I used to generate the results
output.ref: the output from msg11 with the ref kernel
output.new: the output from msg11 with the patched kernel
size: the output from the size command
ref: directory with the results files for the ref kernel
new: directory with the results files for the patched kernel
In these 2 directories:
*_mem_*before: /proc/meminfo before creating the msg queues
*_mem_*after: /proc/meminfo after creating the msg queues
*_slab_*before: /proc/slabinfo before creating the msg queues
*_slab_*after: /proc/slabinfo after creating the msg queues



Andi,

Here is an annalysis of the results I sent you yesterday (I guess you 
don't have enoguh time to look at everything):


ref code:

1) since /proc/sys/kernel/msgmni has been set to 32768, vmalloc(0x20014) 
is called to allocate the entries[] array (see grow_ary() -- 
ipc_rcu_alloc()).


==

Before msg queues allocation:  VmallocUsed = 2860 kB
After msg queues allocation:   VmallocUsed = 2996 KB

Once allocated this array is never freed.

Unfortunately, in the result I sent you yesterday, you can't see the 
evolution since it was not the 1st time I was running the test, so the 
vmalloc() has not been called.



2) Since 32768 msg queues have been created and a msg_queue structure 
PAGE_SIZE, kmalloc(0x6C) is called 32768 times

== size-128 in slabinfo: (I slighty simplified the output to make it 
fit in the mail):


  objs  slabs
 # name   active  num size : active num
before : size-128 1070   1320128 :   4444
after  : size-12833840  33840128 : 1128  1128


patched code:
1) since 32768 msg queues are created, idr_pre_get() is called 32768 times
== idr_layer_cache in slabinfo:

objs  slabs
 # name   active  num size : active num
before : idr_layer_cache   112116136 :4 4
after  : idr_layer_cache  1189   1189136 :   4141

2) This point remains unchanged compared to the ref code.



Regards,
Nadia
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC][PATCH 1/6] Storing ipcs into IDRs

2007-09-06 Thread Nadia Derbey

Andi Kleen wrote:

[EMAIL PROTECTED] writes:



This patch introduces ipcs storage into IDRs. The main changes are:
 . This ipc_ids structure is changed: the entries array is changed into a
   root idr structure.
 . The grow_ary() routine is removed: it is not needed anymore when adding
   an ipc structure, since we are now using the IDR facility.
 . The ipc_rmid() routine interface is changed:
  . there is no need for this routine to return the pointer passed in as
argument: it is now declared as a void
  . since the id is now part of the kern_ipc_perm structure, no need to
have it as an argument to the routine




Thanks for doing this work. It was long overdue.

Do you have any data how this changes memory consumption with 
many objects? 


-Andi



Andi,

Here are the results I got when creating 32768 (IPCMNI) msg queues with 
the patched kernel:


http://akt.sourceforge.net/results/2.6.23-rc2-idr/msg11/output.new

It's the output from msg11.c. This script does what follows:
. gets sysinfo(2) results
. captures /proc/meminfo
. captures /proc/slabinfo
. creates XX msg queues (XX given as parameter)
. captures /proc/meminfo
. captures /proc/slabinfo
. gets sysinfo results
. outputs all the results
. removes the created ipcs

sysinfo results: a BEFORE and an AFTER column are output where necessary.
BEFORE means "before creating the objects"
AFTER means "after the objects have been created"

meminfo results: the BEFORE and AFTER files are pasted

slabinfo results: only the differences between the BEFORE and the AFTER 
are output.



Here are also the sizes for the ref and the patched kernel:

size linux-2.6.23-rc2.ref/vmlinux linux-2.6.23-rc2/vmlinux
   textdata bss dec hex filename
4432697  496450  602112 5531259  54667b linux-2.6.23-rc2.ref/vmlinux
4430747  496450  602112 5529309  545edd linux-2.6.23-rc2/vmlinux



The http://akt.sourceforge.net/results/2.6.23-rc2-idr/msg11 directory is 
structured as follows:


msg11.c: the script I used to generate the results
output.ref: the output from msg11 with the ref kernel
output.new: the output from msg11 with the patched kernel
size: the output from the size command
ref: directory with the results files for the ref kernel
new: directory with the results files for the patched kernel
In these 2 directories:
*_mem_*before: /proc/meminfo before creating the msg queues
*_mem_*after: /proc/meminfo after creating the msg queues
*_slab_*before: /proc/slabinfo before creating the msg queues
*_slab_*after: /proc/slabinfo after creating the msg queues

Regards,
Nadia

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC][PATCH 1/6] Storing ipcs into IDRs

2007-09-03 Thread Nadia Derbey

Andi Kleen wrote:

[EMAIL PROTECTED] writes:



This patch introduces ipcs storage into IDRs. The main changes are:
 . This ipc_ids structure is changed: the entries array is changed into a
   root idr structure.
 . The grow_ary() routine is removed: it is not needed anymore when adding
   an ipc structure, since we are now using the IDR facility.
 . The ipc_rmid() routine interface is changed:
  . there is no need for this routine to return the pointer passed in as
argument: it is now declared as a void
  . since the id is now part of the kern_ipc_perm structure, no need to
have it as an argument to the routine




Thanks for doing this work. It was long overdue.

Do you have any data how this changes memory consumption with 
many objects? 



No. Will try to send you this as soon as I've done some measurements.

Regards,
Nadia


--
===
Name.. Nadia DERBEY
Organization.. BULL/DT/OSwR/Linux
---
Email. mailto:[EMAIL PROTECTED]
Address... BULL, B.P. 208, 38432 Echirolles Cedex, France
Tel... (33) 76 29 77 62 [Internal Bull: (229) 77 62]
Telex,Fax. 980648 F - (33) 76 29 76 00
Internal Bull. Mail: FREC-B1405
===

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC][PATCH 1/6] Storing ipcs into IDRs

2007-09-03 Thread Nadia Derbey

Andi Kleen wrote:

[EMAIL PROTECTED] writes:



This patch introduces ipcs storage into IDRs. The main changes are:
 . This ipc_ids structure is changed: the entries array is changed into a
   root idr structure.
 . The grow_ary() routine is removed: it is not needed anymore when adding
   an ipc structure, since we are now using the IDR facility.
 . The ipc_rmid() routine interface is changed:
  . there is no need for this routine to return the pointer passed in as
argument: it is now declared as a void
  . since the id is now part of the kern_ipc_perm structure, no need to
have it as an argument to the routine




Thanks for doing this work. It was long overdue.

Do you have any data how this changes memory consumption with 
many objects? 



No. Will try to send you this as soon as I've done some measurements.

Regards,
Nadia


--
===
Name.. Nadia DERBEY
Organization.. BULL/DT/OSwRD/Linux
---
Email. mailto:[EMAIL PROTECTED]
Address... BULL, B.P. 208, 38432 Echirolles Cedex, France
Tel... (33) 76 29 77 62 [Internal Bull: (229) 77 62]
Telex,Fax. 980648 F - (33) 76 29 76 00
Internal Bull. Mail: FREC-B1405
===

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC][PATCH 1/6] Storing ipcs into IDRs

2007-09-01 Thread Andi Kleen
[EMAIL PROTECTED] writes:

> This patch introduces ipcs storage into IDRs. The main changes are:
>   . This ipc_ids structure is changed: the entries array is changed into a
> root idr structure.
>   . The grow_ary() routine is removed: it is not needed anymore when adding
> an ipc structure, since we are now using the IDR facility.
>   . The ipc_rmid() routine interface is changed:
>. there is no need for this routine to return the pointer passed in as
>  argument: it is now declared as a void
>. since the id is now part of the kern_ipc_perm structure, no need to
>  have it as an argument to the routine
> 

Thanks for doing this work. It was long overdue.

Do you have any data how this changes memory consumption with 
many objects? 

-Andi
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC][PATCH 1/6] Storing ipcs into IDRs

2007-09-01 Thread Andi Kleen
[EMAIL PROTECTED] writes:

 This patch introduces ipcs storage into IDRs. The main changes are:
   . This ipc_ids structure is changed: the entries array is changed into a
 root idr structure.
   . The grow_ary() routine is removed: it is not needed anymore when adding
 an ipc structure, since we are now using the IDR facility.
   . The ipc_rmid() routine interface is changed:
. there is no need for this routine to return the pointer passed in as
  argument: it is now declared as a void
. since the id is now part of the kern_ipc_perm structure, no need to
  have it as an argument to the routine
 

Thanks for doing this work. It was long overdue.

Do you have any data how this changes memory consumption with 
many objects? 

-Andi
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC][PATCH 1/6] Storing ipcs into IDRs

2007-08-31 Thread Nadia . Derbey
[PATCH 01/06]


This patch introduces ipcs storage into IDRs. The main changes are:
  . This ipc_ids structure is changed: the entries array is changed into a
root idr structure.
  . The grow_ary() routine is removed: it is not needed anymore when adding
an ipc structure, since we are now using the IDR facility.
  . The ipc_rmid() routine interface is changed:
   . there is no need for this routine to return the pointer passed in as
 argument: it is now declared as a void
   . since the id is now part of the kern_ipc_perm structure, no need to
 have it as an argument to the routine


Signed-off-by: Nadia Derbey <[EMAIL PROTECTED]>

---
 include/linux/ipc.h |1 
 include/linux/msg.h |1 
 include/linux/sem.h |1 
 include/linux/shm.h |1 
 ipc/msg.c   |  113 +-
 ipc/sem.c   |  111 -
 ipc/shm.c   |  116 +-
 ipc/util.c  |  264 +++-
 ipc/util.h  |   32 +-
 9 files changed, 329 insertions(+), 311 deletions(-)

Index: linux-2.6.23-rc2/include/linux/ipc.h
===
--- linux-2.6.23-rc2.orig/include/linux/ipc.h   2007-08-31 07:49:01.0 
+0200
+++ linux-2.6.23-rc2/include/linux/ipc.h2007-08-31 08:05:36.0 
+0200
@@ -61,6 +61,7 @@ struct kern_ipc_perm
 {
spinlock_t  lock;
int deleted;
+   int id;
key_t   key;
uid_t   uid;
gid_t   gid;
Index: linux-2.6.23-rc2/include/linux/msg.h
===
--- linux-2.6.23-rc2.orig/include/linux/msg.h   2007-08-31 07:49:01.0 
+0200
+++ linux-2.6.23-rc2/include/linux/msg.h2007-08-31 08:06:24.0 
+0200
@@ -77,7 +77,6 @@ struct msg_msg {
 /* one msq_queue structure for each present queue on the system */
 struct msg_queue {
struct kern_ipc_perm q_perm;
-   int q_id;
time_t q_stime; /* last msgsnd time */
time_t q_rtime; /* last msgrcv time */
time_t q_ctime; /* last change time */
Index: linux-2.6.23-rc2/include/linux/sem.h
===
--- linux-2.6.23-rc2.orig/include/linux/sem.h   2007-08-31 07:49:01.0 
+0200
+++ linux-2.6.23-rc2/include/linux/sem.h2007-08-31 08:06:45.0 
+0200
@@ -90,7 +90,6 @@ struct sem {
 /* One sem_array data structure for each set of semaphores in the system. */
 struct sem_array {
struct kern_ipc_permsem_perm;   /* permissions .. see ipc.h */
-   int sem_id;
time_t  sem_otime;  /* last semop time */
time_t  sem_ctime;  /* last change time */
struct sem  *sem_base;  /* ptr to first semaphore in 
array */
Index: linux-2.6.23-rc2/include/linux/shm.h
===
--- linux-2.6.23-rc2.orig/include/linux/shm.h   2007-08-31 07:49:01.0 
+0200
+++ linux-2.6.23-rc2/include/linux/shm.h2007-08-31 08:07:07.0 
+0200
@@ -77,7 +77,6 @@ struct shmid_kernel /* private to the ke
 {  
struct kern_ipc_permshm_perm;
struct file *   shm_file;
-   int id;
unsigned long   shm_nattch;
unsigned long   shm_segsz;
time_t  shm_atim;
Index: linux-2.6.23-rc2/ipc/util.h
===
--- linux-2.6.23-rc2.orig/ipc/util.h2007-08-31 07:49:21.0 +0200
+++ linux-2.6.23-rc2/ipc/util.h 2007-08-31 11:29:21.0 +0200
@@ -10,6 +10,8 @@
 #ifndef _IPC_UTIL_H
 #define _IPC_UTIL_H
 
+#include 
+
 #define USHRT_MAX 0x
 #define SEQ_MULTIPLIER (IPCMNI)
 
@@ -25,24 +27,17 @@ void sem_exit_ns(struct ipc_namespace *n
 void msg_exit_ns(struct ipc_namespace *ns);
 void shm_exit_ns(struct ipc_namespace *ns);
 
-struct ipc_id_ary {
-   int size;
-   struct kern_ipc_perm *p[0];
-};
-
 struct ipc_ids {
int in_use;
-   int max_id;
unsigned short seq;
unsigned short seq_max;
struct mutex mutex;
-   struct ipc_id_ary nullentry;
-   struct ipc_id_ary* entries;
+   struct idr ipcs_idr;
 };
 
 struct seq_file;
 
-void ipc_init_ids(struct ipc_ids *ids, int size);
+void ipc_init_ids(struct ipc_ids *);
 #ifdef CONFIG_PROC_FS
 void __init ipc_init_proc_interface(const char *path, const char *header,
int ids, int (*show)(struct seq_file *, void *));
@@ -55,11 +50,12 @@ void __init ipc_init_proc_interface(cons
 #define IPC_SHM_IDS2
 
 /* must be called with ids->mutex acquired.*/
-int ipc_findkey(struct ipc_ids* ids, key_t key);
-int ipc_addid(struct ipc_ids* ids, struct 

[RFC][PATCH 1/6] Storing ipcs into IDRs

2007-08-31 Thread Nadia . Derbey
[PATCH 01/06]


This patch introduces ipcs storage into IDRs. The main changes are:
  . This ipc_ids structure is changed: the entries array is changed into a
root idr structure.
  . The grow_ary() routine is removed: it is not needed anymore when adding
an ipc structure, since we are now using the IDR facility.
  . The ipc_rmid() routine interface is changed:
   . there is no need for this routine to return the pointer passed in as
 argument: it is now declared as a void
   . since the id is now part of the kern_ipc_perm structure, no need to
 have it as an argument to the routine


Signed-off-by: Nadia Derbey [EMAIL PROTECTED]

---
 include/linux/ipc.h |1 
 include/linux/msg.h |1 
 include/linux/sem.h |1 
 include/linux/shm.h |1 
 ipc/msg.c   |  113 +-
 ipc/sem.c   |  111 -
 ipc/shm.c   |  116 +-
 ipc/util.c  |  264 +++-
 ipc/util.h  |   32 +-
 9 files changed, 329 insertions(+), 311 deletions(-)

Index: linux-2.6.23-rc2/include/linux/ipc.h
===
--- linux-2.6.23-rc2.orig/include/linux/ipc.h   2007-08-31 07:49:01.0 
+0200
+++ linux-2.6.23-rc2/include/linux/ipc.h2007-08-31 08:05:36.0 
+0200
@@ -61,6 +61,7 @@ struct kern_ipc_perm
 {
spinlock_t  lock;
int deleted;
+   int id;
key_t   key;
uid_t   uid;
gid_t   gid;
Index: linux-2.6.23-rc2/include/linux/msg.h
===
--- linux-2.6.23-rc2.orig/include/linux/msg.h   2007-08-31 07:49:01.0 
+0200
+++ linux-2.6.23-rc2/include/linux/msg.h2007-08-31 08:06:24.0 
+0200
@@ -77,7 +77,6 @@ struct msg_msg {
 /* one msq_queue structure for each present queue on the system */
 struct msg_queue {
struct kern_ipc_perm q_perm;
-   int q_id;
time_t q_stime; /* last msgsnd time */
time_t q_rtime; /* last msgrcv time */
time_t q_ctime; /* last change time */
Index: linux-2.6.23-rc2/include/linux/sem.h
===
--- linux-2.6.23-rc2.orig/include/linux/sem.h   2007-08-31 07:49:01.0 
+0200
+++ linux-2.6.23-rc2/include/linux/sem.h2007-08-31 08:06:45.0 
+0200
@@ -90,7 +90,6 @@ struct sem {
 /* One sem_array data structure for each set of semaphores in the system. */
 struct sem_array {
struct kern_ipc_permsem_perm;   /* permissions .. see ipc.h */
-   int sem_id;
time_t  sem_otime;  /* last semop time */
time_t  sem_ctime;  /* last change time */
struct sem  *sem_base;  /* ptr to first semaphore in 
array */
Index: linux-2.6.23-rc2/include/linux/shm.h
===
--- linux-2.6.23-rc2.orig/include/linux/shm.h   2007-08-31 07:49:01.0 
+0200
+++ linux-2.6.23-rc2/include/linux/shm.h2007-08-31 08:07:07.0 
+0200
@@ -77,7 +77,6 @@ struct shmid_kernel /* private to the ke
 {  
struct kern_ipc_permshm_perm;
struct file *   shm_file;
-   int id;
unsigned long   shm_nattch;
unsigned long   shm_segsz;
time_t  shm_atim;
Index: linux-2.6.23-rc2/ipc/util.h
===
--- linux-2.6.23-rc2.orig/ipc/util.h2007-08-31 07:49:21.0 +0200
+++ linux-2.6.23-rc2/ipc/util.h 2007-08-31 11:29:21.0 +0200
@@ -10,6 +10,8 @@
 #ifndef _IPC_UTIL_H
 #define _IPC_UTIL_H
 
+#include linux/idr.h
+
 #define USHRT_MAX 0x
 #define SEQ_MULTIPLIER (IPCMNI)
 
@@ -25,24 +27,17 @@ void sem_exit_ns(struct ipc_namespace *n
 void msg_exit_ns(struct ipc_namespace *ns);
 void shm_exit_ns(struct ipc_namespace *ns);
 
-struct ipc_id_ary {
-   int size;
-   struct kern_ipc_perm *p[0];
-};
-
 struct ipc_ids {
int in_use;
-   int max_id;
unsigned short seq;
unsigned short seq_max;
struct mutex mutex;
-   struct ipc_id_ary nullentry;
-   struct ipc_id_ary* entries;
+   struct idr ipcs_idr;
 };
 
 struct seq_file;
 
-void ipc_init_ids(struct ipc_ids *ids, int size);
+void ipc_init_ids(struct ipc_ids *);
 #ifdef CONFIG_PROC_FS
 void __init ipc_init_proc_interface(const char *path, const char *header,
int ids, int (*show)(struct seq_file *, void *));
@@ -55,11 +50,12 @@ void __init ipc_init_proc_interface(cons
 #define IPC_SHM_IDS2
 
 /* must be called with ids-mutex acquired.*/
-int ipc_findkey(struct ipc_ids* ids, key_t key);
-int ipc_addid(struct ipc_ids* ids,