[PATCH 2.6.24-rc3-mm1 1/3] IPC: make struct ipc_ids static in ipc_namespace

Previous thread: [PATCH 2.6.24-rc3-mm1 3/3] IPC: consolidate sem_exit_ns(), msg_exit_ns and shm_exit_ns() by pierre.peiffer on Tuesday, November 27, 2007 - 10:49 am. (1 message)

Next thread: ACPI related Warning in 2.6.24-rc3-git2 by Lukas Hejtmanek on Tuesday, November 27, 2007 - 11:05 am. (14 messages)
To: <akpm@...>
Cc: <linux-kernel@...>
Date: Tuesday, November 27, 2007 - 10:49 am

From: Pierre Peiffer <pierre.peiffer@bull.net>

Each ipc_namespace contains a table of 3 pointers to struct ipc_ids (3 for
msg, sem and shm, structure used to store each ipcs)
These pointers are dynamically allocated for each icp_namespace as the
ipc_namespace itself (for the init namespace, they are initialized with
pointer to static variables instead)

It is so for historical reason: in fact, before the use of idr to store the
ipcs, the ipcs were stored in tables of variable length, depending of the
maximum number of ipcs allowed.
Now, these 'struct ipc_ids' have a fixed size. As they are allocated in any
cases for each new ipc_namespace, there is no gain of memory in having them
allocated separately of the struct ipc_namespace.

This patch proposes to make this table static in the struct ipc_namespace.
Thus, we can allocate all in once and get rid of all the code needed to
allocate and free these ipc_ids separately.

Signed-off-by: Pierre Peiffer <pierre.peiffer@bull.net>
Acked-by: Cedric Le Goater <clg@fr.ibm.com>
Acked-by: Pavel Emelyanov <xemul@openvz.org>
---
include/linux/ipc_namespace.h | 13 +++++++++++--
ipc/msg.c | 26 ++++----------------------
ipc/namespace.c | 25 ++++---------------------
ipc/sem.c | 26 ++++----------------------
ipc/shm.c | 26 ++++----------------------
ipc/util.c | 6 +++---
ipc/util.h | 16 ++++------------
7 files changed, 34 insertions(+), 104 deletions(-)

Index: b/include/linux/ipc_namespace.h
===================================================================
--- a/include/linux/ipc_namespace.h
+++ b/include/linux/ipc_namespace.h
@@ -2,11 +2,20 @@
#define __IPC_NAMESPACE_H__

#include <linux/err.h>
+#include <linux/idr.h>
+#include <linux/rwsem.h>
+
+struct ipc_ids {
+ int in_use;
+ unsigned short seq;
+ unsigned short seq_max;
+ struct rw_semaphore rw_mu...

Previous thread: [PATCH 2.6.24-rc3-mm1 3/3] IPC: consolidate sem_exit_ns(), msg_exit_ns and shm_exit_ns() by pierre.peiffer on Tuesday, November 27, 2007 - 10:49 am. (1 message)

Next thread: ACPI related Warning in 2.6.24-rc3-git2 by Lukas Hejtmanek on Tuesday, November 27, 2007 - 11:05 am. (14 messages)