From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH] io_uring: comment on kfree(iovec) checks
Date: Thu, 20 Aug 2020 11:34:10 +0300 [thread overview]
Message-ID: <7dd37adcb8a6fabd700205e2bcf62ccdc30681f3.1597912327.git.asml.silence@gmail.com> (raw)
kfree() handles NULL pointers well, but io_{read,write}() checks it
because of performance reasons. Leave a comment there for those who are
tempted to patch it.
Signed-off-by: Pavel Begunkov <[email protected]>
---
fs/io_uring.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 938112826dd1..ea2d1cb5c422 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -3204,6 +3204,7 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,
kiocb_done(kiocb, ret, cs);
ret = 0;
out_free:
+ /* it's reportedly faster than delegating the null check to kfree() */
if (iovec)
kfree(iovec);
return ret;
@@ -3300,6 +3301,7 @@ static int io_write(struct io_kiocb *req, bool force_nonblock,
return -EAGAIN;
}
out_free:
+ /* it's reportedly faster than delegating the null check to kfree() */
if (iovec)
kfree(iovec);
return ret;
--
2.24.0
next reply other threads:[~2020-08-20 8:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-20 8:34 Pavel Begunkov [this message]
2020-08-20 11:50 ` [PATCH] io_uring: comment on kfree(iovec) checks 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=7dd37adcb8a6fabd700205e2bcf62ccdc30681f3.1597912327.git.asml.silence@gmail.com \
[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