mbox series

[V3,0/3] selftests: add ublk selftests

Message ID 20250228161919.2869102-1-ming.lei@redhat.com (mailing list archive)
Headers show
Series selftests: add ublk selftests | expand

Message

Ming Lei Feb. 28, 2025, 4:19 p.m. UTC
Hello Jens,

This patchset adds ublk kernel selftests, which is very handy for
developer for verifying kernel change, especially ublk heavily depends
on io_uring subsystem. Also it provides template for target implementation.

Please consider it for v6.15.

The 1st patch adds one ublk utility and one entry test.
The 2nd patch adds test over file backed ublk.
The 3rd patch adds test for ublk zero copy.

How to run:
	- make install
	- make headers_install INSTALL_HDR_PATH=/usr	# in case UAPI is changed
	- reboot
	- make -C tools/testing/selftests TARGETS=ublk run_test

Thanks,

V3:
	- re-organize code, and move target code into standalone source file
	- fix one error handling bug
	- add licence tag
	- add dma limit for zero copy file backed target
	- kill checkpatch ERROR

V2:
	- fix one sqe allocation bug, so ublk zero copy with io_link can pass
	- dump log in case of error
	- add one more test for mkfs/mount on zero copy


Ming Lei (3):
  selftests: ublk: add kernel selftests for ublk
  selftests: ublk: add file backed ublk
  selftests: ublk: add ublk zero copy test

 MAINTAINERS                                  |    1 +
 tools/testing/selftests/Makefile             |    1 +
 tools/testing/selftests/ublk/.gitignore      |    3 +
 tools/testing/selftests/ublk/Makefile        |   16 +
 tools/testing/selftests/ublk/config          |    1 +
 tools/testing/selftests/ublk/file_backed.c   |  220 ++++
 tools/testing/selftests/ublk/kublk.c         | 1110 ++++++++++++++++++
 tools/testing/selftests/ublk/kublk.h         |  326 +++++
 tools/testing/selftests/ublk/null.c          |   38 +
 tools/testing/selftests/ublk/test_common.sh  |  113 ++
 tools/testing/selftests/ublk/test_loop_01.sh |   31 +
 tools/testing/selftests/ublk/test_loop_02.sh |   22 +
 tools/testing/selftests/ublk/test_loop_03.sh |   33 +
 tools/testing/selftests/ublk/test_loop_04.sh |   22 +
 tools/testing/selftests/ublk/test_null_01.sh |   19 +
 15 files changed, 1956 insertions(+)
 create mode 100644 tools/testing/selftests/ublk/.gitignore
 create mode 100644 tools/testing/selftests/ublk/Makefile
 create mode 100644 tools/testing/selftests/ublk/config
 create mode 100644 tools/testing/selftests/ublk/file_backed.c
 create mode 100644 tools/testing/selftests/ublk/kublk.c
 create mode 100644 tools/testing/selftests/ublk/kublk.h
 create mode 100644 tools/testing/selftests/ublk/null.c
 create mode 100755 tools/testing/selftests/ublk/test_common.sh
 create mode 100755 tools/testing/selftests/ublk/test_loop_01.sh
 create mode 100755 tools/testing/selftests/ublk/test_loop_02.sh
 create mode 100755 tools/testing/selftests/ublk/test_loop_03.sh
 create mode 100755 tools/testing/selftests/ublk/test_loop_04.sh
 create mode 100755 tools/testing/selftests/ublk/test_null_01.sh

Comments

Jens Axboe Feb. 28, 2025, 4:37 p.m. UTC | #1
On 2/28/25 9:19 AM, Ming Lei wrote:
> Hello Jens,
> 
> This patchset adds ublk kernel selftests, which is very handy for
> developer for verifying kernel change, especially ublk heavily depends
> on io_uring subsystem. Also it provides template for target implementation.
> 
> Please consider it for v6.15.

