summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-06-06 09:22:15 +0300
committerPaul Buetow <paul@buetow.org>2026-06-06 09:22:15 +0300
commit178ca1f256b1e345cad2f506b6b244fb50d8d281 (patch)
treeb0d44ee4b4052df12177ea69a8f7d8ae1f6d8034 /cmd
parent322496c2863d5bc14b0a5e4af16690bf19073cae (diff)
test(timerfd): assert timerfd_settime/gettime fd capture end-to-end
The fd-from-air-eventfd-users workload only called timerfd_create then closed the fd, so timerfd_settime/timerfd_gettime were never exercised by any integration test. Commit 6ac9fa4 fixed those two syscalls to KindFd@arg0 (capturing the operating timerfd via fd_event instead of a null_event), but that fix had no end-to-end coverage. Extend the workload to arm the still-open timerfd via timerfd_settime (1s relative expiry, so it never fires) and read it back via timerfd_gettime before closing. Assert in TestFdFromAirEventfdUsers that both enter handlers fire (MinCount>=1) and resolve to the "timerfd:" path prefix, proving arg0 fd is captured rather than null. Locks in the 6ac9fa4 KindFd fix. splice/tee are NOT touched: retbytes_test.go already asserts enter_splice/enter_tee plus positive transfer byte counts, which inherently exercises their arg0 fd capture, so no new coverage is needed there. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/ioworkload/scenario_ipc.go29
1 files changed, 28 insertions, 1 deletions
diff --git a/cmd/ioworkload/scenario_ipc.go b/cmd/ioworkload/scenario_ipc.go
index af22505..207966e 100644
--- a/cmd/ioworkload/scenario_ipc.go
+++ b/cmd/ioworkload/scenario_ipc.go
@@ -77,11 +77,38 @@ func fdFromAirEventfdUsers() error {
fd, _, _ = syscall.RawSyscall(unix.SYS_SIGNALFD4, ^uintptr(0), uintptr(unsafe.Pointer(&mask)), uintptr(unsafe.Sizeof(mask)))
closeIfValid(int(fd))
+ // Create a timerfd and, while it is still open, arm it with
+ // timerfd_settime and read it back with timerfd_gettime. Both of those
+ // syscalls take the timerfd as arg0 (kind=fd@arg0), so tracing them
+ // exercises the fd_event capture path fixed in commit 6ac9fa4: the enter
+ // handlers must resolve arg0 to the registered "timerfd:" descriptor
+ // rather than emitting a null event. We close the fd only after both
+ // operations so the descriptor stays registered for the duration.
fd, _, _ = syscall.RawSyscall(unix.SYS_TIMERFD_CREATE, uintptr(unix.CLOCK_MONOTONIC), uintptr(unix.TFD_CLOEXEC), 0)
- closeIfValid(int(fd))
+ if int(fd) >= 0 {
+ armAndReadTimerfd(int(fd))
+ closeIfValid(int(fd))
+ }
return nil
}
+// armAndReadTimerfd arms the given timerfd via timerfd_settime and reads its
+// current setting back via timerfd_gettime. The timer is set to a one-second
+// relative expiration: far enough in the future that it never actually fires
+// during the scenario, so its only observable effect is that the two syscalls
+// are issued against an already-open timerfd descriptor.
+func armAndReadTimerfd(fd int) {
+ newValue := unix.ItimerSpec{
+ Value: unix.Timespec{Sec: 1, Nsec: 0},
+ }
+ syscall.RawSyscall6(unix.SYS_TIMERFD_SETTIME, uintptr(fd), 0,
+ uintptr(unsafe.Pointer(&newValue)), 0, 0, 0)
+
+ var curValue unix.ItimerSpec
+ syscall.RawSyscall(unix.SYS_TIMERFD_GETTIME, uintptr(fd),
+ uintptr(unsafe.Pointer(&curValue)), 0)
+}
+
func closeIfValid(fd int) {
if fd >= 0 {
_ = syscall.Close(fd)