Skip to content

Commit b2d75cd

Browse files
xemulLinus Torvalds
authored andcommitted
ipc: uninline some code from util.h
ipc_lock_check_down(), ipc_lock_check() and ipcget() seem too large to be inline. Besides, they give no optimization being inline as they perform calls inside in any case. Moving them into ipc/util.c saves 500 bytes of vmlinux and shortens IPC internal API. $ ./scripts/bloat-o-meter vmlinux-orig vmlinux add/remove: 3/2 grow/shrink: 0/10 up/down: 490/-989 (-499) function old new delta ipcget - 392 +392 ipc_lock_check_down - 49 +49 ipc_lock_check - 49 +49 sys_semget 119 105 -14 sys_shmget 108 86 -22 sys_msgget 100 78 -22 do_msgsnd 665 631 -34 do_msgrcv 680 644 -36 do_shmat 771 733 -38 sys_msgctl 1302 1229 -73 ipcget_new 80 - -80 sys_semtimedop 1534 1452 -82 sys_semctl 2034 1922 -112 sys_shmctl 1919 1765 -154 ipcget_public 322 - -322 The ipcget() growth is the result of gcc inlining of currently static ipcget_new/_public. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Cc: Nadia Derbey <Nadia.Derbey@bull.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent a46c999 commit b2d75cd

2 files changed

Lines changed: 57 additions & 58 deletions

File tree

‎ipc/util.c‎

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size)
248248
* This routine is called by sys_msgget, sys_semget() and sys_shmget()
249249
* when the key is IPC_PRIVATE.
250250
*/
251-
int ipcget_new(struct ipc_namespace *ns, struct ipc_ids *ids,
251+
static int ipcget_new(struct ipc_namespace *ns, struct ipc_ids *ids,
252252
struct ipc_ops *ops, struct ipc_params *params)
253253
{
254254
int err;
@@ -312,7 +312,7 @@ static int ipc_check_perms(struct kern_ipc_perm *ipcp, struct ipc_ops *ops,
312312
*
313313
* On success, the ipc id is returned.
314314
*/
315-
int ipcget_public(struct ipc_namespace *ns, struct ipc_ids *ids,
315+
static int ipcget_public(struct ipc_namespace *ns, struct ipc_ids *ids,
316316
struct ipc_ops *ops, struct ipc_params *params)
317317
{
318318
struct kern_ipc_perm *ipcp;
@@ -710,6 +710,57 @@ struct kern_ipc_perm *ipc_lock_down(struct ipc_ids *ids, int id)
710710
return out;
711711
}
712712

713+
struct kern_ipc_perm *ipc_lock_check_down(struct ipc_ids *ids, int id)
714+
{
715+
struct kern_ipc_perm *out;
716+
717+
out = ipc_lock_down(ids, id);
718+
if (IS_ERR(out))
719+
return out;
720+
721+
if (ipc_checkid(out, id)) {
722+
ipc_unlock(out);
723+
return ERR_PTR(-EIDRM);
724+
}
725+
726+
return out;
727+
}
728+
729+
struct kern_ipc_perm *ipc_lock_check(struct ipc_ids *ids, int id)
730+
{
731+
struct kern_ipc_perm *out;
732+
733+
out = ipc_lock(ids, id);
734+
if (IS_ERR(out))
735+
return out;
736+
737+
if (ipc_checkid(out, id)) {
738+
ipc_unlock(out);
739+
return ERR_PTR(-EIDRM);
740+
}
741+
742+
return out;
743+
}
744+
745+
/**
746+
* ipcget - Common sys_*get() code
747+
* @ns : namsepace
748+
* @ids : IPC identifier set
749+
* @ops : operations to be called on ipc object creation, permission checks
750+
* and further checks
751+
* @params : the parameters needed by the previous operations.
752+
*
753+
* Common routine called by sys_msgget(), sys_semget() and sys_shmget().
754+
*/
755+
int ipcget(struct ipc_namespace *ns, struct ipc_ids *ids,
756+
struct ipc_ops *ops, struct ipc_params *params)
757+
{
758+
if (params->key == IPC_PRIVATE)
759+
return ipcget_new(ns, ids, ops, params);
760+
else
761+
return ipcget_public(ns, ids, ops, params);
762+
}
763+
713764
#ifdef __ARCH_WANT_IPC_PARSE_VERSION
714765

715766

‎ipc/util.h‎

Lines changed: 4 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,6 @@ int ipc_parse_version (int *cmd);
131131
extern void free_msg(struct msg_msg *msg);
132132
extern struct msg_msg *load_msg(const void __user *src, int len);
133133
extern int store_msg(void __user *dest, struct msg_msg *msg, int len);
134-
extern int ipcget_new(struct ipc_namespace *, struct ipc_ids *,
135-
struct ipc_ops *, struct ipc_params *);
136-
extern int ipcget_public(struct ipc_namespace *, struct ipc_ids *,
137-
struct ipc_ops *, struct ipc_params *);
138134

139135
static inline int ipc_buildid(int id, int seq)
140136
{
@@ -163,57 +159,9 @@ static inline void ipc_unlock(struct kern_ipc_perm *perm)
163159
rcu_read_unlock();
164160
}
165161

166-
static inline struct kern_ipc_perm *ipc_lock_check_down(struct ipc_ids *ids,
167-
int id)
168-
{
169-
struct kern_ipc_perm *out;
170-
171-
out = ipc_lock_down(ids, id);
172-
if (IS_ERR(out))
173-
return out;
174-
175-
if (ipc_checkid(out, id)) {
176-
ipc_unlock(out);
177-
return ERR_PTR(-EIDRM);
178-
}
179-
180-
return out;
181-
}
182-
183-
static inline struct kern_ipc_perm *ipc_lock_check(struct ipc_ids *ids,
184-
int id)
185-
{
186-
struct kern_ipc_perm *out;
187-
188-
out = ipc_lock(ids, id);
189-
if (IS_ERR(out))
190-
return out;
191-
192-
if (ipc_checkid(out, id)) {
193-
ipc_unlock(out);
194-
return ERR_PTR(-EIDRM);
195-
}
196-
197-
return out;
198-
}
199-
200-
/**
201-
* ipcget - Common sys_*get() code
202-
* @ns : namsepace
203-
* @ids : IPC identifier set
204-
* @ops : operations to be called on ipc object creation, permission checks
205-
* and further checks
206-
* @params : the parameters needed by the previous operations.
207-
*
208-
* Common routine called by sys_msgget(), sys_semget() and sys_shmget().
209-
*/
210-
static inline int ipcget(struct ipc_namespace *ns, struct ipc_ids *ids,
211-
struct ipc_ops *ops, struct ipc_params *params)
212-
{
213-
if (params->key == IPC_PRIVATE)
214-
return ipcget_new(ns, ids, ops, params);
215-
else
216-
return ipcget_public(ns, ids, ops, params);
217-
}
162+
struct kern_ipc_perm *ipc_lock_check_down(struct ipc_ids *ids, int id);
163+
struct kern_ipc_perm *ipc_lock_check(struct ipc_ids *ids, int id);
164+
int ipcget(struct ipc_namespace *ns, struct ipc_ids *ids,
165+
struct ipc_ops *ops, struct ipc_params *params);
218166

219167
#endif

0 commit comments

Comments
 (0)