Can we add the zc bits to the liburing test case as well?
Jens Axboe Feb. 28, 2025, 4:38 p.m. UTC | #2
On Sat, 01 Mar 2025 00:19:13 +0800, Ming Lei wrote:
> This patchset adds ublk kernel selftests, which is very handy for
> developer for verifying kernel change, especially ublk heavily depends
> on io_uring subsystem. Also it provides template for target implementation.
> 
> Please consider it for v6.15.
> 
> The 1st patch adds one ublk utility and one entry test.
> The 2nd patch adds test over file backed ublk.
> The 3rd patch adds test for ublk zero copy.
> 
> [...]

Applied, thanks!

[1/3] selftests: ublk: add kernel selftests for ublk
      commit: 6aecda00b7d1e187c31e702d607d2b51bbcddbcc
[2/3] selftests: ublk: add file backed ublk
      commit: 5d95bfb5357111028b7a37464d1a18702722efe9
[3/3] selftests: ublk: add ublk zero copy test
      commit: bedc9cbc5f9709b97646fe3423dbf530b74b09d5

Best regards,
Ming Lei March 1, 2025, 1:11 a.m. UTC | #3
On Fri, Feb 28, 2025 at 09:37:47AM -0700, Jens Axboe wrote:
> On 2/28/25 9:19 AM, Ming Lei wrote:
> > Hello Jens,
> > 
> > This patchset adds ublk kernel selftests, which is very handy for
> > developer for verifying kernel change, especially ublk heavily depends
> > on io_uring subsystem. Also it provides template for target implementation.
> > 
> > Please consider it for v6.15.
> 
> Can we add the zc bits to the liburing test case as well?

OK, will unify the two tests and cover liburing too.

BTW, would you like to consider to move liburing tests or part of them
into kernel selftests? 

This way looks more friendly for kernel developer:

- single repo, and single patchset can include both io_uring kernel
  patches and selftests change

- easy to run test against same kernel repo

Also liburing development may be decoupled from io_uring kernel
a bit.



Thanks,
Ming
Jens Axboe March 1, 2025, 2:19 a.m. UTC | #4
On 2/28/25 6:11 PM, Ming Lei wrote:
> On Fri, Feb 28, 2025 at 09:37:47AM -0700, Jens Axboe wrote:
>> On 2/28/25 9:19 AM, Ming Lei wrote:
>>> Hello Jens,
>>>
>>> This patchset adds ublk kernel selftests, which is very handy for
>>> developer for verifying kernel change, especially ublk heavily depends
>>> on io_uring subsystem. Also it provides template for target implementation.
>>>
>>> Please consider it for v6.15.
>>
>> Can we add the zc bits to the liburing test case as well?
> 
> OK, will unify the two tests and cover liburing too.
> 
> BTW, would you like to consider to move liburing tests or part of them
> into kernel selftests? 
> 
> This way looks more friendly for kernel developer:
> 
> - single repo, and single patchset can include both io_uring kernel
>   patches and selftests change
> 
> - easy to run test against same kernel repo

I have considered it, but at least the way I run the liburing tests, it
uses a bunch of different types of devices to get full coverage. It's
not really a fire-off-and-forget kind of setup. Yes you can run it like
that and not have it use any other fs or device, but you won't get full
coverage. The liburing regression tests are also meant to be run on ANY
kernel, not just the current kernel. Eg I do that for stable kernels.

As far as I can tell, the only win here would be that it'd be easier for
someone to run when making a kernel change. And that is a nice win
indeed. But there are so many downsides for me and the tests in general,
that I don't see that win as being nearly big enough to warrant
switching it over.

For new feature tests, I think adding that as kernel selftests may make
more sense - test that it works, test failure/error cases, etc.

> Also liburing development may be decoupled from io_uring kernel
> a bit.

It's already entirely decoupled from the kernel. At least as much as it
can be. Yes the uapi header is shared and synced across them, but
there's really no other dependency there and no version dependencies
between liburing and the kernel.