Skip to contentSkip to conversation

io_uring/eventfd: reset deferred signal state

PATCH Applied Yufan Chen 2 participants 2 messages May 3 – May 4 io_uring

lore
Share & tools
lore

Yufan Chen

author
#0 lore raw

PATCH 1/1 io_uring/eventfd: reset deferred signal state

From: Yufan Chen <[email protected]>

Recursive eventfd wakeups must defer io_uring eventfd signaling because eventfd_signal_mask() rejects reentry from eventfd wakeup handlers. The io_ev_fd ops bit tracks an outstanding deferred signal so that the same rcu_head is not queued twice.

That bit is only set today. Once the first deferred callback runs, later recursive notifications still see the bit set and skip queueing another deferred signal. This can leave new completions without a matching eventfd wake after the first recursive deferral.

Clear the pending bit before issuing the deferred signal. If the wakeup path recurses while the callback runs, a new signal can be queued for the next RCU grace period while the current callback keeps its reference until it returns.

---
 io_uring/eventfd.c | 1 +
 1 file changed, 1 insertion(+)
io_uring/eventfd.c +1 -0
index 3da028500f7..d656cc2a0b9 100644
@@ -43,6 +43,7 @@ static void io_eventfd_do_signal(struct rcu_head *rcu)
 {
 	struct io_ev_fd *ev_fd = container_of(rcu, struct io_ev_fd, rcu);
 
+	atomic_andnot(BIT(IO_EVENTFD_OP_SIGNAL_BIT), &ev_fd->ops);
 	eventfd_signal_mask(ev_fd->cq_ev_fd, EPOLL_URING_WAKE);
 	io_eventfd_put(ev_fd);
 }
Signature · 1 line
2.47.3
maintainer Applied
#1 lore raw
Quoted 11 lines · Yufan Chen

Recursive eventfd wakeups must defer io_uring eventfd signaling because eventfd_signal_mask() rejects reentry from eventfd wakeup handlers. The io_ev_fd ops bit tracks an outstanding deferred signal so that the same rcu_head is not queued twice.

That bit is only set today. Once the first deferred callback runs, later recursive notifications still see the bit set and skip queueing another deferred signal. This can leave new completions without a matching eventfd wake after the first recursive deferral.

[...]

Applied, thanks!

[1/1] io_uring/eventfd: reset deferred signal state

      commit: 0f32b6daa03ab8c1831f650d617f59447af31172

Best regards,

Signature · 1 line
Jens Axboe