Skip to contentSkip to conversation

md: add check for sleepers in md_wakeup_thread()

PATCH Applied Jack Wang 2 participants 2 messages Mar 27, 2024 – Apr 10, 2024 MD RAID

lore
Share & tools
lore

Jack Wang

author
#0 lore raw

PATCH 1/1 md: add check for sleepers in md_wakeup_thread()

From: Florian-Ewald Mueller <[email protected]>

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.

---
 drivers/md/md.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/md.c +2 -1
index 7d7b982e369c..44253faa2633 100644
@@ -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();
 }
Signature · 1 line
2.34.1
maintainer Applied
#1 lore raw
Quoted 6 lines · Jack Wang

From: Florian-Ewald Mueller <[email protected]>

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

Quoted 7 lines

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.

Applied to md-6.10. Thanks!

Song