On 3/26/24 18:42, Jens Axboe wrote:
Hi, This converts the deferred, normal, and fallback task_work to use a normal io_wq_work_list, rather than an llist. The main motivation behind this is to get rid of the need to reverse the list once it's deleted and run. I tested this basic conversion of just switching it from an llist to an io_wq_work_list with a spinlock, and I don't see any benefits from the lockless list. And for cases where we get a bursty addition of task_work, this approach is faster as it avoids the need to iterate the list upfront while reversing it.
I'm curious how you benchmarked it including accounting of irq/softirq where tw add usually happens? One known problem with the current list approach I mentioned several times before is that it peeks at the previous queued tw to count them. It's not nice, but that can be easily done with cmpxchg double. I wonder how much of an issue is that.
And this is less code and simpler, so I'd prefer to go that route.
I'm not sure it's less code, if you return optimisations that I believe were killed, see comments to patch 2, it might turn out to be even bulkier and not that simpler.
include/linux/io_uring_types.h | 13 +-- io_uring/io_uring.c | 175 ++++++++++++++++----------------- io_uring/io_uring.h | 8 +- io_uring/sqpoll.c | 8 +- io_uring/tctx.c | 3 +- 5 files changed, 102 insertions(+), 105 deletions(-)
-- Pavel Begunkov