Skip to content

Commit 800cda7

Browse files
Add IORING_SETUP_DEFER_TASKRUN flag.
DEFER_TASKRUN (kernel 6.1+, requires SINGLE_ISSUER) defers io_uring task work to the application thread rather than a kernel thread, reducing cross-CPU signaling overhead on the wakeup and completion paths. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 71ac5f8 commit 800cda7

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

ext/io/event/selector/uring.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,12 @@ VALUE IO_Event_Selector_URing_initialize(VALUE self, VALUE loop) {
267267
#ifdef IORING_SETUP_SINGLE_ISSUER
268268
flags |= IORING_SETUP_SINGLE_ISSUER;
269269
#endif
270+
// IORING_SETUP_DEFER_TASKRUN (kernel 6.1+, requires SINGLE_ISSUER): defer io_uring
271+
// task work to the application thread rather than a kernel thread, reducing
272+
// cross-CPU signaling overhead.
273+
#ifdef IORING_SETUP_DEFER_TASKRUN
274+
flags |= IORING_SETUP_DEFER_TASKRUN;
275+
#endif
270276

271277
int result = io_uring_queue_init(URING_ENTRIES, &selector->ring, flags);
272278

@@ -1290,6 +1296,9 @@ static int IO_Event_Selector_URing_supported_p(void) {
12901296
#ifdef IORING_SETUP_SINGLE_ISSUER
12911297
flags |= IORING_SETUP_SINGLE_ISSUER;
12921298
#endif
1299+
#ifdef IORING_SETUP_DEFER_TASKRUN
1300+
flags |= IORING_SETUP_DEFER_TASKRUN;
1301+
#endif
12931302

12941303
int result = io_uring_queue_init(32, &ring, flags);
12951304

0 commit comments

Comments
 (0)