Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SCTP]: Remove sctp_add_cmd_sf wrapper bloat

With a was number of callsites sctp_add_cmd_sf wrapper bloats
kernel by some amount. Due to unlikely tracking allyesconfig,
with the initial result were around ~7kB (thus caught my
attention) while a non-debug config produced only ~2.3kB effect.

I (ij) proposed first a patch to uninline it but Vlad responded
with a patch that removed the only sctp_add_cmd call which is
wrapped by sctp_add_cmd_sf (I wasn't sure if I could do that).
I did minor cleanup to Vlad's patch.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Ilpo Järvinen and committed by
David S. Miller
bc09dff1 419ae74e

+5 -24
+1 -2
include/net/sctp/command.h
··· 205 205 int sctp_init_cmd_seq(sctp_cmd_seq_t *seq); 206 206 207 207 /* Add a command to an sctp_cmd_seq_t. 208 - * Return 0 if the command sequence is full. 209 208 * 210 209 * Use the SCTP_* constructors defined by SCTP_ARG_CONSTRUCTOR() above 211 210 * to wrap data which goes in the obj argument. 212 211 */ 213 - int sctp_add_cmd(sctp_cmd_seq_t *seq, sctp_verb_t verb, sctp_arg_t obj); 212 + void sctp_add_cmd_sf(sctp_cmd_seq_t *seq, sctp_verb_t verb, sctp_arg_t obj); 214 213 215 214 /* Return the next command structure in an sctp_cmd_seq. 216 215 * Return NULL at the end of the sequence.
-8
include/net/sctp/sm.h
··· 385 385 return (((s) == (t)) || (((t) - (s)) & ADDIP_SERIAL_SIGN_BIT)); 386 386 } 387 387 388 - 389 - /* Run sctp_add_cmd() generating a BUG() if there is a failure. */ 390 - static inline void sctp_add_cmd_sf(sctp_cmd_seq_t *seq, sctp_verb_t verb, sctp_arg_t obj) 391 - { 392 - if (unlikely(!sctp_add_cmd(seq, verb, obj))) 393 - BUG(); 394 - } 395 - 396 388 /* Check VTAG of the packet matches the sender's own tag. */ 397 389 static inline int 398 390 sctp_vtag_verify(const struct sctp_chunk *chunk,
+2 -8
net/sctp/command.c
··· 52 52 /* Add a command to a sctp_cmd_seq_t. 53 53 * Return 0 if the command sequence is full. 54 54 */ 55 - int sctp_add_cmd(sctp_cmd_seq_t *seq, sctp_verb_t verb, sctp_arg_t obj) 55 + void sctp_add_cmd_sf(sctp_cmd_seq_t *seq, sctp_verb_t verb, sctp_arg_t obj) 56 56 { 57 - if (seq->next_free_slot >= SCTP_MAX_NUM_COMMANDS) 58 - goto fail; 57 + BUG_ON(seq->next_free_slot >= SCTP_MAX_NUM_COMMANDS); 59 58 60 59 seq->cmds[seq->next_free_slot].verb = verb; 61 60 seq->cmds[seq->next_free_slot++].obj = obj; 62 - 63 - return 1; 64 - 65 - fail: 66 - return 0; 67 61 } 68 62 69 63 /* Return the next command structure in a sctp_cmd_seq.
+2 -6
net/sctp/sm_statefuns.c
··· 3135 3135 if (!ev) 3136 3136 goto nomem; 3137 3137 3138 - if (!sctp_add_cmd(commands, SCTP_CMD_EVENT_ULP, 3139 - SCTP_ULPEVENT(ev))) { 3140 - sctp_ulpevent_free(ev); 3141 - goto nomem; 3142 - } 3143 - 3138 + sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, 3139 + SCTP_ULPEVENT(ev)); 3144 3140 sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_OPERR, 3145 3141 SCTP_CHUNK(chunk)); 3146 3142 }