From: Pavel Begunkov <asml.silence@gmail.com>
To: Jens Axboe <axboe@kernel.dk>, Hao Xu <haoxu@linux.alibaba.com>
Cc: io-uring@vger.kernel.org, metze@samba.org,
Jiufei Xue <jiufei.xue@linux.alibaba.com>,
Joseph Qi <joseph.qi@linux.alibaba.com>
Subject: Re: [PATCH v3 RESEND] io_uring: add timeout support for io_uring_enter()
Date: Wed, 4 Nov 2020 19:27:00 +0000 [thread overview]
Message-ID: <fa632df8-28c8-a63f-e79a-5996344b8226@gmail.com> (raw)
In-Reply-To: <052a2b54-017f-8617-5d1a-074408d164fd@kernel.dk>
On 04/11/2020 18:32, Jens Axboe wrote:
> On 11/4/20 10:50 AM, Jens Axboe wrote:
>> +struct io_uring_getevents_arg {
>> + sigset_t *sigmask;
>> + struct __kernel_timespec *ts;
>> +};
>> +
>
> I missed that this is still not right, I did bring it up in your last
> posting though - you can't have pointers as a user API, since the size
> of the pointer will vary depending on whether this is a 32-bit or 64-bit
> arch (or 32-bit app running on 64-bit kernel).
Maybe it would be better
1) to kill this extra indirection?
struct io_uring_getevents_arg {
- sigset_t *sigmask;
- struct __kernel_timespec *ts;
+ sigset_t sigmask;
+ struct __kernel_timespec ts;
};
then,
sigset_t *sig = (...)arg;
__kernel_timespec* ts = (...)(arg + offset);
It'd spare us from IORING_ENTER_GETEVENTS_TIMEOUT but we'd need
to find a way to disable some of them. E.g. don't use sigmask when
user don't want it, but sigsz == sizeof(io_uring_getevents_arg),
and parsing would look like
switch (argsz) {
case sizeof(struct io_uring_getevents_arg): {
struct __kernel_timespec ts = argp + ts_offset;
...
}
fallthrough;
case sizeof(sig): {
const sigset_t __user *sig = argp;
...
break;
}
default:
return -EINVAL;
}
2) and move all the parsing into io_cqring_wait(). That sounds better
performance-wise.
>
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index 7e6945383907..2f533f6815ea 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -9158,8 +9158,8 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit,
> return -EINVAL;
> if (copy_from_user(&arg, argp, sizeof(arg)))
> return -EFAULT;
> - sig = arg.sigmask;
> - ts = arg.ts;
> + sig = u64_to_user_ptr(arg.sigmask);
> + ts = u64_to_user_ptr(arg.ts);
> } else {
> sig = (const sigset_t __user *)argp;
> ts = NULL;
> diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h
> index fefee28c3ed8..0b104891df68 100644
> --- a/include/uapi/linux/io_uring.h
> +++ b/include/uapi/linux/io_uring.h
> @@ -338,8 +338,8 @@ enum {
> };
>
> struct io_uring_getevents_arg {
> - sigset_t *sigmask;
> - struct __kernel_timespec *ts;
> + __u64 sigmask;
> + __u64 ts;
> };
>
> #endif
>
--
Pavel Begunkov
next prev parent reply other threads:[~2020-11-04 19:30 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-02 8:50 [PATCH v3] io_uring: add timeout support for io_uring_enter() Hao Xu
2020-11-03 2:54 ` [PATCH v3 RESEND] " Hao Xu
2020-11-04 17:50 ` Jens Axboe
2020-11-04 18:32 ` Jens Axboe
2020-11-04 19:06 ` Jens Axboe
2020-11-04 19:27 ` Pavel Begunkov [this message]
2020-11-04 19:34 ` Jens Axboe
2020-11-04 20:16 ` Pavel Begunkov
2020-11-04 20:28 ` Jens Axboe
2020-11-04 20:50 ` Jens Axboe
2020-11-04 21:20 ` Pavel Begunkov
2020-11-04 21:27 ` 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=fa632df8-28c8-a63f-e79a-5996344b8226@gmail.com \
--to=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=haoxu@linux.alibaba.com \
--cc=io-uring@vger.kernel.org \
--cc=jiufei.xue@linux.alibaba.com \
--cc=joseph.qi@linux.alibaba.com \
--cc=metze@samba.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.