Re: [PATCH 1/6] sched/wait: Add swq_has_sleepers()

From: Paolo Bonzini
Date: Wed Oct 11 2017 - 07:21:54 EST


On 11/10/2017 10:27, Peter Zijlstra wrote:
> On Tue, Sep 05, 2017 at 12:00:17PM -0700, Davidlohr Bueso wrote:
>> Which is the equivalent of what we have in regular waitqueues.
>> I'm not crazy about the name, but this also helps us get both
>> apis closer -- which iirc comes originally from the -net folks.
>
> I'm confused. I don't see anything like this in the original waitqueue.
>

/**
* wq_has_sleeper - check if there are any waiting processes
* @wq_head: wait queue head
*
* Returns true if wq_head has waiting processes
*
* Please refer to the comment for waitqueue_active.
*/
static inline bool wq_has_sleeper(struct wait_queue_head *wq_head)
{
/*
* We need to be sure we are in sync with the
* add_wait_queue modifications to the wait queue.
*
* This memory barrier should be paired with one on the
* waiting side.
*/
smp_mb();
return waitqueue_active(wq_head);
}

Paolo