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/io-wq: eliminate redundant io_work_get_acct() calls

Instead of calling io_work_get_acct() again, pass acct to
io_wq_insert_work() and io_wq_remove_pending().

This atomic access in io_work_get_acct() was done under the
`acct->lock`, and optimizing it away reduces lock contention a bit.

Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
Link: https://lore.kernel.org/r/20250128133927.3989681-2-max.kellermann@ionos.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Max Kellermann and committed by
Jens Axboe
3c75635f 0ad2507d

+4 -5
+4 -5
io_uring/io-wq.c
··· 903 903 } while (work); 904 904 } 905 905 906 - static void io_wq_insert_work(struct io_wq *wq, struct io_wq_work *work) 906 + static void io_wq_insert_work(struct io_wq *wq, struct io_wq_acct *acct, struct io_wq_work *work) 907 907 { 908 - struct io_wq_acct *acct = io_work_get_acct(wq, work); 909 908 unsigned int hash; 910 909 struct io_wq_work *tail; 911 910 ··· 950 951 } 951 952 952 953 raw_spin_lock(&acct->lock); 953 - io_wq_insert_work(wq, work); 954 + io_wq_insert_work(wq, acct, work); 954 955 clear_bit(IO_ACCT_STALLED_BIT, &acct->flags); 955 956 raw_spin_unlock(&acct->lock); 956 957 ··· 1020 1021 } 1021 1022 1022 1023 static inline void io_wq_remove_pending(struct io_wq *wq, 1024 + struct io_wq_acct *acct, 1023 1025 struct io_wq_work *work, 1024 1026 struct io_wq_work_node *prev) 1025 1027 { 1026 - struct io_wq_acct *acct = io_work_get_acct(wq, work); 1027 1028 unsigned int hash = io_get_work_hash(work); 1028 1029 struct io_wq_work *prev_work = NULL; 1029 1030 ··· 1050 1051 work = container_of(node, struct io_wq_work, list); 1051 1052 if (!match->fn(work, match->data)) 1052 1053 continue; 1053 - io_wq_remove_pending(wq, work, prev); 1054 + io_wq_remove_pending(wq, acct, work, prev); 1054 1055 raw_spin_unlock(&acct->lock); 1055 1056 io_run_cancel(work, wq); 1056 1057 match->nr_pending++;