Re: [PATCH 4/6] io_uring: switch normal task_work to a mpscq
Jens Axboe <[email protected]>
| Newsgroups | org.kernel.vger.io-uring |
|---|---|
| Message-ID | <[email protected]> |
On 6/15/26 2:40 PM, Caleb Sander Mateos wrote:
>> @@ -34,10 +34,6 @@ void io_tctx_fallback_work(struct work_struct *work)
>> fallback_work);
>> unsigned int count = 0;
>>
>> - /* see tctx_task_work() - a set bit must always have a run coming */
>> - clear_bit(0, &tctx->tw_pending);
>> - smp_mb__after_atomic();
>> -
>> /*
>> * Run the entries directly. We're in PF_KTHRED context, hence
>> * io_should_terminate_tw() is true and they will be marked as
>> @@ -101,6 +97,13 @@ void tctx_task_work_run(struct io_uring_task *tctx, unsigned int max_entries,
>> io_poll_task_func, io_req_rw_complete,
>> (struct io_tw_req){req}, ts);
>> (*count)++;
>> + /*
>> + * Break if most recent pop emptied the queue. This helps
>> + * bound task_work run, and also protects the regular
>> + * task_work addition.
>> + */
>> + if (mpscq_pop_emptied(&tctx->task_list, tctx->task_head))
>> + break;
>
> I think we can now remove the "if (mpscq_empty(&tctx->task_list))
> break;" above? The queue must be nonempty initially, otherwise the
> task work wouldn't have been scheduled. And if the queue is empty
> after an attempted pop, the previous iteration of this loop must have
> successfully marked the queue as empty.
We could, but then we'd need to special case the SQPOLL side. I think
it's better if we just leave it somewhat defensive as-is, it's just a
single compare anyway, non-atomic.
--
Jens Axboe