io_uring: pre-initialise some of req fields
authorPavel Begunkov <asml.silence@gmail.com>
Sat, 26 Jun 2021 20:40:49 +0000 (21:40 +0100)
committerJens Axboe <axboe@kernel.dk>
Wed, 30 Jun 2021 20:15:40 +0000 (14:15 -0600)
commit99ebe4efbd3882422db1fd6a1b477291ea8bdab7
treeaadeb6e8c2b16ed616bc351e24b1a28040221640
parent5182ed2e332e8e11fa3c1649ef6d6546ccca64d0
io_uring: pre-initialise some of req fields

Most of requests are allocated from an internal cache, so it's waste of
time fully initialising them every time. Instead, let's pre-init some of
the fields we can during initial allocation (e.g. kmalloc(), see
io_alloc_req()) and keep them valid on request recycling. There are four
of them in this patch:

->ctx is always stays the same
->link is NULL on free, it's an invariant
->result is not even needed to init, just a precaution
->async_data we now clean in io_dismantle_req() as it's likely to
   never be allocated.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/892ba0e71309bba9fe9e0142472330bbf9d8f05d.1624739600.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c