From: Jens Axboe <[email protected]>
To: Pavel Begunkov <[email protected]>, [email protected]
Subject: Re: [PATCH 1/1] io_uring: break iopolling on signal
Date: Wed, 9 Aug 2023 09:30:43 -0600 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <eeba551e82cad12af30c3220125eb6cb244cc94c.1691594339.git.asml.silence@gmail.com>
On 8/9/23 9:20 AM, Pavel Begunkov wrote:
> Don't keep spinning iopoll with a signal set. It'll eventually return
> back, e.g. by virtue of need_resched(), but it's not a nice user
> experience.
I wonder if we shouldn't clean it up a bit while at it, the ret clearing
is kind of odd and only used in that one loop? Makes the break
conditions easier to read too, and makes it clear that we're returning
0/-error rather than zero-or-positive/-error as well.
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 8681bde70716..ec575f663a82 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -1637,7 +1637,6 @@ static __cold void io_iopoll_try_reap_events(struct io_ring_ctx *ctx)
static int io_iopoll_check(struct io_ring_ctx *ctx, long min)
{
unsigned int nr_events = 0;
- int ret = 0;
unsigned long check_cq;
if (!io_allowed_run_tw(ctx))
@@ -1663,6 +1662,8 @@ static int io_iopoll_check(struct io_ring_ctx *ctx, long min)
return 0;
do {
+ int ret = 0;
+
/*
* If a submit got punted to a workqueue, we can have the
* application entering polling for a command before it gets
@@ -1692,12 +1693,16 @@ static int io_iopoll_check(struct io_ring_ctx *ctx, long min)
}
ret = io_do_iopoll(ctx, !min);
if (ret < 0)
- break;
+ return ret;
nr_events += ret;
- ret = 0;
- } while (nr_events < min && !need_resched());
- return ret;
+ if (task_sigpending(current))
+ return -EINTR;
+ if (need_resched())
+ break;
+ } while (nr_events < min);
+
+ return 0;
}
void io_req_task_complete(struct io_kiocb *req, struct io_tw_state *ts)
--
Jens Axboe
next prev parent reply other threads:[~2023-08-09 15:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-09 15:20 [PATCH 1/1] io_uring: break iopolling on signal Pavel Begunkov
2023-08-09 15:30 ` Jens Axboe [this message]
2023-08-09 15:38 ` Pavel Begunkov
2023-08-09 15:50 ` Jens Axboe
2023-08-09 15:58 ` Pavel Begunkov
2023-08-09 16:01 ` Jens Axboe
2023-08-09 16:01 ` Pavel Begunkov
2023-08-09 16:05 ` Jens Axboe
2023-08-09 16:18 ` Jens Axboe
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 \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/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