io_uring-6.7-2023-11-17

-----BEGIN PGP SIGNATURE-----
 
 iQJEBAABCAAuFiEEwPw5LcreJtl1+l5K99NY+ylx4KYFAmVXpIQQHGF4Ym9lQGtl
 cm5lbC5kawAKCRD301j7KXHgpiDzD/4v0bC3DF+P8uv8YPKO/OCOfkEvDmcIhNOh
 HDYoVzkbUtXaZB8qKr9lgFtf4sfVgJ8fSGHGME83VgWTzH7WeH9iM4be1mqu0i57
 M13C4WfRNw3gSYhopoZ7/IKOsbq9g0ze8/aFWdSJDzmmZAMmgnW+1ub/mvBIN6sz
 U0AO5wbYylWDydNXic/WtE1vZOt0gmuT6JuQExZPmIxIGVwn1Sq45I3JqtlD2H0A
 z3ja8zwIWxTSvs0vWVZP5+xRT7G2jDbjBv2Jhe1K14RkFU3eMvYatlCDPkJ2xWj5
 9WlZo8zai/Go5m44mqQ2AGHoo2/KvWqILNqVBmoOxU8Poa/lmGMCoY6PbVbXSsSN
 CO5YsIcfVdspyJOWH7UCdBYEWBU1NhaTo6VyUMPK5yZefm5Mpm+fnJCy8qOTvOHq
 cpEPvDRR4Oq9c4/s/dTu7vbCdF54biXEFS0brhuLp5P36EI6xihGmKn6zgPEpYyA
 eAD+uBqHxFvgh4DQJOE3olia/41MNDGs1HKD0lq+vigv7HIer1NK0Q62INPU1+7c
 hn7kxN622+DyTkSfTl4Aoeakiqn3QI049YYAzwHsnCF9vu1G9Qx2l1B91TBuyirk
 G6XxZVy2NK7yJoN47un9aQLoWTQnltlgU2CdpbbzugoK6o74NFfOUuDDI3HMb3rd
 hbtRSOjTqQ==
 =9rAj
 -----END PGP SIGNATURE-----

Merge tag 'io_uring-6.7-2023-11-17' of git://git.kernel.dk/linux

Pull io_uring fix from Jens Axboe:
 "Just a single fixup for a change we made in this release, which caused
  a regression in sometimes missing fdinfo output if the SQPOLL thread
  had the lock held when fdinfo output was retrieved.

  This brings us back on par with what we had before, where just the
  main uring_lock will prevent that output. We'd love to get rid of that
  too, but that is beyond the scope of this release and will have to
  wait for 6.8"

* tag 'io_uring-6.7-2023-11-17' of git://git.kernel.dk/linux:
  io_uring/fdinfo: remove need for sqpoll lock for thread/pid retrieval
This commit is contained in:
Linus Torvalds 2023-11-17 14:03:18 -08:00
commit 0e413c2a73
2 changed files with 12 additions and 9 deletions

View file

@ -145,13 +145,8 @@ __cold void io_uring_show_fdinfo(struct seq_file *m, struct file *f)
if (has_lock && (ctx->flags & IORING_SETUP_SQPOLL)) {
struct io_sq_data *sq = ctx->sq_data;
if (mutex_trylock(&sq->lock)) {
if (sq->thread) {
sq_pid = task_pid_nr(sq->thread);
sq_cpu = task_cpu(sq->thread);
}
mutex_unlock(&sq->lock);
}
sq_pid = sq->task_pid;
sq_cpu = sq->sq_cpu;
}
seq_printf(m, "SqThread:\t%d\n", sq_pid);

View file

@ -214,6 +214,7 @@ static bool io_sqd_handle_event(struct io_sq_data *sqd)
did_sig = get_signal(&ksig);
cond_resched();
mutex_lock(&sqd->lock);
sqd->sq_cpu = raw_smp_processor_id();
}
return did_sig || test_bit(IO_SQ_THREAD_SHOULD_STOP, &sqd->state);
}
@ -229,10 +230,15 @@ static int io_sq_thread(void *data)
snprintf(buf, sizeof(buf), "iou-sqp-%d", sqd->task_pid);
set_task_comm(current, buf);
if (sqd->sq_cpu != -1)
/* reset to our pid after we've set task_comm, for fdinfo */
sqd->task_pid = current->pid;
if (sqd->sq_cpu != -1) {
set_cpus_allowed_ptr(current, cpumask_of(sqd->sq_cpu));
else
} else {
set_cpus_allowed_ptr(current, cpu_online_mask);
sqd->sq_cpu = raw_smp_processor_id();
}
mutex_lock(&sqd->lock);
while (1) {
@ -261,6 +267,7 @@ static int io_sq_thread(void *data)
mutex_unlock(&sqd->lock);
cond_resched();
mutex_lock(&sqd->lock);
sqd->sq_cpu = raw_smp_processor_id();
}
continue;
}
@ -294,6 +301,7 @@ static int io_sq_thread(void *data)
mutex_unlock(&sqd->lock);
schedule();
mutex_lock(&sqd->lock);
sqd->sq_cpu = raw_smp_processor_id();
}
list_for_each_entry(ctx, &sqd->ctx_list, sqd_list)
atomic_andnot(IORING_SQ_NEED_WAKEUP,