diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2020-11-30 11:09:45 +0100 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2020-12-02 01:56:01 +0100 |
commit | 94e0028a052ad3df1c0229f66104eff16525da11 (patch) | |
tree | 47439a0e387145cc102f7f40c7eabdd4f1e015e8 /drivers/s390/net/ctcm_fsms.c | |
parent | net: freescale: ucc_geth: remove unused SKB_ALLOC_TIMEOUT (diff) | |
download | linux-94e0028a052ad3df1c0229f66104eff16525da11.tar.xz linux-94e0028a052ad3df1c0229f66104eff16525da11.zip |
s390/ctcm: Avoid temporary allocation of struct th_header and th_sweep.
The size of struct th_header is 8 byte and the size of struct th_sweep
is 16 byte. The memory for is allocated, initialized, used and
deallocated a few lines later.
It is more efficient to avoid the allocation/free dance and assign the
values directly to skb's data part instead of using memcpy() for it.
Avoid an allocation of struct th_sweep/th_header and use the resulting
skb pointer instead.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
[jwi: use skb_put_zero(), instead of skb_put() + memset to 0]
Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/s390/net/ctcm_fsms.c')
-rw-r--r-- | drivers/s390/net/ctcm_fsms.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/drivers/s390/net/ctcm_fsms.c b/drivers/s390/net/ctcm_fsms.c index 661d2a49bce9..b341075397d9 100644 --- a/drivers/s390/net/ctcm_fsms.c +++ b/drivers/s390/net/ctcm_fsms.c @@ -1303,12 +1303,10 @@ static void ctcmpc_chx_txdone(fsm_instance *fi, int event, void *arg) /* p_header points to the last one we handled */ if (p_header) p_header->pdu_flag |= PDU_LAST; /*Say it's the last one*/ - header = kzalloc(TH_HEADER_LENGTH, gfp_type()); - if (!header) { - spin_unlock(&ch->collect_lock); - fsm_event(priv->mpcg->fsm, MPCG_EVENT_INOP, dev); - goto done; - } + + header = skb_push(ch->trans_skb, TH_HEADER_LENGTH); + memset(header, 0, TH_HEADER_LENGTH); + header->th_ch_flag = TH_HAS_PDU; /* Normal data */ ch->th_seq_num++; header->th_seq_num = ch->th_seq_num; @@ -1316,11 +1314,6 @@ static void ctcmpc_chx_txdone(fsm_instance *fi, int event, void *arg) CTCM_PR_DBGDATA("%s: ToVTAM_th_seq= %08x\n" , __func__, ch->th_seq_num); - memcpy(skb_push(ch->trans_skb, TH_HEADER_LENGTH), header, - TH_HEADER_LENGTH); /* put the TH on the packet */ - - kfree(header); - CTCM_PR_DBGDATA("%s: trans_skb len:%04x \n", __func__, ch->trans_skb->len); CTCM_PR_DBGDATA("%s: up-to-50 bytes of trans_skb " |