diff options
| author | Davidlohr Bueso <davidlohr@hp.com> | 2014-01-27 20:07:09 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-28 00:02:40 -0500 |
| commit | daf948c7d1a080041ae19aca07625efec670695a (patch) | |
| tree | af17f8452bcd1e6c709f4875c4a04d95d4b6b62f | |
| parent | 8dc5cd04f97b5d6cad64df1e7dc5c49110b4d5e3 (diff) | |
ipc: delete seq_max field in struct ipc_ids
This field is only used to reset the ids seq number if it exceeds the
smaller of INT_MAX/SEQ_MULTIPLIER and USHRT_MAX, and can therefore be
moved out of the structure and into its own macro. Since each
ipc_namespace contains a table of 3 pointers to struct ipc_ids we can
save space in instruction text:
text data bss dec hex filename
56232 2348 24 58604 e4ec ipc/built-in.o
56216 2348 24 58588 e4dc ipc/built-in.o-after
Signed-off-by: Davidlohr Bueso <davidlohr@hp.com>
Reviewed-by: Jonathan Gonzalez <jgonzalez@linets.cl>
Cc: Aswin Chandramouleeswaran <aswin@hp.com>
Cc: Rik van Riel <riel@redhat.com>
Acked-by: Manfred Spraul <manfred@colorfullife.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
| -rw-r--r-- | include/linux/ipc_namespace.h | 1 | ||||
| -rw-r--r-- | ipc/util.c | 13 | ||||
| -rw-r--r-- | ipc/util.h | 1 |
3 files changed, 3 insertions, 12 deletions
diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h index f6c82de12541..e7831d203737 100644 --- a/include/linux/ipc_namespace.h +++ b/include/linux/ipc_namespace.h | |||
| @@ -21,7 +21,6 @@ struct user_namespace; | |||
| 21 | struct ipc_ids { | 21 | struct ipc_ids { |
| 22 | int in_use; | 22 | int in_use; |
| 23 | unsigned short seq; | 23 | unsigned short seq; |
| 24 | unsigned short seq_max; | ||
| 25 | struct rw_semaphore rwsem; | 24 | struct rw_semaphore rwsem; |
| 26 | struct idr ipcs_idr; | 25 | struct idr ipcs_idr; |
| 27 | int next_id; | 26 | int next_id; |
diff --git a/ipc/util.c b/ipc/util.c index cecb46e89ab0..e1b4c6db8aa0 100644 --- a/ipc/util.c +++ b/ipc/util.c | |||
| @@ -139,19 +139,10 @@ __initcall(ipc_init); | |||
| 139 | */ | 139 | */ |
| 140 | void ipc_init_ids(struct ipc_ids *ids) | 140 | void ipc_init_ids(struct ipc_ids *ids) |
| 141 | { | 141 | { |
| 142 | init_rwsem(&ids->rwsem); | ||
| 143 | |||
| 144 | ids->in_use = 0; | 142 | ids->in_use = 0; |
| 145 | ids->seq = 0; | 143 | ids->seq = 0; |
| 146 | ids->next_id = -1; | 144 | ids->next_id = -1; |
| 147 | { | 145 | init_rwsem(&ids->rwsem); |
| 148 | int seq_limit = INT_MAX/SEQ_MULTIPLIER; | ||
| 149 | if (seq_limit > USHRT_MAX) | ||
| 150 | ids->seq_max = USHRT_MAX; | ||
| 151 | else | ||
| 152 | ids->seq_max = seq_limit; | ||
| 153 | } | ||
| 154 | |||
| 155 | idr_init(&ids->ipcs_idr); | 146 | idr_init(&ids->ipcs_idr); |
| 156 | } | 147 | } |
| 157 | 148 | ||
| @@ -304,7 +295,7 @@ int ipc_addid(struct ipc_ids *ids, struct kern_ipc_perm *new, int size) | |||
| 304 | 295 | ||
| 305 | if (next_id < 0) { | 296 | if (next_id < 0) { |
| 306 | new->seq = ids->seq++; | 297 | new->seq = ids->seq++; |
| 307 | if (ids->seq > ids->seq_max) | 298 | if (ids->seq > IPCID_SEQ_MAX) |
| 308 | ids->seq = 0; | 299 | ids->seq = 0; |
| 309 | } else { | 300 | } else { |
| 310 | new->seq = ipcid_to_seqx(next_id); | 301 | new->seq = ipcid_to_seqx(next_id); |
diff --git a/ipc/util.h b/ipc/util.h index d64db3e56f7d..9c47d6f6c7b4 100644 --- a/ipc/util.h +++ b/ipc/util.h | |||
| @@ -100,6 +100,7 @@ void __init ipc_init_proc_interface(const char *path, const char *header, | |||
| 100 | 100 | ||
| 101 | #define ipcid_to_idx(id) ((id) % SEQ_MULTIPLIER) | 101 | #define ipcid_to_idx(id) ((id) % SEQ_MULTIPLIER) |
| 102 | #define ipcid_to_seqx(id) ((id) / SEQ_MULTIPLIER) | 102 | #define ipcid_to_seqx(id) ((id) / SEQ_MULTIPLIER) |
| 103 | #define IPCID_SEQ_MAX min_t(int, INT_MAX/SEQ_MULTIPLIER, USHRT_MAX) | ||
| 103 | 104 | ||
| 104 | /* must be called with ids->rwsem acquired for writing */ | 105 | /* must be called with ids->rwsem acquired for writing */ |
| 105 | int ipc_addid(struct ipc_ids *, struct kern_ipc_perm *, int); | 106 | int ipc_addid(struct ipc_ids *, struct kern_ipc_perm *, int); |
