summaryrefslogtreecommitdiff
path: root/io_uring
diff options
context:
space:
mode:
authorMax Kellermann <max.kellermann@ionos.com>2025-01-28 14:39:20 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-04-10 14:44:02 +0200
commitafde54f2901d7b18aeab30c680adab90d6bd8ca9 (patch)
treec6322c5210e35cc216edf03268672ee705e4bc5f /io_uring
parent0239da0f7b30644d54a6deca63c15c16fcd5ecce (diff)
downloadlinux-afde54f2901d7b18aeab30c680adab90d6bd8ca9.tar.gz
linux-afde54f2901d7b18aeab30c680adab90d6bd8ca9.tar.bz2
linux-afde54f2901d7b18aeab30c680adab90d6bd8ca9.zip
io_uring/io-wq: eliminate redundant io_work_get_acct() calls
[ Upstream commit 3c75635f8ed482300931327847c50068a865a648 ] 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> Stable-dep-of: 486ba4d84d62 ("io_uring/io-wq: do not use bogus hash value") Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'io_uring')
-rw-r--r--io_uring/io-wq.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/io_uring/io-wq.c b/io_uring/io-wq.c
index 91019b4d0308..f7d09698e43c 100644
--- a/io_uring/io-wq.c
+++ b/io_uring/io-wq.c
@@ -916,9 +916,8 @@ static void io_run_cancel(struct io_wq_work *work, struct io_wq *wq)
} while (work);
}
-static void io_wq_insert_work(struct io_wq *wq, struct io_wq_work *work)
+static void io_wq_insert_work(struct io_wq *wq, struct io_wq_acct *acct, struct io_wq_work *work)
{
- struct io_wq_acct *acct = io_work_get_acct(wq, work);
unsigned int hash;
struct io_wq_work *tail;
@@ -964,7 +963,7 @@ void io_wq_enqueue(struct io_wq *wq, struct io_wq_work *work)
}
raw_spin_lock(&acct->lock);
- io_wq_insert_work(wq, work);
+ io_wq_insert_work(wq, acct, work);
clear_bit(IO_ACCT_STALLED_BIT, &acct->flags);
raw_spin_unlock(&acct->lock);
@@ -1034,10 +1033,10 @@ static bool io_wq_worker_cancel(struct io_worker *worker, void *data)
}
static inline void io_wq_remove_pending(struct io_wq *wq,
+ struct io_wq_acct *acct,
struct io_wq_work *work,
struct io_wq_work_node *prev)
{
- struct io_wq_acct *acct = io_work_get_acct(wq, work);
unsigned int hash = io_get_work_hash(work);
struct io_wq_work *prev_work = NULL;
@@ -1064,7 +1063,7 @@ static bool io_acct_cancel_pending_work(struct io_wq *wq,
work = container_of(node, struct io_wq_work, list);
if (!match->fn(work, match->data))
continue;
- io_wq_remove_pending(wq, work, prev);
+ io_wq_remove_pending(wq, acct, work, prev);
raw_spin_unlock(&acct->lock);
io_run_cancel(work, wq);
match->nr_pending++;