aboutsummaryrefslogtreecommitdiffstats
path: root/net/strparser/strparser.c
diff options
context:
space:
mode:
authorVakul Garg <vakul.garg@nxp.com>2018-06-29 15:15:55 -0400
committerDavid S. Miller <davem@davemloft.net>2018-06-30 08:25:39 -0400
commit4e485d06bb8c7811a0d69a811c77befd54b9ab0c (patch)
tree83739c15a00c922f1b44e901cef4db7423302e0a /net/strparser/strparser.c
parent180390c470e1b6e3e19b4f969524182eeb5e4e6c (diff)
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>
Diffstat (limited to 'net/strparser/strparser.c')
-rw-r--r--net/strparser/strparser.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/net/strparser/strparser.c b/net/strparser/strparser.c
index 373836615c57..4f40a90ca016 100644
--- a/net/strparser/strparser.c
+++ b/net/strparser/strparser.c
@@ -155,11 +155,13 @@ static int __strp_recv(read_descriptor_t *desc, struct sk_buff *orig_skb,
155 /* We are going to append to the frags_list of head. 155 /* We are going to append to the frags_list of head.
156 * Need to unshare the frag_list. 156 * Need to unshare the frag_list.
157 */ 157 */
158 err = skb_unclone(head, GFP_ATOMIC); 158 if (skb_has_frag_list(head)) {
159 if (err) { 159 err = skb_unclone(head, GFP_ATOMIC);
160 STRP_STATS_INCR(strp->stats.mem_fail); 160 if (err) {
161 desc->error = err; 161 STRP_STATS_INCR(strp->stats.mem_fail);
162 return 0; 162 desc->error = err;
163 return 0;
164 }
163 } 165 }
164 166
165 if (unlikely(skb_shinfo(head)->frag_list)) { 167 if (unlikely(skb_shinfo(head)->frag_list)) {
@@ -216,14 +218,16 @@ static int __strp_recv(read_descriptor_t *desc, struct sk_buff *orig_skb,
216 memset(stm, 0, sizeof(*stm)); 218 memset(stm, 0, sizeof(*stm));
217 stm->strp.offset = orig_offset + eaten; 219 stm->strp.offset = orig_offset + eaten;
218 } else { 220 } else {
219 /* Unclone since we may be appending to an skb that we 221 /* Unclone if we are appending to an skb that we
220 * already share a frag_list with. 222 * already share a frag_list with.
221 */ 223 */
222 err = skb_unclone(skb, GFP_ATOMIC); 224 if (skb_has_frag_list(skb)) {
223 if (err) { 225 err = skb_unclone(skb, GFP_ATOMIC);
224 STRP_STATS_INCR(strp->stats.mem_fail); 226 if (err) {
225 desc->error = err; 227 STRP_STATS_INCR(strp->stats.mem_fail);
226 break; 228 desc->error = err;
229 break;
230 }
227 } 231 }
228 232
229 stm = _strp_msg(head); 233 stm = _strp_msg(head);