/* This is used to atomically remove a wait queue entry from the eventfd wait queue head, and read/reset the counter value.  */
int eventfd_ctx_remove_wait_queue(struct eventfd_ctx *ctx, wait_queue_t *wait, __u64 *cnt)
/* This is used to atomically remove a wait queue entry from the eventfd wait queue head, and read/reset the counter value.  */
int eventfd_ctx_remove_wait_queue(struct eventfd_ctx *ctx, wait_queue_t *wait, __u64 *cnt)
{
	unsigned long flags;
	spin_lock_irqsave(&ctx->wqh.lock, flags);
	eventfd_ctx_do_read(ctx, cnt);
	__remove_wait_queue(&ctx->wqh, wait);
	if (*cnt != 0 && waitqueue_active(&ctx->wqh))
		wake_up_locked_poll(&ctx->wqh, POLLOUT);
	spin_unlock_irqrestore(&ctx->wqh.lock, flags);
	return *cnt != 0 ? 0 : -EAGAIN;
}