Skip to content

test(relay): inject a refused io_uring ring so startup is tested on every kernel - #8641

Merged
kixelated merged 2 commits into
mainfrom
fix/uring-memlock-test
Nov 13, 2026
Merged

kixelated merged 2 commits into
mainfrom
fix/uring-memlock-test

Conversation

@kixelated

@kixelated kixelated commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

moq-relay's runtime_uring::uring_startup_reports_the_memlock_limit fails deterministically on Linux 7.3, including the fedora self-hosted CI runners. That breaks main's merge gate whenever the queue lands on one of those runners. The test sets RLIMIT_MEMLOCK to 0 and expects worker startup to fail, but on 7.3 startup succeeds.

Root cause: Linux 6.14 moved the SQ/CQ rings and provided-buffer rings onto the region API, which charged them to RLIMIT_MEMLOCK. That was a regression: the rings had been memcg-accounted since 5.12. Linux 7.3 reverted it in torvalds/linux@b59cabf9b4ac ("do not charge the SQ/CQ rings to RLIMIT_MEMLOCK") and torvalds/linux@cde56daf4b93 (same for provided-buffer rings). Both are tagged Cc: stable. The test's premise only holds on 6.14–7.2 kernels without the backport.

The relay's contract is still right: a ring refused at startup reaches the Ready waiter as an actionable error, and run fails. What was wrong is the claim, in moq_uring::Error::ring, the CQ sizing comment, and the docs, that the kernel always charges rings to memlock.

This does the work of the follow-up quest quest/m0/test-flakes-2/uring-memlock.md that moq-dev/moq#8546 adds, so that follow-up can be dropped from #8546.

Approach

  • Test (renamed uring_startup_reports_a_refused_ring): in its isolated child process, a seccomp filter makes io_uring_setup return ENOMEM. A spent memory cgroup or a memlock-charging kernel refuses a ring the same way. The test still asserts that the error names the worker, RLIMIT_MEMLOCK, ulimit -l and LimitMEMLOCK= (all present in the message on main), and that run fails. It now runs on every kernel and under root, so the CAP_IPC_LOCK skip is gone.
  • Code comments: Error::ring's doc comment and the CQ sizing comment in worker.rs now name the kernel range that charges memlock.
  • The ENOMEM message text and the user-facing docs (moq-uring/README.md, doc/bin/relay/config.md, moq-relay.service) make the same wrong claim. They move to a follow-up PR, moq-dev/moq#8642, so this behavior-preserving gate fix can land on its own.

Decision I made without the user (recommendation taken):

  • Inject the refusal with seccomp instead of exhausting a real limit. Which limit a kernel charges varies, and exhausting memcg would mean a cgroup the test can't portably create.

Validation

  • Probed the kernels directly with a C program that sets RLIMIT_MEMLOCK=0, then sets up a 256/2048 ring, registers a 4096-entry provided-buffer ring, and registers a 1 MiB fixed buffer:
    • 7.3.3 (fedora): ring and buffer ring succeed; only the fixed buffer gets ENOMEM.
    • 6.18.63 (nixos, with the stable backport): same as 7.3.3.
    • 7.0 (Ubuntu, desktop): ring setup gets ENOMEM.
  • Checked the kernel sources: io_create_region(NULL, …) for rings and buffer rings in v7.3, and ctx->user in v6.18 and v7.0–v7.2.
  • The old test fails on 7.3.3 with and without --features io-uring. The new test passes under cargo test and nextest.
  • Mutation: with the filter call removed, the new test fails on expect_err, so it isn't vacuous.
  • Ran the isolated child directly. The waiter got failed to start the io_uring QUIC workers: io_uring worker 0 failed to start: io_uring setup failed: io error: Cannot allocate memory (os error 12): …RLIMIT_MEMLOCK….
  • just check passes.

Impact

  • No public API, wire or message change: test and code comments only.
  • The test runs in the merge gate as before (~0.03 s), now on every kernel.

Alternatives

  • Skip on kernels that don't charge memlock: rejected. The relay doesn't act on the kernel version, and the test would go silent on fixed kernels.
  • Fail with EMFILE via RLIMIT_NOFILE: depends on how many fds the process already has open, and wouldn't exercise the ENOMEM message path.

Follow-ups

  • moq-dev/moq#8642: corrects the ENOMEM message and the docs to name the affected kernel range.

Caused by

No single PR: an upstream kernel change. moq-dev/moq#7593 wrote the test and moq-dev/moq#4167 the memlock wording, both against 6.14–7.2's memlock charge, which the kernel later reverted as a regression.

Waiting

Nothing.

Models

Size: S
Implementer: Claude Code, claude-opus-5-5, unknown effort

