diff mbox series

[for-next,1/5] io_uring: return back links tw run optimisation

Message ID 6328acdbb5e60efc762b18003382de077e6e1367.1673887636.git.asml.silence@gmail.com (mailing list archive)
State New
Headers show
Series random for-next patches | expand

Commit Message

Pavel Begunkov Jan. 16, 2023, 4:48 p.m. UTC
io_submit_flush_completions() may queue new requests for tw execution,
especially true for linked requests. Recheck the tw list for emptiness
after flushing completions.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 io_uring/io_uring.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Jens Axboe Jan. 16, 2023, 6:43 p.m. UTC | #1
On 1/16/23 9:48 AM, Pavel Begunkov wrote:
> io_submit_flush_completions() may queue new requests for tw execution,
> especially true for linked requests. Recheck the tw list for emptiness
> after flushing completions.

Did you check when it got lost? Would be nice to add a Fixes link?
Pavel Begunkov Jan. 16, 2023, 7:47 p.m. UTC | #2
On 1/16/23 18:43, Jens Axboe wrote:
> On 1/16/23 9:48 AM, Pavel Begunkov wrote:
>> io_submit_flush_completions() may queue new requests for tw execution,
>> especially true for linked requests. Recheck the tw list for emptiness
>> after flushing completions.
> 
> Did you check when it got lost? Would be nice to add a Fixes link?

fwiw, not fan of putting a "Fixes" tag on sth that is not a fix.

Looks like the optimisation was there for normal task_work, then
disappeared in f88262e60bb9c ("io_uring: lockless task list").
DEFERRED_TASKRUN came later and this patch handles exclusively
deferred tw. I probably need to send a patch for normal tw as well.
Jens Axboe Jan. 16, 2023, 9:04 p.m. UTC | #3
On 1/16/23 12:47 PM, Pavel Begunkov wrote:
> On 1/16/23 18:43, Jens Axboe wrote:
>> On 1/16/23 9:48 AM, Pavel Begunkov wrote:
>>> io_submit_flush_completions() may queue new requests for tw execution,
>>> especially true for linked requests. Recheck the tw list for emptiness
>>> after flushing completions.
>>
>> Did you check when it got lost? Would be nice to add a Fixes link?
> 
> fwiw, not fan of putting a "Fixes" tag on sth that is not a fix.

I'm not either as it isn't fully descriptive, but it is better than
not having that reference imho.

> Looks like the optimisation was there for normal task_work, then
> disappeared in f88262e60bb9c ("io_uring: lockless task list").
> DEFERRED_TASKRUN came later and this patch handles exclusively
> deferred tw. I probably need to send a patch for normal tw as well.

So maybe just use that commit? I can make a note in the message on
how it relates.
Pavel Begunkov Jan. 16, 2023, 9:14 p.m. UTC | #4
On 1/16/23 21:04, Jens Axboe wrote:
> On 1/16/23 12:47 PM, Pavel Begunkov wrote:
>> On 1/16/23 18:43, Jens Axboe wrote:
>>> On 1/16/23 9:48 AM, Pavel Begunkov wrote:
>>>> io_submit_flush_completions() may queue new requests for tw execution,
>>>> especially true for linked requests. Recheck the tw list for emptiness
>>>> after flushing completions.
>>>
>>> Did you check when it got lost? Would be nice to add a Fixes link?
>>
>> fwiw, not fan of putting a "Fixes" tag on sth that is not a fix.
> 
> I'm not either as it isn't fully descriptive, but it is better than
> not having that reference imho.

Agree, but it's also not great that it might be tried to be
backported. Maybe adding a link would be nicer?

Link: https://lore.kernel.org/r/20220622134028.2013417-4-dylany@fb.com


