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-5.8-2020-07-05' of git://git.kernel.dk/linux-block

Pull io_uring fix from Jens Axboe:
"Andres reported a regression with the fix that was merged earlier this
week, where his setup of using signals to interrupt io_uring CQ waits
no longer worked correctly.

Fix this, and also limit our use of TWA_SIGNAL to the case where we
need it, and continue using TWA_RESUME for task_work as before.

Since the original is marked for 5.7 stable, let's flush this one out
early"

* tag 'io_uring-5.8-2020-07-05' of git://git.kernel.dk/linux-block:
io_uring: fix regression with always ignoring signals in io_cqring_wait()

+22 -7
+22 -7
fs/io_uring.c
··· 4072 4072 int error; 4073 4073 }; 4074 4074 4075 - static int io_req_task_work_add(struct io_kiocb *req, struct callback_head *cb, 4076 - int notify) 4075 + static int io_req_task_work_add(struct io_kiocb *req, struct callback_head *cb) 4077 4076 { 4078 4077 struct task_struct *tsk = req->task; 4079 - int ret; 4078 + struct io_ring_ctx *ctx = req->ctx; 4079 + int ret, notify = TWA_RESUME; 4080 4080 4081 - if (req->ctx->flags & IORING_SETUP_SQPOLL) 4081 + /* 4082 + * SQPOLL kernel thread doesn't need notification, just a wakeup. 4083 + * If we're not using an eventfd, then TWA_RESUME is always fine, 4084 + * as we won't have dependencies between request completions for 4085 + * other kernel wait conditions. 4086 + */ 4087 + if (ctx->flags & IORING_SETUP_SQPOLL) 4082 4088 notify = 0; 4089 + else if (ctx->cq_ev_fd) 4090 + notify = TWA_SIGNAL; 4083 4091 4084 4092 ret = task_work_add(tsk, cb, notify); 4085 4093 if (!ret) ··· 4118 4110 * of executing it. We can't safely execute it anyway, as we may not 4119 4111 * have the needed state needed for it anyway. 4120 4112 */ 4121 - ret = io_req_task_work_add(req, &req->task_work, TWA_SIGNAL); 4113 + ret = io_req_task_work_add(req, &req->task_work); 4122 4114 if (unlikely(ret)) { 4123 4115 WRITE_ONCE(poll->canceled, true); 4124 4116 tsk = io_wq_get_task(req->ctx->io_wq); ··· 6209 6201 if (current->task_works) 6210 6202 task_work_run(); 6211 6203 if (signal_pending(current)) { 6212 - ret = -ERESTARTSYS; 6204 + if (current->jobctl & JOBCTL_TASK_WORK) { 6205 + spin_lock_irq(&current->sighand->siglock); 6206 + current->jobctl &= ~JOBCTL_TASK_WORK; 6207 + recalc_sigpending(); 6208 + spin_unlock_irq(&current->sighand->siglock); 6209 + continue; 6210 + } 6211 + ret = -EINTR; 6213 6212 break; 6214 6213 } 6215 6214 if (io_should_wake(&iowq, false)) ··· 6225 6210 } while (1); 6226 6211 finish_wait(&ctx->wait, &iowq.wq); 6227 6212 6228 - restore_saved_sigmask_unless(ret == -ERESTARTSYS); 6213 + restore_saved_sigmask_unless(ret == -EINTR); 6229 6214 6230 6215 return READ_ONCE(rings->cq.head) == READ_ONCE(rings->cq.tail) ? ret : 0; 6231 6216 }