From: Stanislav Fomichev <sdf@google.com>
To: Dave Marchevsky <davemarchevsky@fb.com>
Cc: bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@kernel.org>,
Kernel Team <kernel-team@fb.com>,
Nathan Slingerland <slinger@meta.com>
Subject: Re: [PATCH bpf-next 2/3] bpf: Introduce task_vma open-coded iterator kfuncs
Date: Thu, 10 Aug 2023 14:57:19 -0700 [thread overview]
Message-ID: <ZNVdP0mA9REeLQJj@google.com> (raw)
In-Reply-To: <20230810183513.684836-3-davemarchevsky@fb.com>
On 08/10, Dave Marchevsky wrote:
> This patch adds kfuncs bpf_iter_task_vma_{new,next,destroy} which allow
> creation and manipulation of struct bpf_iter_task_vma in open-coded
> iterator style. BPF programs can use these kfuncs directly or through
> bpf_for_each macro for natural-looking iteration of all task vmas.
>
> The implementation borrows heavily from bpf_find_vma helper's locking -
> differing only in that it holds the mmap_read lock for all iterations
> while the helper only executes its provided callback on a maximum of 1
> vma. Aside from locking, struct vma_iterator and vma_next do all the
> heavy lifting.
>
> The newly-added struct bpf_iter_task_vma has a name collision with a
> selftest for the seq_file task_vma iter's bpf skel, so the selftests/bpf/progs
> file is renamed in order to avoid the collision.
>
> Signed-off-by: Dave Marchevsky <davemarchevsky@fb.com>
> Cc: Nathan Slingerland <slinger@meta.com>
> ---
> include/uapi/linux/bpf.h | 5 ++
> kernel/bpf/helpers.c | 3 +
> kernel/bpf/task_iter.c | 56 +++++++++++++++++++
> tools/include/uapi/linux/bpf.h | 5 ++
> tools/lib/bpf/bpf_helpers.h | 8 +++
> .../selftests/bpf/prog_tests/bpf_iter.c | 26 ++++-----
> ...f_iter_task_vma.c => bpf_iter_task_vmas.c} | 0
> 7 files changed, 90 insertions(+), 13 deletions(-)
> rename tools/testing/selftests/bpf/progs/{bpf_iter_task_vma.c => bpf_iter_task_vmas.c} (100%)
>
> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
> index d21deb46f49f..c4a65968f9f5 100644
> --- a/include/uapi/linux/bpf.h
> +++ b/include/uapi/linux/bpf.h
> @@ -7291,4 +7291,9 @@ struct bpf_iter_num {
> __u64 __opaque[1];
> } __attribute__((aligned(8)));
>
> +struct bpf_iter_task_vma {
[..]
> + __u64 __opaque[9]; /* See bpf_iter_num comment above */
> + char __opaque_c[3];
Everything in the series makes sense, but this part is a big confusing
when reading without too much context. If you're gonna do a respin, maybe:
- __opaque_c[8*9+3] (or whatever the size is)? any reason for separate
__u64 + char?
- maybe worth adding something like /* Opaque representation of
bpf_iter_task_vma_kern; see bpf_iter_num comment above */.
that bpf_iter_task_vma<>bpf_iter_task_vma_kern wasn't super apparent
until I got to the BUG_ON part
next prev parent reply other threads:[~2023-08-10 21:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-10 18:35 [PATCH bpf-next 0/3] Open-coded task_vma iter Dave Marchevsky
2023-08-10 18:35 ` [PATCH bpf-next 1/3] bpf: Explicitly emit BTF for struct bpf_iter_num, not btf_iter_num Dave Marchevsky
2023-08-11 7:19 ` Yonghong Song
2023-08-10 18:35 ` [PATCH bpf-next 2/3] bpf: Introduce task_vma open-coded iterator kfuncs Dave Marchevsky
2023-08-10 21:57 ` Stanislav Fomichev [this message]
2023-08-11 14:57 ` David Marchevsky
2023-08-11 17:03 ` Stanislav Fomichev
2023-08-11 16:22 ` Yonghong Song
2023-08-11 16:41 ` Yonghong Song
2023-08-10 18:35 ` [PATCH bpf-next 3/3] selftests/bpf: Add tests for open-coded task_vma iter Dave Marchevsky
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=ZNVdP0mA9REeLQJj@google.com \
--to=sdf@google.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davemarchevsky@fb.com \
--cc=kernel-team@fb.com \
--cc=martin.lau@kernel.org \
--cc=slinger@meta.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