netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Jakub Kicinski <jakub.kicinski@netronome.com>
Cc: daniel@iogearbox.net, dsahern@gmail.com, netdev@vger.kernel.org,
	oss-drivers@netronome.com, david.beckett@netronome.com
Subject: Re: [RFC] bpf: remove global verifier state
Date: Tue, 3 Oct 2017 19:52:29 -0700	[thread overview]
Message-ID: <20171004025226.wutfwm6hcsj4zuph@ast-mbp> (raw)
In-Reply-To: <20171004002025.28521-1-jakub.kicinski@netronome.com>

On Tue, Oct 03, 2017 at 05:20:25PM -0700, Jakub Kicinski wrote:
> The only global state protected by the verifier lock is
> the verifier log.  Move that log to struct bpf_verifier_env
> and allow verification of multiple programs in parallel.
> 
> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> ---
> Like this? :)
> 
> Compile-tested, I'm rebasing things and will test shortly.
> 
>  include/linux/bpf_verifier.h |   5 +
>  kernel/bpf/verifier.c        | 520 ++++++++++++++++++++++---------------------
>  2 files changed, 276 insertions(+), 249 deletions(-)
> 
> diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h
> index b8d200f60a40..598802dd1897 100644
> --- a/include/linux/bpf_verifier.h
> +++ b/include/linux/bpf_verifier.h
> @@ -139,6 +139,11 @@ struct bpf_verifier_env {
>  	bool allow_ptr_leaks;
>  	bool seen_direct_write;
>  	struct bpf_insn_aux_data *insn_aux_data; /* array of per-insn state */
> +
> +	u32 log_level;
> +	u32 log_size;
> +	u32 log_len;
> +	char *log_buf;
>  };
>  
>  int bpf_analyzer(struct bpf_prog *prog, const struct bpf_ext_analyzer_ops *ops,
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 4cf9b72c59a0..450f60e6229d 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -153,27 +153,21 @@ struct bpf_call_arg_meta {
>  	int access_size;
>  };
>  
> -/* verbose verifier prints what it's seeing
> - * bpf_check() is called under lock, so no race to access these global vars
> - */
> -static u32 log_level, log_size, log_len;
> -static char *log_buf;
> -
> -static DEFINE_MUTEX(bpf_verifier_lock);

yep. looks great.
Please test it and submit officially :)
The commit aafe6ae9cee3 ("bpf: dynamically allocate digest scratch buffer")
fixed the other case where we were relying on the above mutex.
The only other spot to be adjusted is to add spin_lock/mutex or DO_ONCE() to
bpf_get_skb_set_tunnel_proto() to protect md_dst init.
imo that would be it.
Daniel, anything else comes to mind?

  reply	other threads:[~2017-10-04  2:52 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-02 23:11 [PATCH net-next v2 0/3] tools: add bpftool Jakub Kicinski
2017-10-02 23:11 ` [PATCH net-next v2 1/3] tools: rename tools/net directory to tools/bpf Jakub Kicinski
2017-10-02 23:11 ` [PATCH net-next v2 2/3] tools: bpf: add bpftool Jakub Kicinski
2017-10-02 23:11 ` [PATCH net-next v2 3/3] tools: bpftool: add documentation Jakub Kicinski
2017-10-03  0:55   ` Alexei Starovoitov
2017-10-03  1:35     ` Jakub Kicinski
2017-10-03  4:29       ` Alexei Starovoitov
2017-10-03 15:39         ` David Ahern
2017-10-03 16:01           ` Daniel Borkmann
2017-10-03 16:09             ` David Ahern
2017-10-03 17:57             ` [RFC 1/2] bpf: move instruction printing into a separate file Jakub Kicinski
2017-10-03 17:57               ` [RFC 2/2] tools: bpftool: use the kernel's instruction printer Jakub Kicinski
2017-10-03 19:32               ` [RFC 1/2] bpf: move instruction printing into a separate file Daniel Borkmann
2017-10-03 20:14               ` Alexei Starovoitov
2017-10-04  0:20                 ` [RFC] bpf: remove global verifier state Jakub Kicinski
2017-10-04  2:52                   ` Alexei Starovoitov [this message]
2017-10-04  3:24                     ` Eric Dumazet
2017-10-04  3:43                       ` Alexei Starovoitov
2017-10-04 19:13                         ` Daniel Borkmann
2017-10-04 21:57                           ` Jakub Kicinski
2017-10-04 22:40                             ` Alexei Starovoitov
2017-10-03 14:15       ` [PATCH net-next v2 3/3] tools: bpftool: add documentation Daniel Borkmann
2017-10-03 20:19 ` [PATCH net-next v2 0/3] tools: add bpftool Arnaldo Carvalho de Melo
2017-10-04  0:48   ` Jakub Kicinski
2017-10-04 11:40     ` Arnaldo Carvalho de Melo
2017-10-04  4:33 ` David Miller

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=20171004025226.wutfwm6hcsj4zuph@ast-mbp \
    --to=alexei.starovoitov@gmail.com \
    --cc=daniel@iogearbox.net \
    --cc=david.beckett@netronome.com \
    --cc=dsahern@gmail.com \
    --cc=jakub.kicinski@netronome.com \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@netronome.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).