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.

io_uring/wq: avoid indirect do_work/free_work calls

struct io_wq stores do_work and free_work function pointers which are
called on each work item. But these function pointers are always set to
io_wq_submit_work and io_wq_free_work, respectively. So remove these
function pointers and just call the functions directly.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
Link: https://lore.kernel.org/r/20250329161527.3281314-1-csander@purestorage.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Caleb Sander Mateos and committed by
Jens Axboe
9fe99eed 9d7a0577

+5 -19
+4 -11
io_uring/io-wq.c
··· 114 114 struct io_wq { 115 115 unsigned long state; 116 116 117 - free_work_fn *free_work; 118 - io_wq_work_fn *do_work; 119 - 120 117 struct io_wq_hash *hash; 121 118 122 119 atomic_t worker_refs; ··· 609 612 if (do_kill && 610 613 (work_flags & IO_WQ_WORK_UNBOUND)) 611 614 atomic_or(IO_WQ_WORK_CANCEL, &work->flags); 612 - wq->do_work(work); 615 + io_wq_submit_work(work); 613 616 io_assign_current_work(worker, NULL); 614 617 615 - linked = wq->free_work(work); 618 + linked = io_wq_free_work(work); 616 619 work = next_hashed; 617 620 if (!work && linked && !io_wq_is_hashed(linked)) { 618 621 work = linked; ··· 931 934 { 932 935 do { 933 936 atomic_or(IO_WQ_WORK_CANCEL, &work->flags); 934 - wq->do_work(work); 935 - work = wq->free_work(work); 937 + io_wq_submit_work(work); 938 + work = io_wq_free_work(work); 936 939 } while (work); 937 940 } 938 941 ··· 1192 1195 int ret, i; 1193 1196 struct io_wq *wq; 1194 1197 1195 - if (WARN_ON_ONCE(!data->free_work || !data->do_work)) 1196 - return ERR_PTR(-EINVAL); 1197 1198 if (WARN_ON_ONCE(!bounded)) 1198 1199 return ERR_PTR(-EINVAL); 1199 1200 ··· 1201 1206 1202 1207 refcount_inc(&data->hash->refs); 1203 1208 wq->hash = data->hash; 1204 - wq->free_work = data->free_work; 1205 - wq->do_work = data->do_work; 1206 1209 1207 1210 ret = -ENOMEM; 1208 1211
-5
io_uring/io-wq.h
··· 21 21 IO_WQ_CANCEL_NOTFOUND, /* work not found */ 22 22 }; 23 23 24 - typedef struct io_wq_work *(free_work_fn)(struct io_wq_work *); 25 - typedef void (io_wq_work_fn)(struct io_wq_work *); 26 - 27 24 struct io_wq_hash { 28 25 refcount_t refs; 29 26 unsigned long map; ··· 36 39 struct io_wq_data { 37 40 struct io_wq_hash *hash; 38 41 struct task_struct *task; 39 - io_wq_work_fn *do_work; 40 - free_work_fn *free_work; 41 42 }; 42 43 43 44 struct io_wq *io_wq_create(unsigned bounded, struct io_wq_data *data);
+1 -1
io_uring/io_uring.c
··· 1812 1812 bool needs_poll = false; 1813 1813 int ret = 0, err = -ECANCELED; 1814 1814 1815 - /* one will be dropped by ->io_wq_free_work() after returning to io-wq */ 1815 + /* one will be dropped by io_wq_free_work() after returning to io-wq */ 1816 1816 if (!(req->flags & REQ_F_REFCOUNT)) 1817 1817 __io_req_set_refcount(req, 2); 1818 1818 else
-2
io_uring/tctx.c
··· 35 35 36 36 data.hash = hash; 37 37 data.task = task; 38 - data.free_work = io_wq_free_work; 39 - data.do_work = io_wq_submit_work; 40 38 41 39 /* Do QD, or 4 * CPUS, whatever is smallest */ 42 40 concurrency = min(ctx->sq_entries, 4 * num_online_cpus());