Various minor cleanups
Jens Axboe
maintainercover Various minor cleanups
Hi,
No particular theme to this "series", it's mostly just moving code around a bit to more appropriate spots, and removing dead declarations that are entirely unneeded. Mostly in preparation for moving more of the cancel code into cancel.c and out of io_uring.c.
No functional changes in this series.
io_uring/cancel.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ io_uring/cancel.h | 2 ++ io_uring/io_uring.c | 44 -------------------------------------------- io_uring/io_uring.h | 3 --- io_uring/memmap.h | 5 ----- io_uring/net.c | 14 +++++++++++--- io_uring/notif.h | 8 -------- io_uring/rsrc.c | 4 ++-- io_uring/slist.h | 18 ------------------ 9 files changed, 59 insertions(+), 83 deletions(-)
Signature · 1 line
Jens Axboe
Jens Axboe
maintainerPATCH 1/6 io_uring/slist: remove unused wq list splice helpers
Nobody is using those helpers anymore, get rid of them.
--- io_uring/slist.h | 18 ------------------ 1 file changed, 18 deletions(-)
io_uring/slist.h +0 -18
@@ -67,24 +67,6 @@ static inline void wq_list_cut(struct io_wq_work_list *list, last->next =NULL ; } -static inline void __wq_list_splice (struct io_wq_work_list *list, -struct io_wq_work_node *to) -{ - list->last->next = to->next; - to->next = list->first; -INIT_WQ_LIST (list); -} - -static inline bool wq_list_splice (struct io_wq_work_list *list, -struct io_wq_work_node *to) -{ -if (!wq_list_empty (list)) { -__wq_list_splice (list, to); -return true; - } -return false; -} -static inline void wq_stack_add_head (struct io_wq_work_node *node,struct io_wq_work_node *stack) {
Signature · 1 line
2.51.0
Jens Axboe
maintainerPATCH 2/6 io_uring/rsrc: use get/put_user() for integer copy
In reply to Jens AxboeIt's just getting an integer from userspace, installing a file, then copying the output direct descriptor back. No need to use the full copy_to/from_user() for that.
--- io_uring/rsrc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
io_uring/rsrc.c +2 -2
@@ -454,7 +454,7 @@ static int io_files_update_with_index_alloc(struct io_kiocb *req,return -ENXIO ;for (done =0 ; done < up->nr_args; done++) { -if (copy_from_user (&fd, &fds[done],sizeof (fd))) { +if (get_user (fd, &fds[done])) { ret = -EFAULT ;break ; }
@@ -468,7 +468,7 @@ static int io_files_update_with_index_alloc(struct io_kiocb *req, IORING_FILE_INDEX_ALLOC);if (ret <0 )break ; -if (copy_to_user (&fds[done], &ret,sizeof (ret))) { +if (put_user (ret, &fds[done])) {__io_close_fixed (req->ctx, issue_flags, ret); ret = -EFAULT ;break ;
Signature · 1 line
2.51.0
Jens Axboe
maintainerPATCH 3/6 io_uring/notif: move io_notif_flush() to net.c
In reply to Jens AxboeIt's specific to the networking side, move it in there.
--- io_uring/net.c | 14 +++++++++++--- io_uring/notif.h | 8 -------- 2 files changed, 11 insertions(+), 11 deletions(-)
io_uring/net.c +11 -3
@@ -1303,6 +1303,14 @@ int io_recvzc(struct io_kiocb *req, unsigned int issue_flags)return IOU_RETRY ; } +static void io_send_notif_flush (struct io_kiocb *notif) + __must_hold(¬if->ctx->uring_lock) +{ +struct io_notif_data *nd =io_notif_to_data (notif); + +io_tx_ubuf_complete (NULL , &nd->uarg, true); +} +void io_send_zc_cleanup (struct io_kiocb *req) { struct io_sr_msg *zc = io_kiocb_to_cmd(req, struct io_sr_msg);
@@ -1311,7 +1319,7 @@ void io_send_zc_cleanup(struct io_kiocb *req)if (req_has_async_data (req))io_netmsg_iovec_free (io);if (zc->notif) { -io_notif_flush (zc->notif); +io_send_notif_flush (zc->notif); zc->notif =NULL ; } }
@@ -1512,7 +1520,7 @@ int io_send_zc(struct io_kiocb *req, unsigned int issue_flags)* flushing notif to io_send_zc_cleanup() */ if (!(issue_flags &IO_URING_F_UNLOCKED )) { -io_notif_flush (zc->notif); +io_send_notif_flush (zc->notif); zc->notif =NULL ;io_req_msg_cleanup (req,0 ); }
@@ -1582,7 +1590,7 @@ int io_sendmsg_zc(struct io_kiocb *req, unsigned int issue_flags)* flushing notif to io_send_zc_cleanup() */ if (!(issue_flags &IO_URING_F_UNLOCKED )) { -io_notif_flush (sr->notif); +io_send_notif_flush (sr->notif); sr->notif =NULL ;io_req_msg_cleanup (req,0 ); }
io_uring/notif.h +0 -8
@@ -32,14 +32,6 @@ static inline struct io_notif_data *io_notif_to_data(struct io_kiocb *notif) return io_kiocb_to_cmd(notif, struct io_notif_data); } -static inline void io_notif_flush (struct io_kiocb *notif) - __must_hold(¬if->ctx->uring_lock) -{ -struct io_notif_data *nd =io_notif_to_data (notif); - -io_tx_ubuf_complete (NULL , &nd->uarg, true); -} -static inline int io_notif_account_mem (struct io_kiocb *notif,unsigned len) {struct io_ring_ctx *ctx = notif->ctx;
Signature · 1 line
2.51.0
Re: [PATCH 3/6] io_uring/notif: move io_notif_flush() to net.c
Quoted 1 line · Jens Axboe
It's specific to the networking side, move it in there.
It's there because notif.[c,h] know about struct io_notif_data internals and net.c in general shouldn't, otherwise it's not any more net specific than anything else notification related.
Signature · 1 line
Pavel Begunkov
Jens Axboe
maintainerRe: [PATCH 3/6] io_uring/notif: move io_notif_flush() to net.c
Quoted 6 lines · Pavel Begunkov
Quoted 1 line · Jens Axboe
It's specific to the networking side, move it in there.
It's there because notif.[c,h] know about struct
io_notif_datainternals andnet.cin general shouldn't, otherwise it's not any more net specific than anything else notification related.
I guess the notif stuff is all networking anyway, almost doesn't make sense to have it split out. But as long as we do, we can keep that stuff in there. I'll drop this one.
Signature · 1 line
Jens Axboe
Re: [PATCH 3/6] io_uring/notif: move io_notif_flush() to net.c
Quoted 9 lines · Jens Axboe
Quoted 6 lines · Pavel Begunkov
Quoted 1 line · Jens Axboe
It's specific to the networking side, move it in there.
It's there because notif.[c,h] know about struct
io_notif_datainternals andnet.cin general shouldn't, otherwise it's not any more net specific than anything else notification related.I guess the notif stuff is all networking anyway, almost doesn't
Right, that's my point. And separation is not a bad thing considering that net.c is a bit too fat.
Quoted 2 lines
make sense to have it split out. But as long as we do, we can keep that stuff in there. I'll drop this one.
Signature · 1 line
Pavel Begunkov
Jens Axboe
maintainerPATCH 4/6 io_uring/memmap: remove dead io_create_region_mmap_safe() declaration
In reply to Jens AxboeNo longer used and doesn't even exist, kill it from the memmap header file.
--- io_uring/memmap.h | 5 ----- 1 file changed, 5 deletions(-)
io_uring/memmap.h +0 -5
@@ -21,11 +21,6 @@ int io_create_region(struct io_ring_ctx *ctx, struct io_mapped_region *mr,struct io_uring_region_desc *reg, unsigned long mmap_offset); -int io_create_region_mmap_safe (struct io_ring_ctx *ctx, -struct io_mapped_region *mr, -struct io_uring_region_desc *reg, -unsigned long mmap_offset); -static inline void *io_region_get_ptr (struct io_mapped_region *mr) {return mr->ptr;
Signature · 1 line
2.51.0
Jens Axboe
maintainerPATCH 5/6 io_uring/cancel: move request/task cancelation logic into cancel.c
In reply to Jens AxboeMove io_match_task_safe() and helpers into cancel.c, where it belongs.
--- io_uring/cancel.c | 38 ++++++++++++++++++++++++++++++++++++++ io_uring/cancel.h | 2 ++ io_uring/io_uring.c | 38 -------------------------------------- io_uring/io_uring.h | 3 --- 4 files changed, 40 insertions(+), 41 deletions(-)
io_uring/cancel.c +38 -0
@@ -384,3 +384,41 @@ int io_cancel_remove(struct io_ring_ctx *ctx, struct io_cancel_data *cd,io_ring_submit_unlock (ctx, issue_flags);return nr ?: -ENOENT ; } + +static bool io_match_linked (struct io_kiocb *head) +{ +struct io_kiocb *req; + +io_for_each_link (req, head) { +if (req->flags &REQ_F_INFLIGHT ) +return true; + } +return false; +} + +/* +* As io_match_task() but protected against racing with linked timeouts. +* User must not hold timeout_lock. +*/ +bool io_match_task_safe (struct io_kiocb *head,struct io_uring_task *tctx, +bool cancel_all) +{ +bool matched; + +if (tctx && head->tctx != tctx) +return false; +if (cancel_all) +return true; + +if (head->flags &REQ_F_LINK_TIMEOUT ) { +struct io_ring_ctx *ctx = head->ctx; + +/* protect against races with linked timeouts */ +raw_spin_lock_irq (&ctx->timeout_lock); + matched =io_match_linked (head); +raw_spin_unlock_irq (&ctx->timeout_lock); + }else { + matched =io_match_linked (head); + } +return matched; +}
io_uring/cancel.h +2 -0
@@ -23,6 +23,8 @@ int io_try_cancel(struct io_uring_task *tctx, struct io_cancel_data *cd,int io_sync_cancel (struct io_ring_ctx *ctx,void __user *arg);bool io_cancel_req_match (struct io_kiocb *req,struct io_cancel_data *cd); +bool io_match_task_safe (struct io_kiocb *head,struct io_uring_task *tctx, +bool cancel_all); bool io_cancel_remove_all(struct io_ring_ctx *ctx, struct io_uring_task *tctx, struct hlist_head *list, bool cancel_all,
io_uring/io_uring.c +0 -38
@@ -207,44 +207,6 @@ static inline unsigned int __io_cqring_events_user(struct io_ring_ctx *ctx)return READ_ONCE (ctx->rings->cq.tail) -READ_ONCE (ctx->rings->cq.head); } -static bool io_match_linked (struct io_kiocb *head) -{ -struct io_kiocb *req; - -io_for_each_link (req, head) { -if (req->flags &REQ_F_INFLIGHT ) -return true; - } -return false; -} - -/* -* As io_match_task() but protected against racing with linked timeouts. -* User must not hold timeout_lock. -*/ -bool io_match_task_safe (struct io_kiocb *head,struct io_uring_task *tctx, -bool cancel_all) -{ -bool matched; - -if (tctx && head->tctx != tctx) -return false; -if (cancel_all) -return true; - -if (head->flags &REQ_F_LINK_TIMEOUT ) { -struct io_ring_ctx *ctx = head->ctx; - -/* protect against races with linked timeouts */ -raw_spin_lock_irq (&ctx->timeout_lock); - matched =io_match_linked (head); -raw_spin_unlock_irq (&ctx->timeout_lock); - }else { - matched =io_match_linked (head); - } -return matched; -} -static inline void req_fail_link_node (struct io_kiocb *req,int res) {req_set_fail (req);
io_uring/io_uring.h +0 -3
@@ -174,9 +174,6 @@ void io_queue_next(struct io_kiocb *req);void io_task_refs_refill (struct io_uring_task *tctx);bool __io_alloc_req_refill (struct io_ring_ctx *ctx); -bool io_match_task_safe (struct io_kiocb *head,struct io_uring_task *tctx, -bool cancel_all); -void io_activate_pollwq (struct io_ring_ctx *ctx);static inline void io_lockdep_assert_cq_locked (struct io_ring_ctx *ctx)
Signature · 1 line
2.51.0
Jens Axboe
maintainerPATCH 6/6 io_uring/cancel: move __io_uring_cancel() into cancel.c
In reply to Jens AxboeYet another function that should be in cancel.c, move it over.
--- io_uring/cancel.c | 6 ++++++ io_uring/io_uring.c | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-)
io_uring/cancel.c +6 -0
@@ -422,3 +422,9 @@ bool io_match_task_safe(struct io_kiocb *head, struct io_uring_task *tctx, }return matched; } + +void __io_uring_cancel (bool cancel_all) +{ +io_uring_unreg_ringfd (); +io_uring_cancel_generic (cancel_all,NULL ); +}
io_uring/io_uring.c +0 -6
@@ -3336,12 +3336,6 @@ __cold void io_uring_cancel_generic(bool cancel_all, struct io_sq_data *sqd) } } -void __io_uring_cancel (bool cancel_all) -{ -io_uring_unreg_ringfd (); -io_uring_cancel_generic (cancel_all,NULL ); -} -static struct io_uring_reg_wait *io_get_ext_arg_reg (struct io_ring_ctx *ctx,const struct io_uring_getevents_arg __user *uarg) {
Signature · 1 line
2.51.0