Skip to content

Use futex2_wake for io_uring waker - #312

Merged
lalinsky merged 1 commit into
mainfrom
io-uring-futex2-wake
Feb 10, 2026
Merged

lalinsky merged 1 commit into
mainfrom
io-uring-futex2-wake

Conversation

@lalinsky

Copy link
Copy Markdown
Owner

Summary

  • Use futex2_wake instead of old futex syscall to wake io_uring's FUTEX_WAIT (which uses FUTEX2 interface)
  • Wake all waiters instead of just one to work around suspected kernel bug where stale waiters remain in the futex hash table after io_uring ring closure

Test plan

  • Ran ./check.sh - all tests pass
  • Previously flaky sync.future.test.Future: multiple waiters test now passes reliably

io_uring's FUTEX_WAIT uses the FUTEX2 kernel interface, so we need to
use futex2_wake instead of the old futex syscall to wake it.

Wake all waiters instead of just one - the kernel appears to leave
stale waiters in the futex hash table when io_uring rings are closed,
causing subsequent wakes to target the wrong waiter.
@coderabbitai

coderabbitai Bot commented Feb 10, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The wake() function in the io_uring backend switches from a single-target futex WAKE syscall to a futex2_wake call that wakes all waiters. The new implementation uses FUTEX_BITSET_MATCH_ANY matching, updated flags for 32-bit private futex semantics, and an effectively infinite timeout.

Changes

Cohort / File(s) Summary
Futex wake syscall refactor
src/ev/backends/io_uring.zig
Replaced futex WAKE syscall with futex2_wake call; changed from single-waiter wake semantics to broadcast wake with bitset matching and infinite timeout. Adjusts flags to 32-bit private futex mode.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

A futex wakes from slumber deep,
No longer one, but all that sleep.
From syscall old to futex2 new,
Broadcast signals: wake the crew! 📢

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and concisely describes the main change: switching from the old futex syscall to futex2_wake for the io_uring waker implementation.
Description check ✅ Passed The description clearly explains the rationale for the change (futex2 interface compatibility, kernel bug workaround) and provides test evidence supporting the fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch io-uring-futex2-wake

No actionable comments were generated in the recent review. 🎉


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@lalinsky
lalinsky merged commit 8132a95 into main Feb 10, 2026
15 checks passed
@lalinsky
lalinsky deleted the io-uring-futex2-wake branch February 10, 2026 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant