Skip to content

Commit bc09dff

Browse files
ij1davem330
authored andcommitted
[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>
1 parent 419ae74 commit bc09dff

4 files changed

Lines changed: 5 additions & 24 deletions

File tree

‎include/net/sctp/command.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,11 @@ typedef struct {
205205
int sctp_init_cmd_seq(sctp_cmd_seq_t *seq);
206206

207207
/* Add a command to an sctp_cmd_seq_t.
208-
* Return 0 if the command sequence is full.
209208
*
210209
* Use the SCTP_* constructors defined by SCTP_ARG_CONSTRUCTOR() above
211210
* to wrap data which goes in the obj argument.
212211
*/
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);
214213

215214
/* Return the next command structure in an sctp_cmd_seq.
216215
* Return NULL at the end of the sequence.

‎include/net/sctp/sm.h‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -385,14 +385,6 @@ static inline int ADDIP_SERIAL_gte(__u16 s, __u16 t)
385385
return (((s) == (t)) || (((t) - (s)) & ADDIP_SERIAL_SIGN_BIT));
386386
}
387387

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-
396388
/* Check VTAG of the packet matches the sender's own tag. */
397389
static inline int
398390
sctp_vtag_verify(const struct sctp_chunk *chunk,

‎net/sctp/command.c‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,12 @@ int sctp_init_cmd_seq(sctp_cmd_seq_t *seq)
5252
/* Add a command to a sctp_cmd_seq_t.
5353
* Return 0 if the command sequence is full.
5454
*/
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)
5656
{
57-
if (seq->next_free_slot >= SCTP_MAX_NUM_COMMANDS)
58-
goto fail;
57+
BUG_ON(seq->next_free_slot >= SCTP_MAX_NUM_COMMANDS);
5958

6059
seq->cmds[seq->next_free_slot].verb = verb;
6160
seq->cmds[seq->next_free_slot++].obj = obj;
62-
63-
return 1;
64-
65-
fail:
66-
return 0;
6761
}
6862

6963
/* Return the next command structure in a sctp_cmd_seq.

‎net/sctp/sm_statefuns.c‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3135,12 +3135,8 @@ sctp_disposition_t sctp_sf_operr_notify(const struct sctp_endpoint *ep,
31353135
if (!ev)
31363136
goto nomem;
31373137

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));
31443140
sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_OPERR,
31453141
SCTP_CHUNK(chunk));
31463142
}

0 commit comments

Comments
 (0)