>> Looks like the optimisation was there for normal task_work, then
>> disappeared in f88262e60bb9c ("io_uring: lockless task list").
>> DEFERRED_TASKRUN came later and this patch handles exclusively
>> deferred tw. I probably need to send a patch for normal tw as well.
> 
> So maybe just use that commit? I can make a note in the message on
> how it relates.
Pavel Begunkov Jan. 16, 2023, 9:15 p.m. UTC | #5
On 1/16/23 21:04, Jens Axboe wrote:
> On 1/16/23 12:47 PM, Pavel Begunkov wrote:
>> On 1/16/23 18:43, Jens Axboe wrote:
>>> On 1/16/23 9:48 AM, Pavel Begunkov wrote:
>>>> io_submit_flush_completions() may queue new requests for tw execution,
>>>> especially true for linked requests. Recheck the tw list for emptiness
>>>> after flushing completions.
>>>
>>> Did you check when it got lost? Would be nice to add a Fixes link?
>>
>> fwiw, not fan of putting a "Fixes" tag on sth that is not a fix.
> 
> I'm not either as it isn't fully descriptive, but it is better than
> not having that reference imho.
> 
>> Looks like the optimisation was there for normal task_work, then
>> disappeared in f88262e60bb9c ("io_uring: lockless task list").
>> DEFERRED_TASKRUN came later and this patch handles exclusively
>> deferred tw. I probably need to send a patch for normal tw as well.
> 
> So maybe just use that commit? I can make a note in the message on
> how it relates.

Yes please, thanks
Jens Axboe Jan. 16, 2023, 9:17 p.m. UTC | #6
On 1/16/23 2:14 PM, Pavel Begunkov wrote:
> On 1/16/23 21:04, Jens Axboe wrote:
>> On 1/16/23 12:47 PM, Pavel Begunkov wrote:
>>> On 1/16/23 18:43, Jens Axboe wrote:
>>>> On 1/16/23 9:48 AM, Pavel Begunkov wrote:
>>>>> io_submit_flush_completions() may queue new requests for tw execution,
>>>>> especially true for linked requests. Recheck the tw list for emptiness
>>>>> after flushing completions.
>>>>
>>>> Did you check when it got lost? Would be nice to add a Fixes link?
>>>
>>> fwiw, not fan of putting a "Fixes" tag on sth that is not a fix.
>>
>> I'm not either as it isn't fully descriptive, but it is better than
>> not having that reference imho.
> 
> Agree, but it's also not great that it might be tried to be
> backported. Maybe adding a link would be nicer?
> 
> Link: https://lore.kernel.org/r/20220622134028.2013417-4-dylany@fb.com

Only the auto-select bot would pick it, but I'm guessing it'll fail
and that'll be the end of that. Normal stable additions need a
cc stable as well, the fixes is not enough to trigger that.
Jens Axboe Jan. 16, 2023, 9:18 p.m. UTC | #7
On 1/16/23 2:15 PM, Pavel Begunkov wrote:
> On 1/16/23 21:04, Jens Axboe wrote:
>> On 1/16/23 12:47 PM, Pavel Begunkov wrote:
>>> On 1/16/23 18:43, Jens Axboe wrote:
>>>> On 1/16/23 9:48 AM, Pavel Begunkov wrote:
>>>>> io_submit_flush_completions() may queue new requests for tw execution,
>>>>> especially true for linked requests. Recheck the tw list for emptiness
>>>>> after flushing completions.
>>>>
>>>> Did you check when it got lost? Would be nice to add a Fixes link?
>>>
>>> fwiw, not fan of putting a "Fixes" tag on sth that is not a fix.
>>
>> I'm not either as it isn't fully descriptive, but it is better than
>> not having that reference imho.
>>
>>> Looks like the optimisation was there for normal task_work, then
>>> disappeared in f88262e60bb9c ("io_uring: lockless task list").
>>> DEFERRED_TASKRUN came later and this patch handles exclusively
>>> deferred tw. I probably need to send a patch for normal tw as well.
>>
>> So maybe just use that commit? I can make a note in the message on
>> how it relates.
> 
> Yes please, thanks

Done:

https://git.kernel.dk/cgit/linux-block/commit/?h=for-6.3/io_uring&id=b48f4ef033089cf03c28bb09ae054dbfdf11635a
diff mbox series

Patch

diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 718f56baecbd..5570422dc2fb 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -1344,8 +1344,11 @@  static int __io_run_local_work(struct io_ring_ctx *ctx, bool *locked)
 
 	if (!llist_empty(&ctx->work_llist))
 		goto again;
-	if (*locked)
+	if (*locked) {
 		io_submit_flush_completions(ctx);
+		if (!llist_empty(&ctx->work_llist))
+			goto again;
+	}
 	trace_io_uring_local_work_run(ctx, ret, loops);
 	return ret;
 }