netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Fastabend <john.fastabend@gmail.com>
To: "Björn Töpel" <bjorn.topel@gmail.com>,
	netdev@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net
Cc: "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,
	"Toke Høiland-Jørgensen" <toke@redhat.com>
Subject: RE: [PATCH bpf-next v2 1/8] xdp: simplify devmap cleanup
Date: Tue, 07 Jan 2020 09:32:33 -0800	[thread overview]
Message-ID: <5e14c0b1740ca_67962afd051fc5c0a5@john-XPS-13-9370.notmuch> (raw)
In-Reply-To: <20191219061006.21980-2-bjorn.topel@gmail.com>

Björn Töpel wrote:
> From: Björn Töpel <bjorn.topel@intel.com>
> 
> After the RCU flavor consolidation [1], call_rcu() and
> synchronize_rcu() waits for preempt-disable regions (NAPI) in addition
> to the read-side critical sections. As a result of this, the cleanup
> code in devmap can be simplified

OK great makes sense. One comment below.

> 
> * There is no longer a need to flush in __dev_map_entry_free, since we
>   know that this has been done when the call_rcu() callback is
>   triggered.
> 
> * When freeing the map, there is no need to explicitly wait for a
>   flush. It's guaranteed to be done after the synchronize_rcu() call
>   in dev_map_free(). The rcu_barrier() is still needed, so that the
>   map is not freed prior the elements.
> 
> [1] https://lwn.net/Articles/777036/
> 
> Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
> Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
> ---
>  kernel/bpf/devmap.c | 43 +++++--------------------------------------
>  1 file changed, 5 insertions(+), 38 deletions(-)
> 
> diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
> index 3d3d61b5985b..b7595de6a91a 100644
> --- a/kernel/bpf/devmap.c
> +++ b/kernel/bpf/devmap.c
> @@ -201,7 +201,7 @@ static struct bpf_map *dev_map_alloc(union bpf_attr *attr)
>  static void dev_map_free(struct bpf_map *map)
>  {
>  	struct bpf_dtab *dtab = container_of(map, struct bpf_dtab, map);
> -	int i, cpu;
> +	int i;
>  
>  	/* At this point bpf_prog->aux->refcnt == 0 and this map->refcnt == 0,
>  	 * so the programs (can be more than one that used this map) were
> @@ -221,18 +221,6 @@ static void dev_map_free(struct bpf_map *map)
>  	/* Make sure prior __dev_map_entry_free() have completed. */
>  	rcu_barrier();
>  

The comment at the start of this function also needs to be fixed it says,

  /* At this point bpf_prog->aux->refcnt == 0 and this map->refcnt == 0,
   * so the programs (can be more than one that used this map) were
   * disconnected from events. Wait for outstanding critical sections in
   * these programs to complete. The rcu critical section only guarantees
   * no further reads against netdev_map. It does __not__ ensure pending
   * flush operations (if any) are complete.
   */

also comment in dev_map_delete_elem() needs update.

> -	/* To ensure all pending flush operations have completed wait for flush
> -	 * list to empty on _all_ cpus.
> -	 * Because the above synchronize_rcu() ensures the map is disconnected
> -	 * from the program we can assume no new items will be added.
> -	 */
> -	for_each_online_cpu(cpu) {
> -		struct list_head *flush_list = per_cpu_ptr(dtab->flush_list, cpu);
> -
> -		while (!list_empty(flush_list))
> -			cond_resched();
> -	}
> -
>  	if (dtab->map.map_type == BPF_MAP_TYPE_DEVMAP_HASH) {
>  		for (i = 0; i < dtab->n_buckets; i++) {
>  			struct bpf_dtab_netdev *dev;
> @@ -345,8 +333,7 @@ static int dev_map_hash_get_next_key(struct bpf_map *map, void *key,
>  	return -ENOENT;
>  }

Otherwise LGTM thanks.

  reply	other threads:[~2020-01-07 17:32 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-19  6:09 [PATCH bpf-next v2 0/8] Simplify xdp_do_redirect_map()/xdp_do_flush_map() and XDP maps Björn Töpel
2019-12-19  6:09 ` [PATCH bpf-next v2 1/8] xdp: simplify devmap cleanup Björn Töpel
2020-01-07 17:32   ` John Fastabend [this message]
2020-01-08 10:08     ` Björn Töpel
2019-12-19  6:10 ` [PATCH bpf-next v2 2/8] xdp: simplify cpumap cleanup Björn Töpel
2019-12-19  6:10 ` [PATCH bpf-next v2 3/8] xdp: fix graze->grace type-o in cpumap comments Björn Töpel
2020-01-07 17:33   ` John Fastabend
2019-12-19  6:10 ` [PATCH bpf-next v2 4/8] xsk: make xskmap flush_list common for all map instances Björn Töpel
2020-01-07 17:54   ` John Fastabend
2020-01-08 10:13     ` Björn Töpel
2020-01-08 15:52       ` John Fastabend
2020-01-08 16:01         ` Toke Høiland-Jørgensen
2019-12-19  6:10 ` [PATCH bpf-next v2 5/8] xdp: make devmap " Björn Töpel
2020-01-07 17:58   ` John Fastabend
2020-01-08 10:16     ` Björn Töpel
2020-01-08 10:23       ` Toke Høiland-Jørgensen
2020-01-08 10:25         ` Björn Töpel
2019-12-19  6:10 ` [PATCH bpf-next v2 6/8] xdp: make cpumap " Björn Töpel
2020-01-07 17:59   ` John Fastabend
2019-12-19  6:10 ` [PATCH bpf-next v2 7/8] xdp: remove map_to_flush and map swap detection Björn Töpel
2020-01-07 18:15   ` John Fastabend
2020-01-07 21:07     ` Toke Høiland-Jørgensen
2020-01-08  3:45       ` John Fastabend
2020-01-08 10:24         ` Björn Töpel
2019-12-19  6:10 ` [PATCH bpf-next v2 8/8] xdp: simplify __bpf_tx_xdp_map() Björn Töpel
2019-12-19  7:18 ` [PATCH bpf-next v2 0/8] Simplify xdp_do_redirect_map()/xdp_do_flush_map() and XDP maps Jesper Dangaard Brouer
2019-12-20  5:21 ` Alexei Starovoitov
2019-12-20  7:46   ` Jesper Dangaard Brouer
2019-12-20  9:26     ` Jesper Dangaard Brouer
2019-12-20 10:29       ` Toke Høiland-Jørgensen
2020-01-07 11:10         ` Björn Töpel
2020-01-07 11:25           ` Toke Høiland-Jørgensen
2020-01-07 13:05             ` Jesper Dangaard Brouer
2020-01-07 13:27               ` Toke Høiland-Jørgensen
2020-01-07 13:52                 ` Jesper Dangaard Brouer
2020-01-07 14:18                   ` Toke Høiland-Jørgensen

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=5e14c0b1740ca_67962afd051fc5c0a5@john-XPS-13-9370.notmuch \
    --to=john.fastabend@gmail.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=jonathan.lemon@gmail.com \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=toke@redhat.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).