[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220408073916.1428590-9-yukuai3@huawei.com>
Date: Fri, 8 Apr 2022 15:39:16 +0800
From: Yu Kuai <yukuai3@...wei.com>
To: <axboe@...nel.dk>, <yukuai3@...wei.com>,
<andriy.shevchenko@...ux.intel.com>, <john.garry@...wei.com>,
<ming.lei@...hat.com>
CC: <linux-block@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<yi.zhang@...wei.com>
Subject: [PATCH -next RFC v2 8/8] sbitmap: wake up the number of threads based on required tags
Always wake up 'wake_batch' threads will intensify competition and
split io won't be issued continuously. Now that how many tags is required
is recorded for huge io, it's safe to wake up baed on required tags.
Signed-off-by: Yu Kuai <yukuai3@...wei.com>
---
lib/sbitmap.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/lib/sbitmap.c b/lib/sbitmap.c
index 8d01e02ea4b1..eac9fa5c2b4d 100644
--- a/lib/sbitmap.c
+++ b/lib/sbitmap.c
@@ -614,6 +614,26 @@ static inline void sbq_update_preemption(struct sbitmap_queue *sbq,
WRITE_ONCE(sbq->force_tag_preemption, force);
}
+static unsigned int get_wake_nr(struct sbq_wait_state *ws, unsigned int nr_tags)
+{
+ struct sbq_wait *wait;
+ struct wait_queue_entry *entry;
+ unsigned int nr = 1;
+
+ spin_lock_irq(&ws->wait.lock);
+ list_for_each_entry(entry, &ws->wait.head, entry) {
+ wait = container_of(entry, struct sbq_wait, wait);
+ if (nr_tags <= wait->nr_tags)
+ break;
+
+ nr++;
+ nr_tags -= wait->nr_tags;
+ }
+ spin_unlock_irq(&ws->wait.lock);
+
+ return nr;
+}
+
static bool __sbq_wake_up(struct sbitmap_queue *sbq)
{
struct sbq_wait_state *ws;
@@ -648,7 +668,7 @@ static bool __sbq_wake_up(struct sbitmap_queue *sbq)
smp_mb__before_atomic();
atomic_set(&ws->wait_cnt, wake_batch);
sbq_update_preemption(sbq, wake_batch);
- wake_up_nr(&ws->wait, wake_batch);
+ wake_up_nr(&ws->wait, get_wake_nr(ws, wake_batch));
return true;
}
--
2.31.1
Powered by blists - more mailing lists