mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH bpf-next] selftests/bpf: Accept unnamed dma-bufs in the dmabuf_iter default test
@ 2026-10-09  1:49 Qiliang Yuan
  2026-10-09 15:07 ` T.J. Mercier
  0 siblings, 1 reply; 3+ messages in thread
From: Qiliang Yuan @ 2026-10-09  1:49 UTC (permalink / raw)
  To: Andrii Nakryiko, Eduard Zingerman, Ihor Solodrai,
	Alexei Starovoitov, Daniel Borkmann, Kumar Kartikeya Dwivedi,
	Martin KaFai Lau, Song Liu, Yonghong Song, Jiri Olsa,
	Emil Tsalapatis, Shuah Khan, Christian König, T.J. Mercier
  Cc: bpf, linux-kselftest, linux-kernel, Qiliang Yuan

The dmabuf_collector iterator prints the inode, size, name and exporter
of every dma-buf in the system on separate lines, with an empty name for
the buffers that have none. The default_iter subtest parses that output
and looks for the two buffers it created.

It requires a name for every buffer, and sscanf() finds none on the
empty line of an unnamed one. On a system that has such a buffer, like
one exported by udmabuf without a name, the subtest fails before it gets
to its own buffers.

Take an empty name for a buffer without one.

Fixes: ae5d2c59ecd7 ("selftests/bpf: Add test for dmabuf_iter")
Signed-off-by: Qiliang Yuan <odys.yuan@gmail.com>
---
 tools/testing/selftests/bpf/prog_tests/dmabuf_iter.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/dmabuf_iter.c b/tools/testing/selftests/bpf/prog_tests/dmabuf_iter.c
index fb2cea710db3e..1a5dc1adae735 100644
--- a/tools/testing/selftests/bpf/prog_tests/dmabuf_iter.c
+++ b/tools/testing/selftests/bpf/prog_tests/dmabuf_iter.c
@@ -188,8 +188,9 @@ static void subtest_dmabuf_iter_check_default_iter(struct dmabuf_iter *skel)
 			ASSERT_EQ(sscanf(line, "%ld", &bufinfo.size), 1,
 				  "read size");
 		} else if (f % FIELD_COUNT == NAME) {
-			ASSERT_EQ(sscanf(line, "%s", bufinfo.name), 1,
-				  "read name");
+			/* Keep an empty name for a buffer without one */
+			if (sscanf(line, "%s", bufinfo.name) != 1)
+				bufinfo.name[0] = '\0';
 		} else if (f % FIELD_COUNT == EXPORTER) {
 			ASSERT_EQ(sscanf(line, "%31s", bufinfo.exporter), 1,
 				  "read exporter");

---
base-commit: e1d84a37cba984388988d2f1ddc84561413f0db2
change-id: 20261009-selftests-bpf-dmabuf-iter-unnamed-217561e20d84

Best regards,
-- 
Qiliang Yuan <odys.yuan@gmail.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf-next] selftests/bpf: Accept unnamed dma-bufs in the dmabuf_iter default test
  2026-10-09  1:49 [PATCH bpf-next] selftests/bpf: Accept unnamed dma-bufs in the dmabuf_iter default test Qiliang Yuan
@ 2026-10-09 15:07 ` T.J. Mercier
  2026-10-10  2:52   ` Qiliang Yuan
  0 siblings, 1 reply; 3+ messages in thread
From: T.J. Mercier @ 2026-10-09 15:07 UTC (permalink / raw)
  To: Qiliang Yuan
  Cc: Andrii Nakryiko, Eduard Zingerman, Ihor Solodrai,
	Alexei Starovoitov, Daniel Borkmann, Kumar Kartikeya Dwivedi,
	Martin KaFai Lau, Song Liu, Yonghong Song, Jiri Olsa,
	Emil Tsalapatis, Shuah Khan, Christian König, bpf,
	linux-kselftest, linux-kernel

On Fri, Oct 9, 2026 at 3:49 AM Qiliang Yuan <odys.yuan@gmail.com> wrote:
>
> The dmabuf_collector iterator prints the inode, size, name and exporter
> of every dma-buf in the system on separate lines, with an empty name for
> the buffers that have none. The default_iter subtest parses that output
> and looks for the two buffers it created.
>
> It requires a name for every buffer, and sscanf() finds none on the
> empty line of an unnamed one. On a system that has such a buffer, like
> one exported by udmabuf without a name, the subtest fails before it gets
> to its own buffers.

Hi Qiliang, are you running this locally instead of with:
tools/testing/selftests/bpf/vmtest.sh -- ./test_progs?

> Take an empty name for a buffer without one.
>
> Fixes: ae5d2c59ecd7 ("selftests/bpf: Add test for dmabuf_iter")
> Signed-off-by: Qiliang Yuan <odys.yuan@gmail.com>
> ---
>  tools/testing/selftests/bpf/prog_tests/dmabuf_iter.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/dmabuf_iter.c b/tools/testing/selftests/bpf/prog_tests/dmabuf_iter.c
> index fb2cea710db3e..1a5dc1adae735 100644
> --- a/tools/testing/selftests/bpf/prog_tests/dmabuf_iter.c
> +++ b/tools/testing/selftests/bpf/prog_tests/dmabuf_iter.c
> @@ -188,8 +188,9 @@ static void subtest_dmabuf_iter_check_default_iter(struct dmabuf_iter *skel)
>                         ASSERT_EQ(sscanf(line, "%ld", &bufinfo.size), 1,
>                                   "read size");
>                 } else if (f % FIELD_COUNT == NAME) {
> -                       ASSERT_EQ(sscanf(line, "%s", bufinfo.name), 1,
> -                                 "read name");
> +                       /* Keep an empty name for a buffer without one */
> +                       if (sscanf(line, "%s", bufinfo.name) != 1)
> +                               bufinfo.name[0] = '\0';
>                 } else if (f % FIELD_COUNT == EXPORTER) {
>                         ASSERT_EQ(sscanf(line, "%31s", bufinfo.exporter), 1,
>                                   "read exporter");
>
> ---
> base-commit: e1d84a37cba984388988d2f1ddc84561413f0db2
> change-id: 20261009-selftests-bpf-dmabuf-iter-unnamed-217561e20d84
>
> Best regards,
> --
> Qiliang Yuan <odys.yuan@gmail.com>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf-next] selftests/bpf: Accept unnamed dma-bufs in the dmabuf_iter default test
  2026-10-09 15:07 ` T.J. Mercier
