From: Jesper Dangaard Brouer <jbrouer@redhat.com>
To: "Björn Töpel" <bjorn.topel@gmail.com>
Cc: netdev@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
"Björn Töpel" <bjorn.topel@intel.com>,
bpf@vger.kernel.org, davem@davemloft.net,
jakub.kicinski@netronome.com, hawk@kernel.org,
john.fastabend@gmail.com, magnus.karlsson@intel.com,
jonathan.lemon@gmail.com
Subject: Re: [PATCH bpf-next 7/8] xdp: remove map_to_flush and map swap detection
Date: Wed, 18 Dec 2019 14:03:18 +0100 [thread overview]
Message-ID: <20191218140318.2c1d7140@carbon> (raw)
In-Reply-To: <20191218105400.2895-8-bjorn.topel@gmail.com>
On Wed, 18 Dec 2019 11:53:59 +0100
Björn Töpel <bjorn.topel@gmail.com> wrote:
> From: Björn Töpel <bjorn.topel@intel.com>
>
> Now that all XDP maps that can be used with bpf_redirect_map() tracks
> entries to be flushed in a global fashion, there is not need to track
> that the map has changed and flush from xdp_do_generic_map()
> anymore. All entries will be flushed in xdp_do_flush_map().
>
> This means that the map_to_flush can be removed, and the corresponding
> checks. Moving the flush logic to one place, xdp_do_flush_map(), give
> a bulking behavior and performance boost.
>
> Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
> ---
> include/linux/filter.h | 1 -
> net/core/filter.c | 27 +++------------------------
> 2 files changed, 3 insertions(+), 25 deletions(-)
>
> diff --git a/include/linux/filter.h b/include/linux/filter.h
> index 37ac7025031d..69d6706fc889 100644
> --- a/include/linux/filter.h
> +++ b/include/linux/filter.h
> @@ -592,7 +592,6 @@ struct bpf_redirect_info {
> u32 tgt_index;
> void *tgt_value;
> struct bpf_map *map;
> - struct bpf_map *map_to_flush;
> u32 kern_flags;
> };
>
> diff --git a/net/core/filter.c b/net/core/filter.c
> index c706325b3e66..d9caa3e57ea1 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -3547,26 +3547,9 @@ static int __bpf_tx_xdp_map(struct net_device *dev_rx, void *fwd,
>
> void xdp_do_flush_map(void)
> {
> - struct bpf_redirect_info *ri = this_cpu_ptr(&bpf_redirect_info);
> - struct bpf_map *map = ri->map_to_flush;
> -
> - ri->map_to_flush = NULL;
> - if (map) {
> - switch (map->map_type) {
> - case BPF_MAP_TYPE_DEVMAP:
> - case BPF_MAP_TYPE_DEVMAP_HASH:
> - __dev_map_flush();
> - break;
> - case BPF_MAP_TYPE_CPUMAP:
> - __cpu_map_flush();
> - break;
> - case BPF_MAP_TYPE_XSKMAP:
> - __xsk_map_flush();
> - break;
> - default:
> - break;
> - }
> - }
> + __dev_map_flush();
> + __cpu_map_flush();
> + __xsk_map_flush();
> }
> EXPORT_SYMBOL_GPL(xdp_do_flush_map);
>
> @@ -3615,14 +3598,10 @@ static int xdp_do_redirect_map(struct net_device *dev, struct xdp_buff *xdp,
> ri->tgt_value = NULL;
> WRITE_ONCE(ri->map, NULL);
>
> - if (ri->map_to_flush && unlikely(ri->map_to_flush != map))
> - xdp_do_flush_map();
> -
I guess, I need to read the other patches to understand why this is valid.
The idea here is to detect if the BPF-prog are using several different
redirect maps, and do the flush if the program uses another map. I
assume you handle this?
> err = __bpf_tx_xdp_map(dev, fwd, map, xdp);
> if (unlikely(err))
> goto err;
>
> - ri->map_to_flush = map;
> _trace_xdp_redirect_map(dev, xdp_prog, fwd, map, index);
> return 0;
> err:
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
next prev parent reply other threads:[~2019-12-18 13:03 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-18 10:53 [PATCH bpf-next 0/8] Simplify xdp_do_redirect_map()/xdp_do_flush_map() and XDP maps Björn Töpel
2019-12-18 10:53 ` [PATCH bpf-next 1/8] xdp: simplify devmap cleanup Björn Töpel
2019-12-18 11:14 ` Toke Høiland-Jørgensen
2019-12-18 10:53 ` [PATCH bpf-next 2/8] xdp: simplify cpumap cleanup Björn Töpel
2019-12-18 11:15 ` Toke Høiland-Jørgensen
2019-12-18 17:47 ` Jakub Kicinski
2019-12-18 17:48 ` Björn Töpel
2019-12-18 10:53 ` [PATCH bpf-next 3/8] xdp: fix graze->grace type-o in cpumap comments Björn Töpel
2019-12-18 11:18 ` Toke Høiland-Jørgensen
2019-12-18 10:53 ` [PATCH bpf-next 4/8] xsk: make xskmap flush_list common for all map instances Björn Töpel
2019-12-18 11:19 ` Toke Høiland-Jørgensen
2019-12-18 10:53 ` [PATCH bpf-next 5/8] xdp: make devmap " Björn Töpel
2019-12-18 11:19 ` Toke Høiland-Jørgensen
2019-12-18 10:53 ` [PATCH bpf-next 6/8] xdp: make cpumap " Björn Töpel
2019-12-18 11:19 ` Toke Høiland-Jørgensen
2019-12-18 10:53 ` [PATCH bpf-next 7/8] xdp: remove map_to_flush and map swap detection Björn Töpel
2019-12-18 11:20 ` Toke Høiland-Jørgensen
2019-12-18 13:03 ` Jesper Dangaard Brouer [this message]
2019-12-18 13:09 ` Björn Töpel
2019-12-18 10:54 ` [PATCH bpf-next 8/8] xdp: simplify __bpf_tx_xdp_map() Björn Töpel
2019-12-18 11:20 ` Toke Høiland-Jørgensen
2019-12-18 11:11 ` [PATCH bpf-next 0/8] Simplify xdp_do_redirect_map()/xdp_do_flush_map() and XDP maps Jesper Dangaard Brouer
2019-12-18 11:39 ` Björn Töpel
2019-12-18 12:03 ` Jesper Dangaard Brouer
2019-12-18 12:18 ` Björn Töpel
2019-12-18 12:32 ` Björn Töpel
2019-12-18 12:40 ` Jesper Dangaard Brouer
2019-12-18 12:48 ` Björn Töpel
2019-12-19 0:39 ` Andrii Nakryiko
2019-12-19 19:33 ` Jesper Dangaard Brouer
2019-12-19 20:08 ` Daniel Borkmann
2019-12-19 22:56 ` Andrii Nakryiko
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=20191218140318.2c1d7140@carbon \
--to=jbrouer@redhat.com \
--cc=ast@kernel.org \
--cc=bjorn.topel@gmail.com \
--cc=bjorn.topel@intel.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=hawk@kernel.org \
--cc=jakub.kicinski@netronome.com \
--cc=john.fastabend@gmail.com \
--cc=jonathan.lemon@gmail.com \
--cc=magnus.karlsson@intel.com \
--cc=netdev@vger.kernel.org \
/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).