Re: [PATCH 1/2] io_uring: clear TIF_NOTIFY_SIGNAL when running task work

From
Pavel Begunkov <asml.silence@gmail.com>
Date
2021-08-09 10:35:37
Also in
lkml
Reply to
Nadav Amit, 2021-08-09
On 8/9/21 5:50 AM, Nadav Amit wrote:
quoted
On Aug 8, 2021, at 9:07 PM, Hao Xu [off-list ref] wrote:
在 2021/8/9 上午1:31, Nadav Amit 写道:
quoted
quoted
On Aug 8, 2021, at 5:55 AM, Pavel Begunkov [off-list ref] wrote:
On 8/8/21 1:13 AM, Nadav Amit wrote:
quoted
From: Nadav Amit <redacted>

When using SQPOLL, the submission queue polling thread calls
task_work_run() to run queued work. However, when work is added with
TWA_SIGNAL - as done by io_uring itself - the TIF_NOTIFY_SIGNAL remains
static int io_req_task_work_add(struct io_kiocb *req)
{
	...
	notify = (req->ctx->flags & IORING_SETUP_SQPOLL) ? TWA_NONE : TWA_SIGNAL;
	if (!task_work_add(tsk, &tctx->task_work, notify))
	...
}

io_uring doesn't set TIF_NOTIFY_SIGNAL for SQPOLL. But if you see it, I'm
rather curious who does.
I was saying io-uring, but I meant io-uring in the wider sense:
io_queue_worker_create().
Here is a call trace for when TWA_SIGNAL is used. io_queue_worker_create()
uses TWA_SIGNAL. It is called by io_wqe_dec_running(), and not shown due
to inlining:
Hi Nadav, Pavel,
How about trying to make this kind of call to use TWA_NONE for sqthread,
though I know for this case currently there is no info to get to know if
task is sqthread. I think we shouldn't kick sqthread.
It is possible, but it would break the abstractions and propagating
it would be disgusting. Let me give it some thought.
We already do io_wq_enqueue() only from the right task context,
so in theory instead of pushing it through tw, we can create
a new thread on the spot. Though, would need to be careful
with locking.

Anyway, agree that it's better to be left for next.
Regardless, I think that this patch should go to 5.14 and stable,
and any solution to avoid kicking the SQ should come on top (to be
safe).
-- 
Pavel Begunkov
Thread (17 messages) 17 messages, 6 authors, last reply 2021-08-11
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help