From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>,
[email protected], [email protected]
Subject: [PATCH 3/3] io-wq: hash dependant works
Date: Sat, 14 Mar 2020 00:31:05 +0300 [thread overview]
Message-ID: <395f8af8d6133c69cb7a6ef2082e4d7a5c08e8d8.1584130466.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
Enable io-wq hashing stuff for dependant works simply by re-enqueueing
such requests.
Signed-off-by: Pavel Begunkov <[email protected]>
---
fs/io-wq.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/fs/io-wq.c b/fs/io-wq.c
index e26ceef53cbd..9541df2729de 100644
--- a/fs/io-wq.c
+++ b/fs/io-wq.c
@@ -375,11 +375,17 @@ static bool __io_worker_idle(struct io_wqe *wqe, struct io_worker *worker)
return __io_worker_unuse(wqe, worker);
}
-static struct io_wq_work *io_get_next_work(struct io_wqe *wqe, unsigned *hash)
+static inline unsigned int io_get_work_hash(struct io_wq_work *work)
+{
+ return work->flags >> IO_WQ_HASH_SHIFT;
+}
+
+static struct io_wq_work *io_get_next_work(struct io_wqe *wqe)
__must_hold(wqe->lock)
{
struct io_wq_work_node *node, *prev;
struct io_wq_work *work;
+ unsigned int hash;
wq_list_for_each(node, prev, &wqe->work_list) {
work = container_of(node, struct io_wq_work, list);
@@ -391,9 +397,9 @@ static struct io_wq_work *io_get_next_work(struct io_wqe *wqe, unsigned *hash)
}
/* hashed, can run if not already running */
- *hash = work->flags >> IO_WQ_HASH_SHIFT;
- if (!(wqe->hash_map & BIT(*hash))) {
- wqe->hash_map |= BIT(*hash);
+ hash = io_get_work_hash(work);
+ if (!(wqe->hash_map & BIT(hash))) {
+ wqe->hash_map |= BIT(hash);
wq_node_del(&wqe->work_list, node, prev);
return work;
}
@@ -470,15 +476,17 @@ static void io_assign_current_work(struct io_worker *worker,
spin_unlock_irq(&worker->lock);
}
+static void io_wqe_enqueue(struct io_wqe *wqe, struct io_wq_work *work);
+
static void io_worker_handle_work(struct io_worker *worker)
__releases(wqe->lock)
{
struct io_wqe *wqe = worker->wqe;
struct io_wq *wq = wqe->wq;
- unsigned hash = -1U;
do {
struct io_wq_work *work;
+ unsigned int hash;
get_next:
/*
* If we got some work, mark us as busy. If we didn't, but
@@ -487,7 +495,7 @@ static void io_worker_handle_work(struct io_worker *worker)
* can't make progress, any work completion or insertion will
* clear the stalled flag.
*/
- work = io_get_next_work(wqe, &hash);
+ work = io_get_next_work(wqe);
if (work)
__io_worker_busy(wqe, worker, work);
else if (!wq_list_empty(&wqe->work_list))
@@ -511,11 +519,16 @@ static void io_worker_handle_work(struct io_worker *worker)
work->flags |= IO_WQ_WORK_CANCEL;
old_work = work;
+ hash = io_get_work_hash(work);
work->func(&work);
work = (old_work == work) ? NULL : work;
io_assign_current_work(worker, work);
wq->free_work(old_work);
+ if (work && io_wq_is_hashed(work)) {
+ io_wqe_enqueue(wqe, work);
+ work = NULL;
+ }
if (hash != -1U) {
spin_lock_irq(&wqe->lock);
wqe->hash_map &= ~BIT_ULL(hash);
--
2.24.0
next prev parent reply other threads:[~2020-03-13 21:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-13 21:31 [PATCH 0/3] support hashing for linked requests Pavel Begunkov
2020-03-13 21:31 ` [PATCH 1/3] io-wq: don't reshed if there is no work Pavel Begunkov
2020-03-13 21:31 ` [PATCH 2/3] io-wq: split hashing and enqueueing Pavel Begunkov
2020-03-13 21:31 ` Pavel Begunkov [this message]
2020-03-14 23:18 ` [PATCH 0/3] support hashing for linked requests Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=395f8af8d6133c69cb7a6ef2082e4d7a5c08e8d8.1584130466.git.asml.silence@gmail.com \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox