Skip to content

Commit 4e485d0

Browse files
nxa22042davem330
authored andcommitted
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: Vakul Garg <vakul.garg@nxp.com> Suggested-by: Boris Pismenny <borisp@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 180390c commit 4e485d0

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

net/strparser/strparser.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,13 @@ static int __strp_recv(read_descriptor_t *desc, struct sk_buff *orig_skb,
155155
/* We are going to append to the frags_list of head.
156156
* Need to unshare the frag_list.
157157
*/
158-
err = skb_unclone(head, GFP_ATOMIC);
159-
if (err) {
160-
STRP_STATS_INCR(strp->stats.mem_fail);
161-
desc->error = err;
162-
return 0;
158+
if (skb_has_frag_list(head)) {
159+
err = skb_unclone(head, GFP_ATOMIC);
160+
if (err) {
161+
STRP_STATS_INCR(strp->stats.mem_fail);
162+
desc->error = err;
163+
return 0;
164+
}
163165
}
164166

165167
if (unlikely(skb_shinfo(head)->frag_list)) {
@@ -216,14 +218,16 @@ static int __strp_recv(read_descriptor_t *desc, struct sk_buff *orig_skb,
216218
memset(stm, 0, sizeof(*stm));
217219
stm->strp.offset = orig_offset + eaten;
218220
} else {
219-
/* Unclone since we may be appending to an skb that we
221+
/* Unclone if we are appending to an skb that we
220222
* already share a frag_list with.
221223
*/
222-
err = skb_unclone(skb, GFP_ATOMIC);
223-
if (err) {
224-
STRP_STATS_INCR(strp->stats.mem_fail);
225-
desc->error = err;
226-
break;
224+
if (skb_has_frag_list(skb)) {
225+
err = skb_unclone(skb, GFP_ATOMIC);
226+
if (err) {
227+
STRP_STATS_INCR(strp->stats.mem_fail);
228+
desc->error = err;
229+
break;
230+
}
227231
}
228232

229233
stm = _strp_msg(head);

0 commit comments

Comments
 (0)