Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'io_uring-6.6-2023-10-27' of git://git.kernel.dk/linux

Pull io_uring fixes from Jens Axboe:
"Fix for an issue reported where reading fdinfo could find a NULL
thread as we didn't properly synchronize, and then a disable for the
IOCB_DIO_CALLER_COMP optimization as a recent reported highlighted how
that could lead to deadlocks if the task issued async O_DIRECT writes
and then proceeded to do sync fallocate() calls"

* tag 'io_uring-6.6-2023-10-27' of git://git.kernel.dk/linux:
io_uring/rw: disable IOCB_DIO_CALLER_COMP
io_uring/fdinfo: lock SQ thread while retrieving thread cpu/pid

+12 -15
+12 -6
io_uring/fdinfo.c
··· 53 53 __cold void io_uring_show_fdinfo(struct seq_file *m, struct file *f) 54 54 { 55 55 struct io_ring_ctx *ctx = f->private_data; 56 - struct io_sq_data *sq = NULL; 57 56 struct io_overflow_cqe *ocqe; 58 57 struct io_rings *r = ctx->rings; 59 58 unsigned int sq_mask = ctx->sq_entries - 1, cq_mask = ctx->cq_entries - 1; ··· 63 64 unsigned int cq_shift = 0; 64 65 unsigned int sq_shift = 0; 65 66 unsigned int sq_entries, cq_entries; 67 + int sq_pid = -1, sq_cpu = -1; 66 68 bool has_lock; 67 69 unsigned int i; 68 70 ··· 143 143 has_lock = mutex_trylock(&ctx->uring_lock); 144 144 145 145 if (has_lock && (ctx->flags & IORING_SETUP_SQPOLL)) { 146 - sq = ctx->sq_data; 147 - if (!sq->thread) 148 - sq = NULL; 146 + struct io_sq_data *sq = ctx->sq_data; 147 + 148 + if (mutex_trylock(&sq->lock)) { 149 + if (sq->thread) { 150 + sq_pid = task_pid_nr(sq->thread); 151 + sq_cpu = task_cpu(sq->thread); 152 + } 153 + mutex_unlock(&sq->lock); 154 + } 149 155 } 150 156 151 - seq_printf(m, "SqThread:\t%d\n", sq ? task_pid_nr(sq->thread) : -1); 152 - seq_printf(m, "SqThreadCpu:\t%d\n", sq ? task_cpu(sq->thread) : -1); 157 + seq_printf(m, "SqThread:\t%d\n", sq_pid); 158 + seq_printf(m, "SqThreadCpu:\t%d\n", sq_cpu); 153 159 seq_printf(m, "UserFiles:\t%u\n", ctx->nr_user_files); 154 160 for (i = 0; has_lock && i < ctx->nr_user_files; i++) { 155 161 struct file *f = io_file_from_index(&ctx->file_table, i);
-9
io_uring/rw.c
··· 913 913 kiocb_start_write(kiocb); 914 914 kiocb->ki_flags |= IOCB_WRITE; 915 915 916 - /* 917 - * For non-polled IO, set IOCB_DIO_CALLER_COMP, stating that our handler 918 - * groks deferring the completion to task context. This isn't 919 - * necessary and useful for polled IO as that can always complete 920 - * directly. 921 - */ 922 - if (!(kiocb->ki_flags & IOCB_HIPRI)) 923 - kiocb->ki_flags |= IOCB_DIO_CALLER_COMP; 924 - 925 916 if (likely(req->file->f_op->write_iter)) 926 917 ret2 = call_write_iter(req->file, kiocb, &s->iter); 927 918 else if (req->file->f_op->write)