net/tls: Calculate nsg for zerocopy path without skb_cow_data.
authorDoron Roberts-Kedes <doronrk@fb.com>
Tue, 28 Aug 2018 23:33:57 +0000 (16:33 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 30 Aug 2018 02:57:04 +0000 (19:57 -0700)
commit0927f71dbcfb59131b289d7d518e9472e51d4830
tree1db0618375ce8e2d11e28e25aee8d20d78416387
parent7e8d5755be0e6c92d3b86a85e54c6a550b1910c5
net/tls: Calculate nsg for zerocopy path without skb_cow_data.

decrypt_skb fails if the number of sg elements required to map it
is greater than MAX_SKB_FRAGS. nsg must always be calculated, but
skb_cow_data adds unnecessary memcpy's for the zerocopy case.

The new function skb_nsg calculates the number of scatterlist elements
required to map the skb without the extra overhead of skb_cow_data.
This patch reduces memcpy by 50% on my encrypted NBD benchmarks.

Reported-by: Vakul Garg <Vakul.garg@nxp.com>
Reviewed-by: Vakul Garg <Vakul.garg@nxp.com>
Tested-by: Vakul Garg <Vakul.garg@nxp.com>
Signed-off-by: Doron Roberts-Kedes <doronrk@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tls/tls_sw.c