Skip to content

[eve-kernel-arm64-v6.1.155-generic] io_uring/io-wq: apply the current cpuset to new workers - #342

Merged
rene merged 1 commit into
lf-edge:eve-kernel-arm64-v6.1.155-genericfrom
rucoder:backport/iowq-cpuset-arm64-v6.1.155-generic
Nov 23, 2026
Merged

rene merged 1 commit into
lf-edge:eve-kernel-arm64-v6.1.155-genericfrom
rucoder:backport/iowq-cpuset-arm64-v6.1.155-generic

Conversation

@rucoder

@rucoder rucoder commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

Backport of #336 to eve-kernel-arm64-v6.1.155-generic: upstream 0659e44ce739 "io_uring/io-wq: apply the current cpuset to new workers" (applied by Jens Axboe to io_uring-7.4, Cc: stable; not in a mainline release yet).

6.1 has the bug: stable backported 84eacf177faa ("io_uring/io-wq: inherit cpuset of cgroup in io worker") to 6.1.113 as 657ca82526d0, so io-wq workers started after a cpuset change, or after the task moves to another cgroup, run on the CPUs the cgroup had when the io-wq was created. (#336 listed this branch as not affected; that was wrong.)

Key adaptations for 6.1

  • 6.1 keeps one struct io_wqe per NUMA node, each with its own cpu_mask; mainline merged them into struct io_wq in v6.4 (dfd63baf892c, eb47943f2238). The node's CPUs take the place of "all CPUs": io_wq_create() and unregistering IORING_REGISTER_IOWQ_AFF set cpumask_of_node() again, as 6.1 did before 657ca82526d0, and each new worker gets the node's CPUs that its current cpuset allows, or the cpuset if they have none in common.
  • The two helpers take struct io_wqe instead of struct io_wq.
  • The fix does not apply to upstream 6.1.y either, for the same reason; this is the version to send to stable when it asks for a backport.

Validation

This branch's source built for x86_64 under QEMU/KVM (8 CPUs, cgroup v2, lockdep, CPUMASK_OFFSTACK; the io-wq code has no architecture-specific parts), the same test as #336:

case without the fix with the fix
cpuset 2-3 -> 4-5, new workers FAIL PASS
idle worker retired after the change FAIL PASS
cpuset grows 2-3 -> 2-5 FAIL PASS
cgroup move 2-3 -> 4-5 FAIL PASS
IORING_REGISTER_IOWQ_AFF / unregister FAIL PASS
CPU hotplug PASS PASS

Two NUMA nodes (CPUs 0-3 and 4-7, a socket each), to exercise the per-node masks: without the fix 11 workers ran outside their cgroup's cpuset, with it none. There grow and hotplug report a node queue's own CPUs within the cpuset (cpuset 2-5 gives node 0's workers 2-3), which is 6.1's per-node design and not a change. No lockdep or sleep-in-atomic reports.

arm64: io_uring/ cross-compiled with eve_defconfig (NUMA, cpusets on) at W=1: no warnings in io-wq.c. Not run on arm64 hardware.

🤖 Generated with Claude Code

commit 0659e44ce739ecd856164c75a5325b7959a2921d upstream.

Since commit 84eacf1 ("io_uring/io-wq: inherit cpuset of cgroup in
io worker"), io_wq_create() copies the cpuset of the creating task into
wq->cpu_mask, and io_init_new_worker() gives each new worker that copy.
A cpuset change, or a move of the task to another cgroup, updates the
workers that exist but not the copy, so workers started later run on
the CPUs the cgroup had when the io-wq was created, which may since
have been given to other tasks. Workers come and go for the life of the
io-wq, and a worker that cpuset moved is also retired at its next idle
timeout and replaced on the old CPUs.

Keep wq->cpu_mask for the affinity of the io-wq itself, all CPUs or the
mask set with IORING_REGISTER_IOWQ_AFF, and intersect it with the cpuset
of the worker when the worker starts, falling back to the cpuset if the
two do not intersect, as __set_cpus_allowed_ptr() does. Use the same
mask in the idle exit test, and go back to all CPUs when the registered
affinity is removed.

Fixes: 84eacf1 ("io_uring/io-wq: inherit cpuset of cgroup in io worker")
Cc: stable@vger.kernel.org
Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
Link: https://patch.msgid.link/20261111162705.1150983-1-mike.malyshev@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
[Backport: 6.1 keeps an io_wqe per NUMA node, each with its own
 cpu_mask, so the node's CPUs take the place of all CPUs: io_wq_create()
 and the reset in io_wq_cpu_affinity() set cpumask_of_node() again, as
 before the backport of 84eacf1, and each worker gets the node's
 CPUs that its cpuset allows.]
Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
@rene
rene merged commit 1216a9e into lf-edge:eve-kernel-arm64-v6.1.155-generic Nov 23, 2026
2 checks passed
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.

2 participants