Commit 4e485d06 authored by Vakul Garg's avatar Vakul Garg Committed by David S. Miller

strparser: Call skb_unclone conditionally

Calling skb_unclone() is expensive as it triggers a memcpy operation.
Instead of calling skb_unclone() unconditionally, call it only when skb
has a shared frag_list. This improves tls rx throughout significantly.
Signed-off-by: default avatarVakul Garg <vakul.garg@nxp.com>
Suggested-by: default avatarBoris Pismenny <borisp@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 180390c4
...@@ -155,12 +155,14 @@ static int __strp_recv(read_descriptor_t *desc, struct sk_buff *orig_skb, ...@@ -155,12 +155,14 @@ static int __strp_recv(read_descriptor_t *desc, struct sk_buff *orig_skb,
/* We are going to append to the frags_list of head. /* We are going to append to the frags_list of head.
* Need to unshare the frag_list. * Need to unshare the frag_list.
*/ */
if (skb_has_frag_list(head)) {
err = skb_unclone(head, GFP_ATOMIC); err = skb_unclone(head, GFP_ATOMIC);
if (err) { if (err) {
STRP_STATS_INCR(strp->stats.mem_fail); STRP_STATS_INCR(strp->stats.mem_fail);
desc->error = err; desc->error = err;
return 0; return 0;
} }
}
if (unlikely(skb_shinfo(head)->frag_list)) { if (unlikely(skb_shinfo(head)->frag_list)) {
/* We can't append to an sk_buff that already /* We can't append to an sk_buff that already
...@@ -216,15 +218,17 @@ static int __strp_recv(read_descriptor_t *desc, struct sk_buff *orig_skb, ...@@ -216,15 +218,17 @@ static int __strp_recv(read_descriptor_t *desc, struct sk_buff *orig_skb,
memset(stm, 0, sizeof(*stm)); memset(stm, 0, sizeof(*stm));
stm->strp.offset = orig_offset + eaten; stm->strp.offset = orig_offset + eaten;
} else { } else {
/* Unclone since we may be appending to an skb that we /* Unclone if we are appending to an skb that we
* already share a frag_list with. * already share a frag_list with.
*/ */
if (skb_has_frag_list(skb)) {
err = skb_unclone(skb, GFP_ATOMIC); err = skb_unclone(skb, GFP_ATOMIC);
if (err) { if (err) {
STRP_STATS_INCR(strp->stats.mem_fail); STRP_STATS_INCR(strp->stats.mem_fail);
desc->error = err; desc->error = err;
break; break;
} }
}
stm = _strp_msg(head); stm = _strp_msg(head);
*strp->skb_nextp = skb; *strp->skb_nextp = skb;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment