[Devel] [PATCH RH7 08/12] wait: add wq_has_single_sleeper helper
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Thu Sep 29 14:30:08 MSK 2022
From: Josef Bacik <josef at toxicpanda.com>
rq-qos sits in the io path so we want to take locks as sparingly as
possible. To accomplish this we try not to take the waitqueue head lock
unless we are sure we need to go to sleep, and we have an optimization
to make sure that we don't starve out existing waiters. Since we check
if there are existing waiters locklessly we need to be able to update
our view of the waitqueue list after we've added ourselves to the
waitqueue. Accomplish this by adding this helper to see if there is
more than just ourselves on the list.
Reviewed-by: Oleg Nesterov <oleg at redhat.com>
Signed-off-by: Josef Bacik <josef at toxicpanda.com>
Signed-off-by: Jens Axboe <axboe at kernel.dk>
Changes porting to vz7:
- s/wait_queue_head/wait_queue_head_t/
https://jira.sw.ru/browse/PSBM-141883
(cherry picked from commit a6d81d30d3cd87f85bfd922358eb18b8146c4925)
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
fix
---
include/linux/wait.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/include/linux/wait.h b/include/linux/wait.h
index 2cd2201fc1e4..12075edebfd6 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -123,6 +123,19 @@ static inline int waitqueue_active(wait_queue_head_t *q)
return !list_empty(&q->task_list);
}
+/**
+ * wq_has_single_sleeper - check if there is only one sleeper
+ * @wq_head: wait queue head
+ *
+ * Returns true of wq_head has only one sleeper on the list.
+ *
+ * Please refer to the comment for waitqueue_active.
+ */
+static inline bool wq_has_single_sleeper(wait_queue_head_t *q)
+{
+ return list_is_singular(&q->task_list);
+}
+
/**
* wq_has_sleeper - check if there are any waiting processes
* @wq: wait queue head
--
2.37.1
More information about the Devel
mailing list