Linux io-uring development
 help / color / mirror / Atom feed
From: Gabriel Krisman Bertazi <krisman@suse.de>
To: Prateek <kprateek283@gmail.com>, io-uring@vger.kernel.org
Cc: axboe@kernel.dk, Prateek <kprateek283@gmail.com>
Subject: Re: [PATCH 1/2] src/queue: don't swallow -ETIME when SQEs were submitted
Date: Tue, 14 Jul 2026 12:15:30 -0400	[thread overview]
Message-ID: <87fr1l4kf1.fsf@mailhost.krisman.be> (raw)
In-Reply-To: <20260712221049.534729-1-kprateek283@gmail.com>

Prateek <kprateek283@gmail.com> writes:

> If _io_uring_get_cqe() submits SQEs and then times out waiting for
> completions, it returns the submit count instead of -ETIME:
>
>   1. The first enter submits the SQEs; because submit > 0 the kernel
>      returns the submit count, not -ETIME, and it is stored in err.
>   2. On the next iteration the has_ts shortcut wants to report -ETIME,
>      but the 'if (!err)' guard sees the non-zero submit count and keeps
>      it, so -ETIME is dropped.
>
> That contradicts io_uring_submit_and_wait_timeout(3) and
> io_uring_wait_cqes(3), which document -ETIME on timeout.
>
> At these two sites (lines 113 and 118) err is only ever 0 or a positive
> submit count. A negative error from __io_uring_peek_cqe() or a prior
> enter breaks out of the loop before reaching here. So the change is
> functionally equivalent to dropping the err condition entirely; we change
> '!err' to 'err >= 0' so -ETIME is successfully synthesized whenever no
> CQE was seen.
>
> The guards were added in 2f61e849 ("src/queue: don't wait twice if
> looping in _io_uring_get_cqe()") to carry the submit count across
> iterations for the partial-completion case (got some CQEs, no error);
> that case still returns the count because both sites remain guarded by
> !cqe.
>
> Signed-off-by: Prateek <kprateek283@gmail.com>


Reviewed-by: Gabriel Krisman Bertazi <krisman@suse.de>

-- 
Gabriel Krisman Bertazi

      parent reply	other threads:[~2026-07-14 16:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-12 22:10 [PATCH 1/2] src/queue: don't swallow -ETIME when SQEs were submitted Prateek
2026-07-12 22:12 ` [PATCH 2/2] test/timeout-swallow: verify -ETIME is not swallowed Prateek
2026-07-14 16:20   ` Gabriel Krisman Bertazi
2026-07-14 16:15 ` Gabriel Krisman Bertazi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fr1l4kf1.fsf@mailhost.krisman.be \
    --to=krisman@suse.de \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=kprateek283@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox