test: add timens-abs-timer regression test
PATCH 1/1 test: add timens-abs-timer regression test
From: Maoyi Xie <[email protected]>
Add a regression test that exercises the two ABS timer paths in io_uring with the submitter inside a CLONE_NEWTIME time namespace that has a -10s monotonic offset:
- IORING_OP_TIMEOUT with IORING_TIMEOUT_ABS, parsed via io_parse_user_time() in io_uring/timeout.c.
- io_uring_enter with IORING_ENTER_ABS_TIMER, parsed inline in io_cqring_wait() in io_uring/wait.c.
The test forks once to enter the new userns, sets up uid_map and gid_map for unprivileged root, writes the -10s monotonic offset to /proc/self/timens_offsets, then forks again. The grandchild is the first process actually inside the new time namespace (unshare(CLONE_NEWTIME) does not move the caller in, only its future children). On both ABS timer paths the grandchild submits an absolute deadline of now + 1s and asserts the call returns after at least 0.9s.
The test fails on a kernel without commits 9cc6bac1bebf ("io_uring/timeout: honour caller's time namespace for IORING_TIMEOUT_ABS") and 45d2b37a37ab ("io_uring/wait: honour caller's time namespace for IORING_ENTER_ABS_TIMER"), where the deadline is interpreted in host view and the timer fires after ~1ms.
The test is skipped if the kernel lacks CLONE_NEWTIME support or the caller cannot create an unprivileged user namespace.
--- test/Makefile | 1 + test/timens-abs-timer.c | 315 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 316 insertions(+) create mode 100644 test/timens-abs-timer.c
test/Makefile +1 -0
@@ -286,6 +286,7 @@ test_srcs := \ task-restrict.c \ teardowns.c \ thread-exit.c \ + timens-abs-timer.c \ timerfd-short-read.c \ timeout.c \ timeout-new.c \
test/timens-abs-timer.c new file +315 -0
315 lines not on this page · raw message
base-commit: 5dfc30a27303af1185e65d10890fdb35117bb3eb
Signature · 1 line
2.34.1
Quoted 10 lines · Maoyi Xie
Add a regression test that exercises the two ABS timer paths in
io_uringwith the submitter inside aCLONE_NEWTIMEtime namespace that has a -10s monotonic offset:-
IORING_OP_TIMEOUTwithIORING_TIMEOUT_ABS, parsed viaio_parse_user_time()inio_uring/timeout.c.
-io_uring_enterwithIORING_ENTER_ABS_TIMER, parsed inline inio_cqring_wait()inio_uring/wait.c.[...]
Applied, thanks!
[1/1] test: add timens-abs-timer regression test
commit: eb8dd984881241bd206b0503a3bc2627f7ad0d09
Best regards,
Signature · 1 line
Jens Axboe