···25252626struct poll_table_struct;27272828-/* 2828+/*2929 * structures and helpers for f_op->poll implementations3030 */3131typedef void (*poll_queue_proc)(struct file *, wait_queue_head_t *, struct poll_table_struct *);32323333/*3434- * Do not touch the structure directly, use the access functions3535- * poll_does_not_wait() and poll_requested_events() instead.3434+ * Do not touch the structure directly, use the access function3535+ * poll_requested_events() instead.3636 */3737typedef struct poll_table_struct {3838 poll_queue_proc _qproc;···41414242static inline void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p)4343{4444- if (p && p->_qproc && wait_address)4444+ if (p && p->_qproc) {4545 p->_qproc(filp, wait_address, p);4646-}4747-4848-/*4949- * Return true if it is guaranteed that poll will not wait. This is the case5050- * if the poll() of another file descriptor in the set got an event, so there5151- * is no need for waiting.5252- */5353-static inline bool poll_does_not_wait(const poll_table *p)5454-{5555- return p == NULL || p->_qproc == NULL;4646+ /*4747+ * This memory barrier is paired in the wq_has_sleeper().4848+ * See the comment above prepare_to_wait(), we need to4949+ * ensure that subsequent tests in this thread can't be5050+ * reordered with __add_wait_queue() in _qproc() paths.5151+ */5252+ smp_mb();5353+ }5654}57555856/*
+7-10
include/net/sock.h
···22972297}2298229822992299/**23002300- * sock_poll_wait - place memory barrier behind the poll_wait call.23002300+ * sock_poll_wait - wrapper for the poll_wait call.23012301 * @filp: file23022302 * @sock: socket to wait on23032303 * @p: poll_table···23072307static inline void sock_poll_wait(struct file *filp, struct socket *sock,23082308 poll_table *p)23092309{23102310- if (!poll_does_not_wait(p)) {23112311- poll_wait(filp, &sock->wq.wait, p);23122312- /* We need to be sure we are in sync with the23132313- * socket flags modification.23142314- *23152315- * This memory barrier is paired in the wq_has_sleeper.23162316- */23172317- smp_mb();23182318- }23102310+ /* Provides a barrier we need to be sure we are in sync23112311+ * with the socket flags modification.23122312+ *23132313+ * This memory barrier is paired in the wq_has_sleeper.23142314+ */23152315+ poll_wait(filp, &sock->wq.wait, p);23192316}2320231723212318static inline void skb_set_hash_from_sk(struct sk_buff *skb, struct sock *sk)
+4-5
io_uring/io_uring.c
···2813281328142814 if (unlikely(!ctx->poll_activated))28152815 io_activate_pollwq(ctx);28162816-28172817- poll_wait(file, &ctx->poll_wq, wait);28182816 /*28192819- * synchronizes with barrier from wq_has_sleeper call in28202820- * io_commit_cqring28172817+ * provides mb() which pairs with barrier from wq_has_sleeper28182818+ * call in io_commit_cqring28212819 */28222822- smp_rmb();28202820+ poll_wait(file, &ctx->poll_wq, wait);28212821+28232822 if (!io_sqring_full(ctx))28242823 mask |= EPOLLOUT | EPOLLWRNORM;28252824