queue: add opt-in requeue helper for SQ_REWIND - #1626
Conversation
|
I don't think this should be done by default on a short submit. We might not want to requeue, in which case relocating the requests would be a waste of time. Perhaps the relocation could be exposed as a helper in io_uring and let userspace call it if they want. |
A short IORING_SETUP_SQ_REWIND submission leaves any unconsumed entries after the returned count, while liburing resets its local tail before entering the kernel. Retrying those entries requires moving them back to index zero. Add io_uring_sq_requeue() so applications can opt into that relocation after a short or failed submit. Keep the default short-submit policy unchanged. Stop submission-and-wait helpers from internally resubmitting an unrelocated SQ_REWIND remainder, which would otherwise submit already-consumed slots again. Cover the default and opt-in policies, ordinary and fixed 128-byte SQEs, timed submission without duplicate completions, failed submission, and the regular-ring control. Fixes: c22129c ("src/queue: Add support for non circular SQ") Signed-off-by: Darren Carreras <283775510+carrerasdarren-cell@users.noreply.github.com>
a6800c4 to
11051b1
Compare
|
Agreed. I updated the patch so a short I also stopped the submission-and-wait loop from internally submitting an unrelocated remainder, since that can resubmit the already-consumed prefix. The revised regression covers both policies, partial and failed submits, fixed 128-byte SQEs, and timed-submit duplicate detection. Normal and ASan/UBSan builds plus ten focused tests pass on Linux 7.0. I force-pushed the revised single commit. I am happy to adjust the helper name or signature if you prefer a different API shape. |
IORING_SETUP_SQ_REWINDclears liburing's local SQ tail before entering the kernel. If a submission is short, the caller may either abandon the unconsumed entries or choose to retry them. Retrying requires relocating those entries to the beginning of the SQ.This adds
io_uring_sq_requeue()as an explicit opt-in helper. The application recordsio_uring_sq_ready()before submission, then passes that count and the submission return value to the helper before acquiring any new SQEs.Submission-and-wait paths also stop internally resubmitting an unrelocated
SQ_REWINDremainder. Without that guard, a short timed submission can submit already-consumed slots again.The regression covers:
Validation: