strparser: Call skb_unclone conditionally
authorVakul Garg <vakul.garg@nxp.com>
Fri, 29 Jun 2018 19:15:55 +0000 (00:45 +0530)
committerDavid S. Miller <davem@davemloft.net>
Sat, 30 Jun 2018 12:25:39 +0000 (21:25 +0900)
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>
net/strparser/strparser.c

index 373836615c5773de94e1bb47ad0676df886521e2..4f40a90ca01612e77266771e4a7a0a2cdb9ca70c 100644 (file)
@@ -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)) {
@@ -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);