Skip to content

Commit

Permalink
io_uring/sqpoll: do not put cpumask on stack
Browse files Browse the repository at this point in the history
Putting the cpumask on the stack is deprecated for a long time (since
2d3854a), as these can be big. Given that, change the on-stack
allocation of allowed_mask to be dynamically allocated.

Fixes: f011c9c ("io_uring/sqpoll: do not allow pinning outside of cpuset")
Signed-off-by: Felix Moessbauer <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
fmoessbauer authored and axboe committed Sep 16, 2024
1 parent a09c172 commit 7f44bea
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions io_uring/sqpoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,15 +461,22 @@ __cold int io_sq_offload_create(struct io_ring_ctx *ctx,
return 0;

if (p->flags & IORING_SETUP_SQ_AFF) {
struct cpumask allowed_mask;
cpumask_var_t allowed_mask;
int cpu = p->sq_thread_cpu;

ret = -EINVAL;
if (cpu >= nr_cpu_ids || !cpu_online(cpu))
goto err_sqpoll;
cpuset_cpus_allowed(current, &allowed_mask);
if (!cpumask_test_cpu(cpu, &allowed_mask))
ret = -ENOMEM;
if (!alloc_cpumask_var(&allowed_mask, GFP_KERNEL))
goto err_sqpoll;
ret = -EINVAL;
cpuset_cpus_allowed(current, allowed_mask);
if (!cpumask_test_cpu(cpu, allowed_mask)) {
free_cpumask_var(allowed_mask);
goto err_sqpoll;
}
free_cpumask_var(allowed_mask);
sqd->sq_cpu = cpu;
} else {
sqd->sq_cpu = -1;
Expand Down

0 comments on commit 7f44bea

Please sign in to comment.