summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-19 16:15:18 +0300
committerPaul Buetow <paul@buetow.org>2026-05-19 16:15:18 +0300
commit843def4f5c23db050cccfae57a9acb5899c110f4 (patch)
treed90d94c39ff59c7df7278f29f5402c58c391daec /cmd
parent061fb2b2380752eed06a78d10567da172ea8e27c (diff)
x6: add pipe/eventfd fd-from-air syscall support
Diffstat (limited to 'cmd')
-rw-r--r--cmd/ioworkload/scenario_ipc.go56
-rw-r--r--cmd/ioworkload/scenarios.go4
2 files changed, 60 insertions, 0 deletions
diff --git a/cmd/ioworkload/scenario_ipc.go b/cmd/ioworkload/scenario_ipc.go
new file mode 100644
index 0000000..221c3c9
--- /dev/null
+++ b/cmd/ioworkload/scenario_ipc.go
@@ -0,0 +1,56 @@
+package main
+
+import (
+ "fmt"
+ "syscall"
+
+ "golang.org/x/sys/unix"
+)
+
+func pipeBasic() error {
+ var pipefd [2]int
+ if err := syscall.Pipe(pipefd[:]); err != nil {
+ return fmt.Errorf("pipe: %w", err)
+ }
+ defer syscall.Close(pipefd[0])
+ defer syscall.Close(pipefd[1])
+ return nil
+}
+
+func pipe2Basic() error {
+ var pipefd [2]int
+ flags := syscall.O_CLOEXEC | syscall.O_NONBLOCK
+ if err := syscall.Pipe2(pipefd[:], flags); err != nil {
+ return fmt.Errorf("pipe2: %w", err)
+ }
+ defer syscall.Close(pipefd[0])
+ defer syscall.Close(pipefd[1])
+ return nil
+}
+
+func eventfdBasic() error {
+ fd, err := createEventfd(syscall.SYS_EVENTFD, 1, 0)
+ if err != nil {
+ return err
+ }
+ defer syscall.Close(fd)
+ return nil
+}
+
+func eventfd2Basic() error {
+ flags := uintptr(unix.EFD_CLOEXEC | unix.EFD_NONBLOCK)
+ fd, err := createEventfd(syscall.SYS_EVENTFD2, 1, flags)
+ if err != nil {
+ return err
+ }
+ defer syscall.Close(fd)
+ return nil
+}
+
+func createEventfd(number uintptr, initval, flags uintptr) (int, error) {
+ fd, _, errno := syscall.RawSyscall(number, initval, flags, 0)
+ if errno != 0 {
+ return -1, fmt.Errorf("eventfd syscall %d: %w", number, errno)
+ }
+ return int(fd), nil
+}
diff --git a/cmd/ioworkload/scenarios.go b/cmd/ioworkload/scenarios.go
index 9700d85..b9c08d3 100644
--- a/cmd/ioworkload/scenarios.go
+++ b/cmd/ioworkload/scenarios.go
@@ -30,6 +30,10 @@ var scenarios = map[string]func() error{
"socket-accept-lifecycle": socketAcceptLifecycle,
"socket-accept-lifecycle-plain": socketAcceptLifecyclePlain,
"socket-introspection": socketIntrospection,
+ "pipe-basic": pipeBasic,
+ "pipe2-basic": pipe2Basic,
+ "eventfd-basic": eventfdBasic,
+ "eventfd2-basic": eventfd2Basic,
"family-mixed": familyMixed,
"close-basic": closeBasic,
"close-range": closeRange,