diff options
author | Josef Bacik <josef@toxicpanda.com> | 2019-07-16 23:19:25 +0300 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2019-07-18 19:20:13 +0300 |
commit | a6d81d30d3cd87f85bfd922358eb18b8146c4925 (patch) | |
tree | 36ce9e58c5124c3d4308786a7e8daf3ea25ba1a2 /include/linux/wait.h | |
parent | b5e02b484d6f12112d49326bff2aecfccd2f518d (diff) | |
download | linux-a6d81d30d3cd87f85bfd922358eb18b8146c4925.tar.xz |
wait: add wq_has_single_sleeper helper
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@redhat.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'include/linux/wait.h')
-rw-r--r-- | include/linux/wait.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/wait.h b/include/linux/wait.h index b6f77cf60dd7..30c515520fb2 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h @@ -127,6 +127,19 @@ static inline int waitqueue_active(struct wait_queue_head *wq_head) } /** + * 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(struct wait_queue_head *wq_head) +{ + return list_is_singular(&wq_head->head); +} + +/** * wq_has_sleeper - check if there are any waiting processes * @wq_head: wait queue head * |