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>
This commit is contained in:
Sebastian Andrzej Siewior
2020-11-30 11:09:45 +01:00
committed by Jakub Kicinski
parent 2bf7d3776b
commit 94e0028a05
3 changed files with 9 additions and 53 deletions

View File

@@ -655,24 +655,10 @@ static void ctcmpc_send_sweep_resp(struct channel *rch)
goto done;
}
header = kmalloc(sizeof(struct th_sweep), gfp_type());
if (!header) {
dev_kfree_skb_any(sweep_skb);
goto done;
}
header->th.th_seg = 0x00 ;
header = skb_put_zero(sweep_skb, TH_SWEEP_LENGTH);
header->th.th_ch_flag = TH_SWEEP_RESP;
header->th.th_blk_flag = 0x00;
header->th.th_is_xid = 0x00;
header->th.th_seq_num = 0x00;
header->sw.th_last_seq = ch->th_seq_num;
skb_put_data(sweep_skb, header, TH_SWEEP_LENGTH);
kfree(header);
netif_trans_update(dev);
skb_queue_tail(&ch->sweep_queue, sweep_skb);