🤖 Generated with Claude Code

(Written by Claude Opus 5.5)

Review

Rewritten by quest review after each round.

  • Head: e9d1825

  • Base: origin/main at 6aa4f9c

  • Reviewer: Codex, gpt-6.1-sol, medium effort

  • Session: 01a1d51f-57d7-7e02-9afa-6a69fa26daa9, round 1

  • Score: 9/10, Source review found no actionable defects, but runtime validation remains because builds and tests were not run as instructed.

  • Rounds: 2; findings 0: fixed 0, refuted 0, open 0

  • Findings: none

…mlock-charging ones

Linux 6.14 began charging io_uring SQ/CQ and provided-buffer rings to
RLIMIT_MEMLOCK, a regression that 7.3 reverted (and stable backported),
so the memlock test started succeeding on fixed kernels. Inject ENOMEM
into io_uring_setup with a seccomp filter instead, and stop claiming
every kernel charges rings to memlock.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review November 13, 2026 13:31
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Reviewed the net change through e9d1825: the test now injects the ring refusal itself, and two code comments limit the memlock claim to the affected kernels. e9d1825 moved the error message and docs wording to a follow-up PR.

  • Refused-ring test: uring_startup_reports_a_refused_ring runs in an isolated child process. That child installs a seccomp filter (PR_SET_NO_NEW_PRIVS + SECCOMP_FILTER_FLAG_TSYNC) that makes io_uring_setup return ENOMEM, so the test no longer depends on kernel accounting or CAP_IPC_LOCK. The filter goes in after the supported() probe and Relay::load, so only the relay's worker startup sees the refusal. The test's expected substrings (RLIMIT_MEMLOCK, ulimit -l, LimitMEMLOCK=) all still appear in the unchanged Error::ring message.
  • Comments only: the Error::ring doc comment and the PRODUCTION_CQ_ENTRIES comment in worker.rs now say only Linux 6.14 up to the 7.3 fix charges rings to RLIMIT_MEMLOCK.

ℹ️ The PR description still describes the reverted changes

Since e9d1825, the PR no longer changes the Error::ring ENOMEM message, moq-uring/README.md, doc/bin/relay/config.md or moq-relay.service. The Approach, Validation (the quoted waiter message) and Impact sections still say it does. Update them before merge so the squash commit matches the change.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The integration test replaces memlock exhaustion and a capability check with a synchronized seccomp filter that returns ENOMEM for io_uring_setup. It checks that relay readiness fails. Documentation now distinguishes shared RLIMIT_MEMLOCK accounting on Linux 6.14 through the 7.3 fix, including stable backports, from memory-cgroup accounting on other kernels.

Merge Risk: Minimal · up to e9d18

This change updates documentation comments and replaces a kernel-dependent test with a deterministic one. It does not alter production behavior, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the memlock startup test is replaced by a seccomp-injected io_uring_setup ENOMEM refusal, so it runs on every kernel. It matches the test rewrite in runtime_uring.rs a…
Description check Passed The description explains the problem (the memlock startup test fails on Linux 7.3), the root cause (the kernel's memlock charging change), the approach (seccomp injects ENOMEM), validation steps, and …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the memlock startup test is replaced by a seccomp-injected io_uring_setup ENOMEM refusal, so it runs on every kernel. It matches the test rewrite in runtime_uring.rs and the objectives. The title is 80 characters, which is slightly long but still clear.

Full details: Description check

Explanation

The description explains the problem (the memlock startup test fails on Linux 7.3), the root cause (the kernel's memlock charging change), the approach (seccomp injects ENOMEM), validation steps, and deferred follow-ups. It is related to the changeset in detail.

Finishing Touches

Simplify code

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

Clippy (1.99.1)

Clippy execution timed out

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8bf1aef4-0f10-41da-8b0e-d9b13854e582
Commits

Reviewing files that changed from the base of the PR and between 6aa4f9c and e9d1825.

Files selected for processing: 3

  • rs/moq-relay/tests/integration/runtime_uring.rs
  • rs/moq-uring/src/error.rs
  • rs/moq-uring/src/worker.rs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

@kixelated kixelated changed the title fix(relay): test a refused io_uring ring on every kernel, not only memlock-charging ones test(relay): inject a refused io_uring ring so startup is tested on every kernel Nov 13, 2026
@kixelated
kixelated added this pull request to the merge queue Nov 13, 2026
Merged via the queue into main with commit 3fabd01 Nov 13, 2026
9 checks passed
@kixelated
kixelated deleted the fix/uring-memlock-test branch November 13, 2026 13:40
kixelated added a commit that referenced this pull request Nov 13, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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