Skip to content

runtime: disable io-uring on EPERM#7724

Merged
ADD-SP merged 1 commit intomasterfrom
use_fallback_when_eperm
Nov 8, 2025
Merged

runtime: disable io-uring on EPERM#7724
ADD-SP merged 1 commit intomasterfrom
use_fallback_when_eperm

Conversation

@mox692
Copy link
Copy Markdown
Member

@mox692 mox692 commented Nov 6, 2025

Motivation

Closes #7691.

Solution

If we get EPERM at the initial io-uring syscall (io_uring_setup), then we set the Unsupported flag internally, which disables subsequent io-uring operations.

@mox692 mox692 added A-tokio Area: The main tokio crate M-runtime Module: tokio/runtime labels Nov 6, 2025
@mox692 mox692 changed the title runtime: fallback to thread-pool when io-uring operation gets EPERM runtime: disable io-uring on EPERM Nov 6, 2025
Copy link
Copy Markdown
Member

@martin-g martin-g left a comment

Choose a reason for hiding this comment

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

LGTM!

I only wish there was an info log to tell me that uring is disabled for some reason.

Copy link
Copy Markdown
Member

@ADD-SP ADD-SP left a comment

Choose a reason for hiding this comment

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

How to write tests for this fix? To make our testset self-contained, the crate libseccomp might be a good candidate. However, the libseccomp requires us to install the libseccomp.so on the system, it is a bit annoying for developer to run tests locally.

One possible solution is gating the test using special cfg and only apply this cfg on CI.

Copy link
Copy Markdown
Member

@ADD-SP ADD-SP left a comment

Choose a reason for hiding this comment

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

Another alternative for testing is https://docs.rs/seccompiler/0.5.0/seccompiler/.

Copy link
Copy Markdown
Member

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

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

Testing this in CI sounds difficult, but can we perform a manual test?

Copy link
Copy Markdown
Member

@ADD-SP ADD-SP left a comment

Choose a reason for hiding this comment

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

We can open another PR for testing if possible.

Copy link
Copy Markdown
Member

@ADD-SP ADD-SP left a comment

Choose a reason for hiding this comment

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

Tested locally — this fix works as expected.

docker run --rm rust:latest bash -c "$(cat <<"EOF"
mkdir -p /tmp/test/src
cd /tmp/test
ln -s Cargo.toml a.toml

cat <<"EOF2" > Cargo.toml
[package]
edition = "2024"
name = "tokio-io-uring-symlink"

[dependencies]
tokio = { git = "https://github.com/tokio-rs/tokio.git", rev = "7f959e1049c8d252f4a1e18bbbabc94cfd91120d", features = ["full", "io-uring"] }
EOF2

cat <<"EOF2" > src/main.rs
#[tokio::main]
async fn main() {
    tokio::fs::File::open("a.toml").await.unwrap();
}
EOF2

RUSTFLAGS='--cfg tokio_unstable' cargo run
EOF
)"

@ADD-SP ADD-SP merged commit 2bf80f0 into master Nov 8, 2025
98 checks passed
@ADD-SP ADD-SP deleted the use_fallback_when_eperm branch November 8, 2025 09:13
Daksh14 pushed a commit to Daksh14/tokio that referenced this pull request Nov 11, 2025
@martin-g martin-g added the T-io-uring Topic: Linux io_uring label Dec 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-tokio Area: The main tokio crate M-runtime Module: tokio/runtime T-io-uring Topic: Linux io_uring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Opening a symlink errors using io-uring feature

4 participants