ctx fields reshuffling pt1
cover ctx fields reshuffling pt1
First round of cleaning up struct io_ring_ctx fields. Just moving around, and only in a way that shouldn't hurt perfomance.
Pavel Begunkov (2):
io_uring: shuffle rarely used ctx fields to end
io_uring: localise fixed resources fields
fs/io_uring.c | 67 +++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 34 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/2 io_uring: shuffle rarely used ctx fields to end
There is a bunch of scattered around ctx fields that are almost never used, e.g. only on ring exit, plunge them to the end, better locality, better aesthetically.
--- fs/io_uring.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-)
fs/io_uring.c +17 -19
@@ -367,9 +367,6 @@ struct io_ring_ctx {unsigned cached_cq_overflow;unsigned long sq_check_overflow; -/* hashed buffered write serialization */ -struct io_wq_hash *hash_map; -struct list_head defer_list;struct list_head timeout_list;struct list_head cq_overflow_list;
@@ -386,9 +383,6 @@ struct io_ring_ctx {struct io_rings *rings; -/* Only used for accounting purposes */ -struct mm_struct *mm_account; -const struct cred *sq_creds;/* cred used for __io_sq_thread() */ struct io_sq_data *sq_data;/* if using sq thread polling */
@@ -409,14 +403,6 @@ struct io_ring_ctx {unsigned nr_user_bufs;struct io_mapped_ubuf **user_bufs; -struct user_struct *user; - -struct completion ref_comp; - -#if defined(CONFIG_UNIX ) -struct socket *ring_sock; -#endif -struct xarray io_buffers;struct xarray personalities;
@@ -460,12 +446,24 @@ struct io_ring_ctx {struct io_restriction restrictions; -/* exit task_work */ -struct callback_head *exit_task_work; -/* Keep this last, we don't need it for the fast path */ -struct work_struct exit_work; -struct list_head tctx_list; +struct { +#if defined(CONFIG_UNIX ) +struct socket *ring_sock; +#endif +/* hashed buffered write serialization */ +struct io_wq_hash *hash_map; + +/* Only used for accounting purposes */ +struct user_struct *user; +struct mm_struct *mm_account; + +/* ctx exit and cancelation */ +struct callback_head *exit_task_work; +struct work_struct exit_work; +struct list_head tctx_list; +struct completion ref_comp; + }; };struct io_uring_task {
Signature · 1 line
2.31.1
PATCH 2/2 io_uring: localise fixed resources fields
In reply to Pavel Begunkovring has two types of resource-related fields, used for request submission, and field needed for update/registration. Reshuffle them into these two groups for better locality and readability. The second group is not in the hot path, so it's natural to place them somewhere in the end. Also update an outdated comment.
--- fs/io_uring.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-)
fs/io_uring.c +17 -16
@@ -390,21 +390,17 @@ struct io_ring_ctx {struct list_head sqd_list;/* -* If used, fixed file set. Writers must ensure that ->refs is dead, -* readers must ensure that ->refs is alive as long as the file* is -* used. Only updated through io_uring_register(2). +* Fixed resources fast path, should be accessed only under uring_lock, +* and updated through io_uring_register(2) */ -struct io_rsrc_data *file_data; +struct io_rsrc_node *rsrc_node; +struct io_file_table file_table;unsigned nr_user_files; - -/* if used, fixed mapped user buffers */ -struct io_rsrc_data *buf_data;unsigned nr_user_bufs;struct io_mapped_ubuf **user_bufs;struct xarray io_buffers; -struct xarray personalities;u32 pers_next;
@@ -436,16 +432,21 @@ struct io_ring_ctx {bool poll_multi_file; }____cacheline_aligned_in_smp ; -struct delayed_work rsrc_put_work; -struct llist_head rsrc_put_llist; -struct list_head rsrc_ref_list; -spinlock_t rsrc_ref_lock; -struct io_rsrc_node *rsrc_node; -struct io_rsrc_node *rsrc_backup_node; -struct io_mapped_ubuf *dummy_ubuf; -struct io_restriction restrictions; +/* slow path rsrc auxilary data, used by update/register */ +struct { +struct io_rsrc_node *rsrc_backup_node; +struct io_mapped_ubuf *dummy_ubuf; +struct io_rsrc_data *file_data; +struct io_rsrc_data *buf_data; + +struct delayed_work rsrc_put_work; +struct llist_head rsrc_put_llist; +struct list_head rsrc_ref_list; +spinlock_t rsrc_ref_lock; + }; +/* Keep this last, we don't need it for the fast path */ struct {#if defined(CONFIG_UNIX )
Signature · 1 line
2.31.1