io_uring/sqpoll: inherit cpumask of creating process io_uring-6.11
authorFelix Moessbauer <felix.moessbauer@siemens.com>
Sat, 7 Sep 2024 10:02:04 +0000 (12:02 +0200)
committerJens Axboe <axboe@kernel.dk>
Sat, 7 Sep 2024 13:40:12 +0000 (07:40 -0600)
commitb7ed6d8ffd627a3de8b0e336996d0247a6535608
tree2957474d9b06cf9c5e5aaa99a731bb6d47631078
parentf274495aea7b15225b3d83837121b22ef96e560c
io_uring/sqpoll: inherit cpumask of creating process

The submit queue polling threads are userland threads that just never
exit to the userland. In case the creating task is part of a cgroup
with the cpuset controller enabled, the poller should also stay within
that cpuset. This also holds, as the poller belongs to the same cgroup
as the task that started it.

With the current implementation, a process can "break out" of the
defined cpuset by creating sq pollers consuming CPU time on other CPUs,
which is especially problematic for realtime applications.

Part of this problem was fixed in a5fc1441 by dropping the
PF_NO_SETAFFINITY flag, but this only becomes effective after the first
modification of the cpuset (i.e. the pollers cpuset is correct after the
first update of the enclosing cgroups cpuset).

By inheriting the cpuset of the creating tasks, we ensure that the
poller is created with a cpumask that is a subset of the cgroups mask.
Inheriting the creators cpumask is reasonable, as other userland tasks
also inherit the mask.

Fixes: 37d1e2e3642e ("io_uring: move SQPOLL thread io-wq forked worker")
Cc: stable@vger.kernel.org # 6.1+
Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
Link: https://lore.kernel.org/r/20240907100204.28609-1-felix.moessbauer@siemens.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/sqpoll.c