[PATCH 3/3] io_uring/uring_cmd: avoid double indirect call in task work dispatch
Christoph Hellwig
hch at lst.de
Thu Oct 23 06:40:47 PDT 2025
On Wed, Oct 22, 2025 at 05:13:26PM -0600, Caleb Sander Mateos wrote:
> io_uring task work dispatch makes an indirect call to struct io_kiocb's
> io_task_work.func field to allow running arbitrary task work functions.
> In the uring_cmd case, this calls io_uring_cmd_work(), which immediately
> makes another indirect call to struct io_uring_cmd's task_work_cb field.
> Introduce a macro DEFINE_IO_URING_CMD_TASK_WORK() to define a
> io_req_tw_func_t function wrapping an io_uring_cmd_tw_t. Convert the
> io_uring_cmd_tw_t function to the io_req_tw_func_t function in
> io_uring_cmd_complete_in_task() and io_uring_cmd_do_in_task_lazy().
> Use DEFINE_IO_URING_CMD_TASK_WORK() to define a io_req_tw_func_t
> function for each existing io_uring_cmd_tw_t function. Now uring_cmd
> task work dispatch makes a single indirect call to the io_req_tw_func_t
> wrapper function, which can inline the io_uring_cmd_tw_t function. This
> also allows removing the task_work_cb field from struct io_uring_cmd,
> freeing up some additional storage space.
Please just open code the logic instead of the symbol-hiding multi-level
macro indirection. Everyone who will have to touch the code in the
future will thank you.
More information about the Linux-nvme
mailing list