netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: netdev@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, alan.maguire@oracle.com,
	Willem de Bruijn <willemb@google.com>
Subject: [PATCH bpf-next v2 01/13] bpf: in bpf_skb_adjust_room avoid copy in tx fast path
Date: Fri, 22 Mar 2019 11:14:52 -0400	[thread overview]
Message-ID: <20190322151504.89983-2-willemdebruijn.kernel@gmail.com> (raw)
In-Reply-To: <20190322151504.89983-1-willemdebruijn.kernel@gmail.com>

From: Willem de Bruijn <willemb@google.com>

bpf_skb_adjust_room calls skb_cow on grow.

This expensive operation can be avoided in the fast path when the only
other clone has released the header. This is the common case for TCP,
where one headerless clone is kept on the retransmit queue.

It is safe to do so even when touching the gso fields in skb_shinfo.
Regular tunnel encap with iptunnel_handle_offloads takes the same
optimization.

The tcp stack unclones in the unlikely case that it accesses these
fields through headerless clones packets on the retransmit queue (see
__tcp_retransmit_skb).

If any other clones are present, e.g., from packet sockets,
skb_cow_head returns the same value as skb_cow().

Signed-off-by: Willem de Bruijn <willemb@google.com>
---
 net/core/filter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/filter.c b/net/core/filter.c
index d2511fe46db3..d21e1acdde29 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -2971,7 +2971,7 @@ static int bpf_skb_net_grow(struct sk_buff *skb, u32 len_diff)
 	if (skb_is_gso(skb) && !skb_is_gso_tcp(skb))
 		return -ENOTSUPP;
 
-	ret = skb_cow(skb, len_diff);
+	ret = skb_cow_head(skb, len_diff);
 	if (unlikely(ret < 0))
 		return ret;
 
-- 
2.21.0.392.gf8f6787159e-goog


  reply	other threads:[~2019-03-22 15:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-22 15:14 [PATCH bpf-next v2 00/13] bpf tc tunneling Willem de Bruijn
2019-03-22 15:14 ` Willem de Bruijn [this message]
2019-03-22 15:14 ` [PATCH bpf-next v2 02/13] selftests/bpf: bpf tunnel encap test Willem de Bruijn
2019-03-22 15:14 ` [PATCH bpf-next v2 03/13] selftests/bpf: expand bpf tunnel test with decap Willem de Bruijn
2019-03-22 15:14 ` [PATCH bpf-next v2 04/13] selftests/bpf: expand bpf tunnel test to ipv6 Willem de Bruijn
2019-03-22 15:14 ` [PATCH bpf-next v2 05/13] selftests/bpf: extend bpf tunnel test with gre Willem de Bruijn
2019-03-22 15:14 ` [PATCH bpf-next v2 06/13] selftests/bpf: extend bpf tunnel test with tso Willem de Bruijn
2019-03-22 15:14 ` [PATCH bpf-next v2 07/13] bpf: add bpf_skb_adjust_room mode BPF_ADJ_ROOM_MAC Willem de Bruijn
2019-03-22 15:14 ` [PATCH bpf-next v2 08/13] bpf: add bpf_skb_adjust_room flag BPF_F_ADJ_ROOM_FIXED_GSO Willem de Bruijn
2019-03-22 15:15 ` [PATCH bpf-next v2 09/13] bpf: add bpf_skb_adjust_room encap flags Willem de Bruijn
2019-03-22 15:44   ` Alexei Starovoitov
2019-03-22 15:47     ` Willem de Bruijn
2019-03-22 16:11       ` Alexei Starovoitov
2019-03-22 16:31         ` Willem de Bruijn
2019-03-22 15:15 ` [PATCH bpf-next v2 10/13] bpf: Sync bpf.h to tools Willem de Bruijn
2019-03-22 15:15 ` [PATCH bpf-next v2 11/13] selftests/bpf: convert bpf tunnel test to BPF_ADJ_ROOM_MAC Willem de Bruijn
2019-03-22 15:15 ` [PATCH bpf-next v2 12/13] selftests/bpf: convert bpf tunnel test to BPF_F_ADJ_ROOM_FIXED_GSO Willem de Bruijn
2019-03-22 15:15 ` [PATCH bpf-next v2 13/13] selftests/bpf: convert bpf tunnel test to encap modes Willem de Bruijn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190322151504.89983-2-willemdebruijn.kernel@gmail.com \
    --to=willemdebruijn.kernel@gmail.com \
    --cc=alan.maguire@oracle.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=netdev@vger.kernel.org \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).