From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: Andrii Nakryiko <andriin@fb.com>
Cc: <bpf@vger.kernel.org>, <netdev@vger.kernel.org>, <ast@fb.com>,
<daniel@iogearbox.net>, <andrii.nakryiko@gmail.com>,
<kernel-team@fb.com>, Rik van Riel <riel@surriel.com>,
Johannes Weiner <hannes@cmpxchg.org>
Subject: Re: [PATCH v2 bpf-next 1/3] bpf: add mmap() support for BPF_MAP_TYPE_ARRAY
Date: Mon, 11 Nov 2019 10:37:43 -0800 [thread overview]
Message-ID: <20191111103743.1c3a38a3@cakuba> (raw)
In-Reply-To: <20191109080633.2855561-2-andriin@fb.com>
On Sat, 9 Nov 2019 00:06:30 -0800, Andrii Nakryiko wrote:
> With BPF_F_MMAPABLE array allocating data in separate chunk of memory,
> array_map_gen_lookup has to accomodate these changes. For non-memory-mapped
> there are no changes and no extra instructions. For BPF_F_MMAPABLE case,
> pointer to where array data is stored has to be dereferenced first.
>
> Generated code for non-memory-mapped array:
>
> ; p = bpf_map_lookup_elem(&data_map, &zero);
> 22: (18) r1 = map[id:19]
> 24: (07) r1 += 408 /* array->inline_data offset */
> 25: (61) r0 = *(u32 *)(r2 +0)
> 26: (35) if r0 >= 0x3 goto pc+3
> 27: (67) r0 <<= 3
> 28: (0f) r0 += r1
> 29: (05) goto pc+1
> 30: (b7) r0 = 0
>
> Generated code for memory-mapped array:
>
> ; p = bpf_map_lookup_elem(&data_map, &zero);
> 22: (18) r1 = map[id:27]
> 24: (07) r1 += 400 /* array->data offset */
> 25: (79) r1 = *(u64 *)(r1 +0) /* extra dereference */
> 26: (61) r0 = *(u32 *)(r2 +0)
> 27: (35) if r0 >= 0x3 goto pc+3
> 28: (67) r0 <<= 3
> 29: (0f) r0 += r1
> 30: (05) goto pc+1
> 31: (b7) r0 = 0
Would it not be possible to overallocate the memory and align the start
of the bpf_map in case of BPF_F_MMAPABLE so that no extra dereference
is needed?
next prev parent reply other threads:[~2019-11-11 19:07 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-09 8:06 [PATCH v2 bpf-next 0/3] Add support for memory-mapping BPF array maps Andrii Nakryiko
2019-11-09 8:06 ` [PATCH v2 bpf-next 1/3] bpf: add mmap() support for BPF_MAP_TYPE_ARRAY Andrii Nakryiko
2019-11-11 16:40 ` Song Liu
2019-11-11 18:37 ` Jakub Kicinski [this message]
2019-11-12 2:06 ` Andrii Nakryiko
2019-11-12 19:17 ` Jakub Kicinski
2019-11-12 22:03 ` Andrii Nakryiko
2019-11-12 22:38 ` Jakub Kicinski
2019-11-13 3:19 ` Andrii Nakryiko
2019-11-11 18:39 ` Jakub Kicinski
2019-11-12 2:01 ` Andrii Nakryiko
2019-11-09 8:06 ` [PATCH v2 bpf-next 2/3] libbpf: make global data internal arrays mmap()-able, if possible Andrii Nakryiko
2019-11-11 18:40 ` Jakub Kicinski
2019-11-12 2:11 ` Andrii Nakryiko
2019-11-09 8:06 ` [PATCH v2 bpf-next 3/3] selftests/bpf: add BPF_TYPE_MAP_ARRAY mmap() tests 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=20191111103743.1c3a38a3@cakuba \
--to=jakub.kicinski@netronome.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andriin@fb.com \
--cc=ast@fb.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=hannes@cmpxchg.org \
--cc=kernel-team@fb.com \
--cc=netdev@vger.kernel.org \
--cc=riel@surriel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.