From: Stefan Roesch <shr@devkernel.io>
To: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Cc: Facebook Kernel Team <kernel-team@fb.com>,
Jens Axboe <axboe@kernel.dk>,
Olivier Langlois <olivier@trillion01.com>,
netdev Mailing List <netdev@vger.kernel.org>,
io-uring Mailing List <io-uring@vger.kernel.org>,
Jakub Kicinski <kuba@kernel.org>
Subject: Re: [RFC PATCH v4 2/3] io_uring: add api to set / get napi configuration.
Date: Mon, 21 Nov 2022 10:56:39 -0800 [thread overview]
Message-ID: <qvqwwn7o3zlv.fsf@dev0134.prn3.facebook.com> (raw)
In-Reply-To: <2dde9961-b820-c301-6eb7-c5a26309c019@gnuweeb.org>
Ammar Faizi <ammarfaizi2@gnuweeb.org> writes:
> On 11/22/22 12:29 AM, Stefan Roesch wrote:
>> +static int io_register_napi(struct io_ring_ctx *ctx, void __user *arg)
>> +{
>> +#ifdef CONFIG_NET_RX_BUSY_POLL
>> + const struct io_uring_napi curr = {
>> + .busy_poll_to = ctx->napi_busy_poll_to,
>> + };
>> + struct io_uring_napi *napi;
>> +
>> + napi = memdup_user(arg, sizeof(*napi));
>> + if (IS_ERR(napi))
>> + return PTR_ERR(napi);
>> +
>> + WRITE_ONCE(ctx->napi_busy_poll_to, napi->busy_poll_to);
>> +
>> + kfree(napi);
>> +
>> + if (copy_to_user(arg, &curr, sizeof(curr)))
>> + return -EFAULT;
>> +
>> + return 0;
>
> Considering:
>
> 1) `struct io_uring_napi` is 16 bytes in size.
>
> 2) The lifetime of `struct io_uring_napi *napi;` is brief.
>
> There is no need to use memdup_user() and kfree(). You can place it
> on the stack and use copy_from_user() instead.
The next version of the patch will use copy_from_user.
next prev parent reply other threads:[~2022-11-21 18:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-21 17:29 [RFC PATCH v4 0/3] io_uring: add napi busy polling support Stefan Roesch
2022-11-21 17:29 ` [RFC PATCH v4 1/3] " Stefan Roesch
2022-11-21 17:29 ` [RFC PATCH v4 2/3] io_uring: add api to set / get napi configuration Stefan Roesch
2022-11-21 17:35 ` Jens Axboe
2022-11-21 18:55 ` Stefan Roesch
2022-11-21 17:37 ` Jens Axboe
2022-11-21 18:55 ` Stefan Roesch
2022-11-21 17:45 ` Ammar Faizi
2022-11-21 18:56 ` Stefan Roesch [this message]
2022-11-21 17:29 ` [RFC PATCH v4 3/3] io_uring: add api to set napi prefer busy poll Stefan Roesch
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=qvqwwn7o3zlv.fsf@dev0134.prn3.facebook.com \
--to=shr@devkernel.io \
--cc=ammarfaizi2@gnuweeb.org \
--cc=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
--cc=kernel-team@fb.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olivier@trillion01.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