mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 00:04:15 +08:00
eventfd: Export eventfd_ctx_do_read()
[ Upstream commit28f1326710
] Where events are consumed in the kernel, for example by KVM's irqfd_wakeup() and VFIO's virqfd_wakeup(), they currently lack a mechanism to drain the eventfd's counter. Since the wait queue is already locked while the wakeup functions are invoked, all they really need to do is call eventfd_ctx_do_read(). Add a check for the lock, and export it for them. Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> Message-Id: <20201027135523.646811-2-dwmw2@infradead.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Stable-dep-of:758b492047
("eventfd: prevent underflow for eventfd semaphores") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
6b5d585e23
commit
755e86f28a
@ -187,11 +187,14 @@ static __poll_t eventfd_poll(struct file *file, poll_table *wait)
|
||||
return events;
|
||||
}
|
||||
|
||||
static void eventfd_ctx_do_read(struct eventfd_ctx *ctx, __u64 *cnt)
|
||||
void eventfd_ctx_do_read(struct eventfd_ctx *ctx, __u64 *cnt)
|
||||
{
|
||||
lockdep_assert_held(&ctx->wqh.lock);
|
||||
|
||||
*cnt = (ctx->flags & EFD_SEMAPHORE) ? 1 : ctx->count;
|
||||
ctx->count -= *cnt;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(eventfd_ctx_do_read);
|
||||
|
||||
/**
|
||||
* eventfd_ctx_remove_wait_queue - Read the current counter and removes wait queue.
|
||||
|
@ -42,6 +42,7 @@ __u64 eventfd_signal(struct eventfd_ctx *ctx, __u64 n);
|
||||
__u64 eventfd_signal_mask(struct eventfd_ctx *ctx, __u64 n, unsigned mask);
|
||||
int eventfd_ctx_remove_wait_queue(struct eventfd_ctx *ctx, wait_queue_entry_t *wait,
|
||||
__u64 *cnt);
|
||||
void eventfd_ctx_do_read(struct eventfd_ctx *ctx, __u64 *cnt);
|
||||
|
||||
DECLARE_PER_CPU(int, eventfd_wake_count);
|
||||
|
||||
@ -89,6 +90,11 @@ static inline bool eventfd_signal_count(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline void eventfd_ctx_do_read(struct eventfd_ctx *ctx, __u64 *cnt)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _LINUX_EVENTFD_H */
|
||||
|
Loading…
Reference in New Issue
Block a user