netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Song Liu <songliubraving@fb.com>
To: Andrii Nakryiko <andriin@fb.com>
Cc: bpf <bpf@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Alexei Starovoitov <ast@fb.com>,
	"daniel@iogearbox.net" <daniel@iogearbox.net>,
	"andrii.nakryiko@gmail.com" <andrii.nakryiko@gmail.com>,
	Kernel Team <Kernel-team@fb.com>
Subject: Re: [PATCH bpf-next 2/3] libbpf: make global data internal arrays mmap()-able, if possible
Date: Fri, 8 Nov 2019 06:44:06 +0000	[thread overview]
Message-ID: <A5F17C12-EBB2-4588-863E-69EDE650DE43@fb.com> (raw)
In-Reply-To: <20191108042041.1549144-3-andriin@fb.com>



> On Nov 7, 2019, at 8:20 PM, Andrii Nakryiko <andriin@fb.com> wrote:
> 
> Add detection of BPF_F_MMAPABLE flag support for arrays and add it as an extra
> flag to internal global data maps, if supported by kernel. This allows users
> to memory-map global data and use it without BPF map operations, greatly
> simplifying user experience.
> 
> Signed-off-by: Andrii Nakryiko <andriin@fb.com>

Acked-by: Song Liu <songliubraving@fb.com>

With nit below. 

> ---
> tools/lib/bpf/libbpf.c | 31 +++++++++++++++++++++++++++++--
> 1 file changed, 29 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index fde6cb3e5d41..73607a31a068 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -142,6 +142,8 @@ struct bpf_capabilities {
> 	__u32 btf_func:1;
> 	/* BTF_KIND_VAR and BTF_KIND_DATASEC support */
> 	__u32 btf_datasec:1;
> +	/* BPF_F_MMAPABLE is supported for arrays */
> +	__u32 array_mmap:1;
> };
> 
> /*
> @@ -855,8 +857,6 @@ bpf_object__init_internal_map(struct bpf_object *obj, enum libbpf_map_type type,
> 		pr_warn("failed to alloc map name\n");
> 		return -ENOMEM;
> 	}
> -	pr_debug("map '%s' (global data): at sec_idx %d, offset %zu.\n",
> -		 map_name, map->sec_idx, map->sec_offset);
> 
> 	def = &map->def;
> 	def->type = BPF_MAP_TYPE_ARRAY;
> @@ -864,6 +864,12 @@ bpf_object__init_internal_map(struct bpf_object *obj, enum libbpf_map_type type,
> 	def->value_size = data->d_size;
> 	def->max_entries = 1;
> 	def->map_flags = type == LIBBPF_MAP_RODATA ? BPF_F_RDONLY_PROG : 0;
> +	if (obj->caps.array_mmap)
> +		def->map_flags |= BPF_F_MMAPABLE;
> +
> +	pr_debug("map '%s' (global data): at sec_idx %d, offset %zu, flags %u.\n",

nit: Better print flags as %x. 



  reply	other threads:[~2019-11-08  6:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-08  4:20 [PATCH bpf-next 0/3] Add support for memory-mapping BPF array maps Andrii Nakryiko
2019-11-08  4:20 ` [PATCH bpf-next 1/3] bpf: add mmap() support for BPF_MAP_TYPE_ARRAY Andrii Nakryiko
2019-11-08  6:39   ` Song Liu
2019-11-08 19:34     ` Andrii Nakryiko
2019-11-11 16:39       ` Song Liu
2019-11-08  4:20 ` [PATCH bpf-next 2/3] libbpf: make global data internal arrays mmap()-able, if possible Andrii Nakryiko
2019-11-08  6:44   ` Song Liu [this message]
2019-11-08 19:34     ` Andrii Nakryiko
2019-11-08  4:20 ` [PATCH bpf-next 3/3] selftests/bpf: add BPF_TYPE_MAP_ARRAY mmap() tests Andrii Nakryiko
2019-11-08  6:49   ` Song Liu
2019-11-08 22:08 ` [PATCH bpf-next 0/3] Add support for memory-mapping BPF array maps Stanislav Fomichev
2019-11-08 23:19   ` 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=A5F17C12-EBB2-4588-863E-69EDE650DE43@fb.com \
    --to=songliubraving@fb.com \
    --cc=Kernel-team@fb.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andriin@fb.com \
    --cc=ast@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --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).