diff mbox series

md: add check for sleepers in md_wakeup_thread()

Message ID 20240327114022.74634-1-jinpu.wang@ionos.com (mailing list archive)
State Accepted, archived
Headers show
Series md: add check for sleepers in md_wakeup_thread() | expand

Commit Message

Jinpu Wang March 27, 2024, 11:40 a.m. UTC
From: Florian-Ewald Mueller <florian-ewald.mueller@ionos.com>

Check for sleeping thread before attempting its wake_up in
md_wakeup_thread() to avoid unnecessary spinlock contention.

With a 6.1 kernel, fio random read/write tests on many (>= 100)
virtual volumes, of 100 GiB each, on 3 md-raid5s on 8 SSDs each
(building a raid50), show by 3 to 4 % improved IOPS performance.

Signed-off-by: Florian-Ewald Mueller <florian-ewald.mueller@ionos.com>
Reviewed-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Jack Wang <jinpu.wang@ionos.com>
---
 drivers/md/md.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Song Liu April 10, 2024, 9:36 p.m. UTC | #1
On Wed, Mar 27, 2024 at 4:40 AM Jack Wang <jinpu.wang@ionos.com> wrote:
>
> From: Florian-Ewald Mueller <florian-ewald.mueller@ionos.com>
>
> Check for sleeping thread before attempting its wake_up in
> md_wakeup_thread() to avoid unnecessary spinlock contention.
>
> With a 6.1 kernel, fio random read/write tests on many (>= 100)
> virtual volumes, of 100 GiB each, on 3 md-raid5s on 8 SSDs each
> (building a raid50), show by 3 to 4 % improved IOPS performance.
>
> Signed-off-by: Florian-Ewald Mueller <florian-ewald.mueller@ionos.com>
> Reviewed-by: Yu Kuai <yukuai3@huawei.com>
> Signed-off-by: Jack Wang <jinpu.wang@ionos.com>

Applied to md-6.10. Thanks!

Song
diff mbox series

Patch

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 7d7b982e369c..44253faa2633 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -8083,7 +8083,8 @@  void md_wakeup_thread(struct md_thread __rcu *thread)
 	if (t) {
 		pr_debug("md: waking up MD thread %s.\n", t->tsk->comm);
 		set_bit(THREAD_WAKEUP, &t->flags);
-		wake_up(&t->wqueue);
+		if (wq_has_sleeper(&t->wqueue))
+			wake_up(&t->wqueue);
 	}
 	rcu_read_unlock();
 }