/** * wait_queue_t of Linux (version < 2.6.34) is a FIFO list for exclusively * waiting threads, which is not always desirable because all threads will * be waken up again and again, even user only needs a few of them to be * active most time. This is not good for performance because cache can * be polluted by different threads. * * LIFO list can resolve this problem because we always wakeup the most * recent active thread by default. * * NB: please don't call non-exclusive & exclusive wait on the same * waitq if add_wait_queue_exclusive_head is used. */ void add_wait_queue_exclusive_head(wait_queue_head_t *waitq, wait_queue_t *link) { unsigned long flags; spin_lock_irqsave(&LINUX_WAITQ_HEAD(waitq)->lock, flags); __add_wait_queue_exclusive(LINUX_WAITQ_HEAD(waitq), LINUX_WAITQ(link)); spin_unlock_irqrestore(&LINUX_WAITQ_HEAD(waitq)->lock, flags); }
void cfs_waitq_init(cfs_waitq_t *waitq) { init_waitqueue_head(LINUX_WAITQ_HEAD(waitq)); }
void cfs_waitq_add_exclusive(cfs_waitq_t *waitq, cfs_waitlink_t *link) { add_wait_queue_exclusive(LINUX_WAITQ_HEAD(waitq), LINUX_WAITQ(link)); }
void cfs_waitq_broadcast(cfs_waitq_t *waitq) { wake_up_all(LINUX_WAITQ_HEAD(waitq)); }
void cfs_waitq_signal_nr(cfs_waitq_t *waitq, int nr) { wake_up_nr(LINUX_WAITQ_HEAD(waitq), nr); }
void cfs_waitq_signal(cfs_waitq_t *waitq) { wake_up(LINUX_WAITQ_HEAD(waitq)); }
int cfs_waitq_active(cfs_waitq_t *waitq) { return waitqueue_active(LINUX_WAITQ_HEAD(waitq)); }
void cfs_waitq_del(cfs_waitq_t *waitq, cfs_waitlink_t *link) { remove_wait_queue(LINUX_WAITQ_HEAD(waitq), LINUX_WAITQ(link)); }