small code clean
cover small code clean
Some small code clean.
Hao Xu (3):
io_uring: extract io_uring_files_cancel() in io_uring_task_cancel()
io_uring: remove files pointer in cancellation functions
io_uring: code clean for completion_lock in io_arm_poll_handler()
fs/io_uring.c | 15 ++++++--------- include/linux/io_uring.h | 9 +++++---- kernel/exit.c | 2 +- 3 files changed, 12 insertions(+), 14 deletions(-)
Signature · 1 line
2.24.4
PATCH 1/3 io_uring: extract io_uring_files_cancel() in io_uring_task_cancel()
Extract io_uring_files_cancel() call in io_uring_task_cancel() to make io_uring_files_cancel() and io_uring_task_cancel() coherent and easy to read.
--- include/linux/io_uring.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/linux/io_uring.h +2 -1
@@ -17,7 +17,8 @@ static inline void io_uring_files_cancel(struct files_struct *files) }static inline void io_uring_task_cancel (void ) { -return io_uring_files_cancel (NULL ); +if (current->io_uring) +__io_uring_cancel (NULL ); }static inline void io_uring_free (struct task_struct *tsk) {
Signature · 1 line
2.24.4
PATCH 2/3 io_uring: remove files pointer in cancellation functions
In reply to Hao XuWhen doing cancellation, we use a parameter to indicate where it's from do_exit or exec. So a boolean value is good enough for this, remove the struct files* as it is not necessary.
--- fs/io_uring.c | 4 ++-- include/linux/io_uring.h | 8 ++++---- kernel/exit.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-)
fs/io_uring.c +2 -2
@@ -9205,9 +9205,9 @@ static void io_uring_cancel_generic(bool cancel_all, struct io_sq_data *sqd) } } -void __io_uring_cancel (struct files_struct *files) +void __io_uring_cancel (bool cancel_all) { -io_uring_cancel_generic (!files,NULL ); +io_uring_cancel_generic (cancel_all,NULL ); } static void *io_uring_validate_mmap_request(struct file *file,
include/linux/io_uring.h +4 -4
@@ -7,18 +7,18 @@#if defined(CONFIG_IO_URING )struct sock *io_uring_get_socket (struct file *file); -void __io_uring_cancel (struct files_struct *files); +void __io_uring_cancel (bool cancel_all);void __io_uring_free (struct task_struct *tsk); -static inline void io_uring_files_cancel (struct files_struct *files) +static inline void io_uring_files_cancel (void ) {if (current->io_uring) -__io_uring_cancel (files); +__io_uring_cancel (false); }static inline void io_uring_task_cancel (void ) {if (current->io_uring) -__io_uring_cancel (NULL ); +__io_uring_cancel (true); }static inline void io_uring_free (struct task_struct *tsk) {
kernel/exit.c +1 -1
@@ -777,7 +777,7 @@ void __noreturn do_exit(long code)schedule (); } -io_uring_files_cancel (tsk->files); +io_uring_files_cancel ();exit_signals (tsk);/* sets PF_EXITING */ /* sync mm's RSS info before statistics gathering */
Signature · 1 line
2.24.4
PATCH 3/3 io_uring: code clean for completion_lock in io_arm_poll_handler()
In reply to Hao XuWe can merge two spin_unlock() operations to one since we removed some code not long ago.
--- fs/io_uring.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
fs/io_uring.c +4 -7
@@ -5231,13 +5231,10 @@ static int io_arm_poll_handler(struct io_kiocb *req) ret =__io_arm_poll_handler (req, &apoll->poll, &ipt, mask, io_async_wake); -if (ret || ipt.error) { -spin_unlock (&ctx->completion_lock); -if (ret) -return IO_APOLL_READY ; -return IO_APOLL_ABORTED ; - } -spin_unlock (&ctx->completion_lock); +spin_unlock_irq (&ctx->completion_lock); +if (ret || ipt.error) +return ret ?IO_APOLL_READY :IO_APOLL_ABORTED ; +trace_io_uring_poll_arm (ctx, req, req->opcode, req->user_data, mask, apoll->poll.events);return IO_APOLL_OK ;
Signature · 1 line
2.24.4
Re: [PATCH 3/3] io_uring: code clean for completion_lock in io_arm_poll_handler()
Quoted 14 lines · Hao Xu
We can merge two
spin_unlock()operations to one since we removed some code not long ago.Signed-off-by Hao Xu <[email protected]>--- fs/io_uring.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)fs/io_uring.c +0
-0@@ -5231,13 +5231,10 @@ static int io_arm_poll_handler(struct io_kiocb *req)
fs/io_uring.c static int io_arm_poll_handler(struct io_kiocb *req) · line 5234
Quoted 10 lines
fs/io_uring.c +1
-7ret =__io_arm_poll_handler (req, &apoll->poll, &ipt, mask, io_async_wake); -if (ret || ipt.error) { -spin_unlock (&ctx->completion_lock); -if (ret) -return IO_APOLL_READY ; -return IO_APOLL_ABORTED ; - } -spin_unlock (&ctx->completion_lock); +spin_unlock_irq (&ctx->completion_lock);
This looks weird.
You replace spin_unlock() with spin_unlock_irq() without any spin_lock() changes.
Thanks,
Joseph
Quoted 7 lines
fs/io_uring.c +3
-0+if (ret || ipt.error) +return ret ?IO_APOLL_READY :IO_APOLL_ABORTED ; +trace_io_uring_poll_arm (ctx, req, req->opcode, req->user_data, mask, apoll->poll.events);return IO_APOLL_OK ;
PATCH v2 1/1 io_uring: code clean for completion_lock in io_arm_poll_handler()
In reply to Hao XuWe can merge two spin_unlock() operations to one since we removed some code not long ago.
--- fs/io_uring.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
fs/io_uring.c +3 -6
@@ -5231,13 +5231,10 @@ static int io_arm_poll_handler(struct io_kiocb *req) ret =__io_arm_poll_handler (req, &apoll->poll, &ipt, mask, io_async_wake); -if (ret || ipt.error) { -spin_unlock (&ctx->completion_lock); -if (ret) -return IO_APOLL_READY ; -return IO_APOLL_ABORTED ; - }spin_unlock (&ctx->completion_lock); +if (ret || ipt.error) +return ret ?IO_APOLL_READY :IO_APOLL_ABORTED ; +trace_io_uring_poll_arm (ctx, req, req->opcode, req->user_data, mask, apoll->poll.events);return IO_APOLL_OK ;
Signature · 1 line
2.24.4
Jens Axboe
maintainerQuoted 11 lines · Hao Xu
Some small code clean.
Hao Xu (3):
io_uring: extractio_uring_files_cancel()inio_uring_task_cancel()
io_uring: remove files pointer in cancellation functions
io_uring: code clean forcompletion_lockinio_arm_poll_handler()fs/io_uring.c | 15 ++++++--------- include/linux/io_uring.h | 9 +++++---- kernel/exit.c | 2 +- 3 files changed, 12 insertions(+), 14 deletions(-)
This looks good, except 3/3 which I think was rebased and then not re-tested after doing so... That's a black mark.
Anyway, v2 looks fine, applied for 5.15.
Signature · 1 line
Jens Axboe
Quoted 8 lines · Jens Axboe
Quoted 7 lines · Hao Xu
Some small code clean.
Hao Xu (3):
io_uring: extractio_uring_files_cancel()inio_uring_task_cancel()
io_uring: remove files pointer in cancellation functions
io_uring: code clean forcompletion_lockinio_arm_poll_handler()
Quoted 8 lines
Quoted 4 lines
fs/io_uring.c | 15 ++++++--------- include/linux/io_uring.h | 9 +++++---- kernel/exit.c | 2 +- 3 files changed, 12 insertions(+), 14 deletions(-)This looks good, except 3/3 which I think was rebased and then not re-tested after doing so... That's a black mark.
Actually I re-tested it after rebasing code and addressing the conflict But the liburing tests results seems all good. Anyway, I'll check the code more carefully when resolving conflict.
Quoted 2 lines
Anyway, v2 looks fine, applied for 5.15.
Jens Axboe
maintainerQuoted 14 lines · Hao Xu
Quoted 13 lines · Jens Axboe
Quoted 11 lines · Hao Xu
Some small code clean.
Hao Xu (3):
io_uring: extractio_uring_files_cancel()inio_uring_task_cancel()
io_uring: remove files pointer in cancellation functions
io_uring: code clean forcompletion_lockinio_arm_poll_handler()fs/io_uring.c | 15 ++++++--------- include/linux/io_uring.h | 9 +++++---- kernel/exit.c | 2 +- 3 files changed, 12 insertions(+), 14 deletions(-)
Quoted 6 lines
Quoted 3 lines
This looks good, except 3/3 which I think was rebased and then not re-tested after doing so... That's a black mark.
Actually I re-tested it after rebasing code and addressing the conflict But the liburing tests results seems all good. Anyway, I'll check the code more carefully when resolving conflict.
Probably would only complain if you had PROVE_LOCKING enabled in your config.
The last patch broke !CONFIG_IO_URING too, I fixed that up.
Signature · 1 line
Jens Axboe