selftest: epoll_busy_poll: epoll busy poll tests
Subsystems (3)
PATCH v2 1/1 selftest: epoll_busy_poll: epoll busy poll tests
Add a simple test for the epoll busy poll ioctls, using the kernel selftest harness.
This test ensures that the ioctls have the expected return codes and that the kernel properly gets and sets epoll busy poll parameters.
The test can be expanded in the future to do real busy polling (provided another machine to act as the client is available).
--- tools/testing/selftests/net/.gitignore | 1 + tools/testing/selftests/net/Makefile | 2 +- tools/testing/selftests/net/epoll_busy_poll.c | 271 ++++++++++++++++++ 3 files changed, 273 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/net/epoll_busy_poll.c
tools/testing/selftests/net/.gitignore +1 -0
@@ -5,6 +5,7 @@ bind_wildcard csum cmsg_sender diag_uid +epoll_busy_poll fin_ack_lat gro hwtstamp_config
tools/testing/selftests/net/Makefile +1 -1
@@ -67,7 +67,7 @@ TEST_GEN_FILES += ipsec TEST_GEN_FILES += ioam6_parser TEST_GEN_FILES += gro TEST_GEN_PROGS = reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa -TEST_GEN_PROGS += reuseport_dualstack reuseaddr_conflict tls tun tap +TEST_GEN_PROGS += reuseport_dualstack reuseaddr_conflict tls tun tap epoll_busy_poll TEST_GEN_FILES += toeplitz TEST_GEN_FILES += cmsg_sender TEST_GEN_FILES += stress_reuseport_listen
tools/testing/selftests/net/epoll_busy_poll.c new file +271 -0
271 lines not on this page · raw message
Signature · 1 line
2.25.1
Jakub Kicinski
maintainerQuoted 8 lines · On Mon, 6 May 2024 20:53:22 +0000 Joe Damato wrote:
Add a simple test for the epoll busy poll ioctls, using the kernel selftest harness.
This test ensures that the ioctls have the expected return codes and that the kernel properly gets and sets epoll busy poll parameters.
The test can be expanded in the future to do real busy polling (provided another machine to act as the client is available).
Hm, we get:
# timeout set to 3600 # selftests: net: epoll_busy_poll # TAP version 13 # 1..5 # # Starting 5 tests from 2 test cases. # # RUN invalid_fd.test_invalid_fd ... # # OK invalid_fd.test_invalid_fd # ok 1 invalid_fd.test_invalid_fd # # RUN epoll_busy_poll.test_get_params ... # # OK epoll_busy_poll.test_get_params # ok 2 epoll_busy_poll.test_get_params # # RUN epoll_busy_poll.test_set_invalid ... # # epoll_busy_poll.c:204:test_set_invalid:Expected -1 (-1) == ret (0) # # epoll_busy_poll.c:205:test_set_invalid:EPIOCSPARAMS should error busy_poll_budget > NAPI_POLL_WEIGHT # # epoll_busy_poll.c:207:test_set_invalid:Expected EPERM (1) == errno (22) # # epoll_busy_poll.c:208:test_set_invalid:EPIOCSPARAMS errno should be EPERM busy_poll_budget > NAPI_POLL_WEIGHT # # test_set_invalid: Test failed # # FAIL epoll_busy_poll.test_set_invalid # not ok 3 epoll_busy_poll.test_set_invalid # # RUN epoll_busy_poll.test_set_and_get_valid ... # # OK epoll_busy_poll.test_set_and_get_valid # ok 4 epoll_busy_poll.test_set_and_get_valid # # RUN epoll_busy_poll.test_invalid_ioctl ... # # OK epoll_busy_poll.test_invalid_ioctl # ok 5 epoll_busy_poll.test_invalid_ioctl
https://netdev-3.bots.linux.dev/vmksft-net/results/584001/98-epoll-busy-poll/stdout
Quoted 38 lines · Jakub Kicinski
Quoted 8 lines · On Mon, 6 May 2024 20:53:22 +0000 Joe Damato wrote:
Add a simple test for the epoll busy poll ioctls, using the kernel selftest harness.
This test ensures that the ioctls have the expected return codes and that the kernel properly gets and sets epoll busy poll parameters.
The test can be expanded in the future to do real busy polling (provided another machine to act as the client is available).
Hm, we get:
# timeout set to 3600 # selftests: net: epoll_busy_poll # TAP version 13 # 1..5 # # Starting 5 tests from 2 test cases. # # RUN invalid_fd.test_invalid_fd ... # # OK invalid_fd.test_invalid_fd # ok 1 invalid_fd.test_invalid_fd # # RUN epoll_busy_poll.test_get_params ... # # OK epoll_busy_poll.test_get_params # ok 2 epoll_busy_poll.test_get_params # # RUN epoll_busy_poll.test_set_invalid ... # # epoll_busy_poll.c:204:test_set_invalid:Expected -1 (-1) == ret (0) # # epoll_busy_poll.c:205:test_set_invalid:EPIOCSPARAMS should error busy_poll_budget > NAPI_POLL_WEIGHT # # epoll_busy_poll.c:207:test_set_invalid:Expected EPERM (1) == errno (22) # # epoll_busy_poll.c:208:test_set_invalid:EPIOCSPARAMS errno should be EPERM busy_poll_budget > NAPI_POLL_WEIGHT # # test_set_invalid: Test failed # # FAIL epoll_busy_poll.test_set_invalid # not ok 3 epoll_busy_poll.test_set_invalid # # RUN epoll_busy_poll.test_set_and_get_valid ... # # OK epoll_busy_poll.test_set_and_get_valid # ok 4 epoll_busy_poll.test_set_and_get_valid # # RUN epoll_busy_poll.test_invalid_ioctl ... # # OK epoll_busy_poll.test_invalid_ioctl # ok 5 epoll_busy_poll.test_invalid_ioctl
Ah, sorry -- this is because I had assumed the test would run without CAP_NET_ADMIN, but since:
epoll_busy_poll.c:204:test_set_invalid:Expected -1 (-1) == ret (0)
succeeds (ret = 0), clearly I am mistaken. Sorry about that.
I think I'll spin up a v3 and I'll add a test with and without CAP_NET_ADMIN to check both cases, which would probably be better anyway.
Jakub Kicinski
maintainerQuoted 9 lines · On Mon, 6 May 2024 18:40:00 -0700 Joe Damato wrote:
Ah, sorry -- this is because I had assumed the test would run without
CAP_NET_ADMIN, but since:epoll_busy_poll.c:204:test_set_invalid:Expected -1 (-1) == ret (0)
succeeds (ret = 0), clearly I am mistaken. Sorry about that.
I think I'll spin up a v3 and I'll add a test with and without
CAP_NET_ADMINto check both cases, which would probably be better anyway.
FWIW the tests run a in separate process from the harness, so it may be possible to drop privileges inside the test, without affecting other test cases. But I've never done it myself, so not sure how easy it is to do in practice..