Skip to content

Commit

Permalink
wait: add wq_has_single_sleeper helper
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Josef Bacik <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
josefbacik authored and axboe committed Jul 18, 2019
1 parent b5e02b4 commit a6d81d3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions include/linux/wait.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,19 @@ static inline int waitqueue_active(struct wait_queue_head *wq_head)
return !list_empty(&wq_head->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
Expand Down

0 comments on commit a6d81d3

Please sign in to comment.