Re: [PATCH bpf-next v4 3/5] bpf: Add open coded dmabuf iterator
From: Song Liu
Date: Thu May 08 2025 - 20:29:03 EST
On Thu, May 8, 2025 at 11:20 AM T.J. Mercier <tjmercier@xxxxxxxxxx> wrote:
>
> This open coded iterator allows for more flexibility when creating BPF
> programs. It can support output in formats other than text. With an open
> coded iterator, a single BPF program can traverse multiple kernel data
> structures (now including dmabufs), allowing for more efficient analysis
> of kernel data compared to multiple reads from procfs, sysfs, or
> multiple traditional BPF iterator invocations.
>
> Signed-off-by: T.J. Mercier <tjmercier@xxxxxxxxxx>
Acked-by: Song Liu <song@xxxxxxxxxx>
With one nitpick below:
> ---
> kernel/bpf/dmabuf_iter.c | 47 ++++++++++++++++++++++++++++++++++++++++
> kernel/bpf/helpers.c | 5 +++++
> 2 files changed, 52 insertions(+)
>
> diff --git a/kernel/bpf/dmabuf_iter.c b/kernel/bpf/dmabuf_iter.c
> index 96b4ba7f0b2c..8049bdbc9efc 100644
> --- a/kernel/bpf/dmabuf_iter.c
> +++ b/kernel/bpf/dmabuf_iter.c
> @@ -100,3 +100,50 @@ static int __init dmabuf_iter_init(void)
> }
>
> late_initcall(dmabuf_iter_init);
> +
> +struct bpf_iter_dmabuf {
> + /* opaque iterator state; having __u64 here allows to preserve correct
> + * alignment requirements in vmlinux.h, generated from BTF
> + */
nit: comment style.
> + __u64 __opaque[1];
> +} __aligned(8);
> +
> +/* Non-opaque version of bpf_iter_dmabuf */
> +struct bpf_iter_dmabuf_kern {
> + struct dma_buf *dmabuf;
> +} __aligned(8);
> +
[...]