@ 2026-10-10  2:52   ` Qiliang Yuan
  0 siblings, 0 replies; 3+ messages in thread
From: Qiliang Yuan @ 2026-10-10  2:52 UTC (permalink / raw)
  To: T.J. Mercier
  Cc: Andrii Nakryiko, Eduard Zingerman, Ihor Solodrai,
	Alexei Starovoitov, Daniel Borkmann, Kumar Kartikeya Dwivedi,
	Martin KaFai Lau, Song Liu, Yonghong Song, Jiri Olsa,
	Emil Tsalapatis, Shuah Khan, Christian König, bpf,
	linux-kselftest, linux-kernel

On Fri, Oct 9, 2026 at 5:07 PM T.J. Mercier <tjmercier@google.com> wrote:
> Hi Qiliang, are you running this locally instead of with:
> tools/testing/selftests/bpf/vmtest.sh -- ./test_progs?

Yes, I ran ./test_progs directly in a Debian testing VM, not through
vmtest.sh. The VM runs a GNOME desktop on virtio-gpu, and gnome-shell,
mutter-x11-frames and ibus-x11 each hold a 4 KiB udmabuf without a name
(their fdinfo shows exp_name udmabuf and no name line). As the
iterator walks every dma-buf in the system, default_iter fails on such
a machine before it gets to the two buffers it created. The minimal VM
of vmtest.sh has no such buffers, so it doesn't show up there.

The subtest only checks its own two buffers, so skipping over the name
of any other buffer seemed safer than relying on all of them having
one.

Thanks,
Qiliang

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-10  2:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-09  1:49 [PATCH bpf-next] selftests/bpf: Accept unnamed dma-bufs in the dmabuf_iter default test Qiliang Yuan
2026-10-09 15:07 ` T.J. Mercier
2026-10-10  2:52   ` Qiliang Yuan

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®