From: "Christian König" <christian.koenig@amd.com>
To: "T.J. Mercier" <tjmercier@google.com>,
sumit.semwal@linaro.org, ast@kernel.org, daniel@iogearbox.net,
andrii@kernel.org, martin.lau@linux.dev,
skhan@linuxfoundation.org, alexei.starovoitov@gmail.com
Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org,
bpf@vger.kernel.org, linux-kselftest@vger.kernel.org,
android-mm@google.com, simona@ffwll.ch, eddyz87@gmail.com,
yonghong.song@linux.dev, john.fastabend@gmail.com,
kpsingh@kernel.org, sdf@fomichev.me, jolsa@kernel.org,
mykolal@fb.com, shuah@kernel.org, song@kernel.org
Subject: Re: [PATCH bpf-next v4 0/5] Replace CONFIG_DMABUF_SYSFS_STATS with BPF
Date: Fri, 9 May 2025 08:03:50 +0200 [thread overview]
Message-ID: <b1e53d0b-04ba-4ad7-abdf-2406283a9cfb@amd.com> (raw)
In-Reply-To: <20250508182025.2961555-1-tjmercier@google.com>
Feel free to add my Acked-by to the patches which don't have my rb yet.
And ping me when I should upstream this through drm-misc-next, but if you want to upstream this through some other branch then that is fine with me as well.
Regards,
Christian.
On 5/8/25 20:20, T.J. Mercier wrote:
> Until CONFIG_DMABUF_SYSFS_STATS was added [1] it was only possible to
> perform per-buffer accounting with debugfs which is not suitable for
> production environments. Eventually we discovered the overhead with
> per-buffer sysfs file creation/removal was significantly impacting
> allocation and free times, and exacerbated kernfs lock contention. [2]
> dma_buf_stats_setup() is responsible for 39% of single-page buffer
> creation duration, or 74% of single-page dma_buf_export() duration when
> stressing dmabuf allocations and frees.
>
> I prototyped a change from per-buffer to per-exporter statistics with a
> RCU protected list of exporter allocations that accommodates most (but
> not all) of our use-cases and avoids almost all of the sysfs overhead.
> While that adds less overhead than per-buffer sysfs, and less even than
> the maintenance of the dmabuf debugfs_list, it's still *additional*
> overhead on top of the debugfs_list and doesn't give us per-buffer info.
>
> This series uses the existing dmabuf debugfs_list to implement a BPF
> dmabuf iterator, which adds no overhead to buffer allocation/free and
> provides per-buffer info. The list has been moved outside of
> CONFIG_DEBUG_FS scope so that it is always populated. The BPF program
> loaded by userspace that extracts per-buffer information gets to define
> its own interface which avoids the lack of ABI stability with debugfs.
>
> This will allow us to replace our use of CONFIG_DMABUF_SYSFS_STATS, and
> the plan is to remove it from the kernel after the next longterm stable
> release.
>
> [1] https://lore.kernel.org/linux-media/20201210044400.1080308-1-hridya@google.com
> [2] https://lore.kernel.org/all/20220516171315.2400578-1-tjmercier@google.com
>
> v1: https://lore.kernel.org/all/20250414225227.3642618-1-tjmercier@google.com
> v1 -> v2:
> Make the DMA buffer list independent of CONFIG_DEBUG_FS per Christian König
> Add CONFIG_DMA_SHARED_BUFFER check to kernel/bpf/Makefile per kernel test robot
> Use BTF_ID_LIST_SINGLE instead of BTF_ID_LIST_GLOBAL_SINGLE per Song Liu
> Fixup comment style, mixing code/declarations, and use ASSERT_OK_FD in selftest per Song Liu
> Add BPF_ITER_RESCHED feature to bpf_dmabuf_reg_info per Alexei Starovoitov
> Add open-coded iterator and selftest per Alexei Starovoitov
> Add a second test buffer from the system dmabuf heap to selftests
> Use the BPF program we'll use in production for selftest per Alexei Starovoitov
> https://r.android.com/c/platform/system/bpfprogs/+/3616123/2/dmabufIter.c
> https://r.android.com/c/platform/system/memory/libmeminfo/+/3614259/1/libdmabufinfo/dmabuf_bpf_stats.cpp
> v2: https://lore.kernel.org/all/20250504224149.1033867-1-tjmercier@google.com
> v2 -> v3:
> Rebase onto bpf-next/master
> Move get_next_dmabuf() into drivers/dma-buf/dma-buf.c, along with the
> new get_first_dmabuf(). This avoids having to expose the dmabuf list
> and mutex to the rest of the kernel, and keeps the dmabuf mutex
> operations near each other in the same file. (Christian König)
> Add Christian's RB to dma-buf: Rename debugfs symbols
> Drop RFC: dma-buf: Remove DMA-BUF statistics
> v3: https://lore.kernel.org/all/20250507001036.2278781-1-tjmercier@google.com
> v3 -> v4:
> Fix selftest BPF program comment style (not kdoc) per Alexei Starovoitov
> Fix dma-buf.c kdoc comment style per Alexei Starovoitov
> Rename get_first_dmabuf / get_next_dmabuf to dma_buf_iter_begin /
> dma_buf_iter_next per Christian König
> Add Christian's RB to bpf: Add dmabuf iterator
>
> T.J. Mercier (5):
> dma-buf: Rename debugfs symbols
> bpf: Add dmabuf iterator
> bpf: Add open coded dmabuf iterator
> selftests/bpf: Add test for dmabuf_iter
> selftests/bpf: Add test for open coded dmabuf_iter
>
> drivers/dma-buf/dma-buf.c | 98 +++++--
> include/linux/dma-buf.h | 4 +-
> kernel/bpf/Makefile | 3 +
> kernel/bpf/dmabuf_iter.c | 149 ++++++++++
> kernel/bpf/helpers.c | 5 +
> .../testing/selftests/bpf/bpf_experimental.h | 5 +
> tools/testing/selftests/bpf/config | 3 +
> .../selftests/bpf/prog_tests/dmabuf_iter.c | 258 ++++++++++++++++++
> .../testing/selftests/bpf/progs/dmabuf_iter.c | 91 ++++++
> 9 files changed, 594 insertions(+), 22 deletions(-)
> create mode 100644 kernel/bpf/dmabuf_iter.c
> create mode 100644 tools/testing/selftests/bpf/prog_tests/dmabuf_iter.c
> create mode 100644 tools/testing/selftests/bpf/progs/dmabuf_iter.c
>
>
> base-commit: 43745d11bfd9683abdf08ad7a5cc403d6a9ffd15
next prev parent reply other threads:[~2025-05-09 6:04 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-08 18:20 T.J. Mercier
2025-05-08 18:20 ` [PATCH bpf-next v4 1/5] dma-buf: Rename debugfs symbols T.J. Mercier
2025-05-08 18:32 ` Song Liu
2025-05-08 18:20 ` [PATCH bpf-next v4 2/5] bpf: Add dmabuf iterator T.J. Mercier
2025-05-09 0:27 ` Song Liu
2025-05-09 17:13 ` T.J. Mercier
2025-05-08 18:20 ` [PATCH bpf-next v4 3/5] bpf: Add open coded " T.J. Mercier
2025-05-09 0:28 ` Song Liu
2025-05-09 17:13 ` T.J. Mercier
2025-05-08 18:20 ` [PATCH bpf-next v4 4/5] selftests/bpf: Add test for dmabuf_iter T.J. Mercier
2025-05-09 0:36 ` Song Liu
2025-05-09 17:13 ` T.J. Mercier
2025-05-09 18:50 ` Song Liu
2025-05-08 18:20 ` [PATCH bpf-next v4 5/5] selftests/bpf: Add test for open coded dmabuf_iter T.J. Mercier
2025-05-09 18:46 ` Song Liu
2025-05-09 21:43 ` T.J. Mercier
2025-05-09 21:58 ` Song Liu
2025-05-09 22:27 ` T.J. Mercier
2025-05-09 6:03 ` Christian König [this message]
2025-05-09 15:21 ` [PATCH bpf-next v4 0/5] Replace CONFIG_DMABUF_SYSFS_STATS with BPF T.J. Mercier
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=b1e53d0b-04ba-4ad7-abdf-2406283a9cfb@amd.com \
--to=christian.koenig@amd.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=android-mm@google.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=dri-devel@lists.freedesktop.org \
--cc=eddyz87@gmail.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=mykolal@fb.com \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=simona@ffwll.ch \
--cc=skhan@linuxfoundation.org \
--cc=song@kernel.org \
--cc=sumit.semwal@linaro.org \
--cc=tjmercier@google.com \
--cc=yonghong.song@linux.dev \
/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
all inboxes | Powered by JetHome®