From: Bob Liu <bob.liu@oracle.com>
To: Jackie Liu <liuyun01@kylinos.cn>, axboe@kernel.dk
Cc: linux-block@vger.kernel.org
Subject: Re: [PATCH] io_uring: set -EINTR directly when a signal wakes up in io_cqring_wait
Date: Fri, 1 Nov 2019 10:14:43 +0800 [thread overview]
Message-ID: <bb55cf58-ce2f-23fe-67a6-c542a1e82f1e@oracle.com> (raw)
In-Reply-To: <1572319002-9943-1-git-send-email-liuyun01@kylinos.cn>
On 10/29/19 11:16 AM, Jackie Liu wrote:
> We didn't use -ERESTARTSYS to tell the application layer to restart the
> system call, but instead return -EINTR. we can set -EINTR directly when
> wakeup by the signal, which can help us save an assignment operation and
> comparison operation.
>
> Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
Looks good to me.
Reviewed-by: Bob Liu <bob.liu@oracle.com>
> ---
> fs/io_uring.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index a30c4f6..63eee7e 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -2878,7 +2878,7 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,
> .to_wait = min_events,
> };
> struct io_rings *rings = ctx->rings;
> - int ret;
> + int ret = 0;
>
> if (io_cqring_events(rings) >= min_events)
> return 0;
> @@ -2896,7 +2896,6 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,
> return ret;
> }
>
> - ret = 0;
> iowq.nr_timeouts = atomic_read(&ctx->cq_timeouts);
> do {
> prepare_to_wait_exclusive(&ctx->wait, &iowq.wq,
> @@ -2905,15 +2904,13 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,
> break;
> schedule();
> if (signal_pending(current)) {
> - ret = -ERESTARTSYS;
> + ret = -EINTR;
> break;
> }
> } while (1);
> finish_wait(&ctx->wait, &iowq.wq);
>
> - restore_saved_sigmask_unless(ret == -ERESTARTSYS);
> - if (ret == -ERESTARTSYS)
> - ret = -EINTR;
> + restore_saved_sigmask_unless(ret == -EINTR);
>
> return READ_ONCE(rings->cq.head) == READ_ONCE(rings->cq.tail) ? ret : 0;
> }
>
next prev parent reply other threads:[~2019-11-01 2:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-29 3:16 [PATCH] io_uring: set -EINTR directly when a signal wakes up in io_cqring_wait Jackie Liu
2019-11-01 2:14 ` Bob Liu [this message]
2019-11-01 14:37 ` 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 \
--in-reply-to=bb55cf58-ce2f-23fe-67a6-c542a1e82f1e@oracle.com \
--to=bob.liu@oracle.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=liuyun01@kylinos.cn \
/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;
as well as URLs for NNTP newsgroup(s).