Optimize sk_msg_clone() by data merge to end dst sg entry
authorVakul Garg <vakul.garg@nxp.com>
Wed, 16 Jan 2019 01:42:44 +0000 (01:42 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 17 Jan 2019 19:42:26 +0000 (11:42 -0800)
commitfda497e5f5b89ac3b2b3715e2571021c2ad55234
treea78e74759d8d7dccbfa14e4b1fa0d3f2a031d5bd
parent4559dd248297cf8eb0318cff971d5f5c33660b6c
Optimize sk_msg_clone() by data merge to end dst sg entry

Function sk_msg_clone has been modified to merge the data from source sg
entry to destination sg entry if the cloned data resides in same page
and is contiguous to the end entry of destination sk_msg. This improves
kernel tls throughput to the tune of 10%.

When the user space tls application calls sendmsg() with MSG_MORE, it leads
to calling sk_msg_clone() with new data being cloned placed continuous to
previously cloned data. Without this optimization, a new SG entry in
the destination sk_msg i.e. rec->msg_plaintext in tls_clone_plaintext_msg()
gets used. This leads to exhaustion of sg entries in rec->msg_plaintext
even before a full 16K of allowable record data is accumulated. Hence we
lose oppurtunity to encrypt and send a full 16K record.

With this patch, the kernel tls can accumulate full 16K of record data
irrespective of the size of data passed in sendmsg() with MSG_MORE.

Signed-off-by: Vakul Garg <vakul.garg@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/skmsg.c