Skip to content

Commit

Permalink
strparser: Call skb_unclone conditionally
Browse files Browse the repository at this point in the history
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: Vakul Garg <[email protected]>
Suggested-by: Boris Pismenny <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
nxa22042 authored and davem330 committed Jun 30, 2018
1 parent 180390c commit 4e485d0
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions net/strparser/strparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,13 @@ static int __strp_recv(read_descriptor_t *desc, struct sk_buff *orig_skb,
/* We are going to append to the frags_list of head.
* Need to unshare the frag_list.
*/
err = skb_unclone(head, GFP_ATOMIC);
if (err) {
STRP_STATS_INCR(strp->stats.mem_fail);
desc->error = err;
return 0;
if (skb_has_frag_list(head)) {
err = skb_unclone(head, GFP_ATOMIC);
if (err) {
STRP_STATS_INCR(strp->stats.mem_fail);
desc->error = err;
return 0;
}
}

if (unlikely(skb_shinfo(head)->frag_list)) {
Expand Down Expand Up @@ -216,14 +218,16 @@ static int __strp_recv(read_descriptor_t *desc, struct sk_buff *orig_skb,
memset(stm, 0, sizeof(*stm));
stm->strp.offset = orig_offset + eaten;
} 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.
*/
err = skb_unclone(skb, GFP_ATOMIC);
if (err) {
STRP_STATS_INCR(strp->stats.mem_fail);
desc->error = err;
break;
if (skb_has_frag_list(skb)) {
err = skb_unclone(skb, GFP_ATOMIC);
if (err) {
STRP_STATS_INCR(strp->stats.mem_fail);
desc->error = err;
break;
}
}

stm = _strp_msg(head);
Expand Down

0 comments on commit 4e485d0

Please sign in to comment.