summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2022-04-28 12:57:46 +0200
committerJakub Kicinski <kuba@kernel.org>2022-05-02 23:36:24 +0200
commit829b7bdd70449c211eb6b2673fcbc597ce120939 (patch)
treeb0f32cba453e0e9472cd6d0f76db77c6ef7c2bf2
parentocteontx2-af: debugfs: fix error return of allocations (diff)
downloadlinux-829b7bdd70449c211eb6b2673fcbc597ce120939.tar.xz
linux-829b7bdd70449c211eb6b2673fcbc597ce120939.zip
tcp: optimise skb_zerocopy_iter_stream()
It's expensive to make a copy of 40B struct iov_iter to the point it was taking 0.2-0.5% of all cycles in my tests. iov_iter_revert() should be fine as it's a simple case without nested reverts/truncates. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/a7e1690c00c5dfe700c30eb9a8a81ec59f6545dd.1650884401.git.asml.silence@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r--net/core/skbuff.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index b92e93dcaa91..475183f37891 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1344,7 +1344,6 @@ int skb_zerocopy_iter_stream(struct sock *sk, struct sk_buff *skb,
struct ubuf_info *uarg)
{
struct ubuf_info *orig_uarg = skb_zcopy(skb);
- struct iov_iter orig_iter = msg->msg_iter;
int err, orig_len = skb->len;
/* An skb can only point to one uarg. This edge case happens when
@@ -1358,7 +1357,7 @@ int skb_zerocopy_iter_stream(struct sock *sk, struct sk_buff *skb,
struct sock *save_sk = skb->sk;
/* Streams do not free skb on error. Reset to prev state. */
- msg->msg_iter = orig_iter;
+ iov_iter_revert(&msg->msg_iter, skb->len - orig_len);
skb->sk = sk;
___pskb_trim(skb, orig_len);
skb->sk = save_sk;