io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-next 0/2] tw handlers cleanups
@ 2021-08-19 11:56 Pavel Begunkov
  2021-08-19 11:56 ` [PATCH 1/2] io_uring: remove mutex in io_req_task_cancel() Pavel Begunkov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Pavel Begunkov @ 2021-08-19 11:56 UTC (permalink / raw)
  To: Jens Axboe, io-uring

Two simple patches cleaning task_work handlers.

Pavel Begunkov (2):
  io_uring: remove mutex in io_req_task_cancel()
  io_uring: dedup tw-based request failing

 fs/io_uring.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

-- 
2.32.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] io_uring: remove mutex in io_req_task_cancel()
  2021-08-19 11:56 [PATCH for-next 0/2] tw handlers cleanups Pavel Begunkov
@ 2021-08-19 11:56 ` Pavel Begunkov
  2021-08-19 11:56 ` [PATCH 2/2] io_uring: dedup tw-based request failing Pavel Begunkov
  2021-08-19 15:49 ` [PATCH for-next 0/2] tw handlers cleanups Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Pavel Begunkov @ 2021-08-19 11:56 UTC (permalink / raw)
  To: Jens Axboe, io-uring

io_req_complete_failed() only does io_req_complete_post(), which we
don't need to protect by ->uring_lock, so remove mutex_lock / unlock
from there.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 fs/io_uring.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 5e99473ad6fc..bdab831a1185 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2111,12 +2111,7 @@ static void io_req_task_work_add(struct io_kiocb *req)
 
 static void io_req_task_cancel(struct io_kiocb *req)
 {
-	struct io_ring_ctx *ctx = req->ctx;
-
-	/* ctx is guaranteed to stay alive while we hold uring_lock */
-	mutex_lock(&ctx->uring_lock);
 	io_req_complete_failed(req, req->result);
-	mutex_unlock(&ctx->uring_lock);
 }
 
 static void io_req_task_submit(struct io_kiocb *req)
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] io_uring: dedup tw-based request failing
  2021-08-19 11:56 [PATCH for-next 0/2] tw handlers cleanups Pavel Begunkov
  2021-08-19 11:56 ` [PATCH 1/2] io_uring: remove mutex in io_req_task_cancel() Pavel Begunkov
@ 2021-08-19 11:56 ` Pavel Begunkov
  2021-08-19 15:49 ` [PATCH for-next 0/2] tw handlers cleanups Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Pavel Begunkov @ 2021-08-19 11:56 UTC (permalink / raw)
  To: Jens Axboe, io-uring

io_req_task_timeout() closely follows io_req_task_cancel(), so remove it
and replace with io_req_task_queue_fail().

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 fs/io_uring.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index bdab831a1185..581c994a4e4f 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -5529,12 +5529,6 @@ static int io_poll_update(struct io_kiocb *req, unsigned int issue_flags)
 	return 0;
 }
 
-static void io_req_task_timeout(struct io_kiocb *req)
-{
-	req_set_fail(req);
-	io_req_complete_post(req, -ETIME, 0);
-}
-
 static enum hrtimer_restart io_timeout_fn(struct hrtimer *timer)
 {
 	struct io_timeout_data *data = container_of(timer,
@@ -5549,8 +5543,7 @@ static enum hrtimer_restart io_timeout_fn(struct hrtimer *timer)
 		atomic_read(&req->ctx->cq_timeouts) + 1);
 	spin_unlock_irqrestore(&ctx->timeout_lock, flags);
 
-	req->io_task_work.func = io_req_task_timeout;
-	io_req_task_work_add(req);
+	io_req_task_queue_fail(req, -ETIME);
 	return HRTIMER_NORESTART;
 }
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH for-next 0/2] tw handlers cleanups
  2021-08-19 11:56 [PATCH for-next 0/2] tw handlers cleanups Pavel Begunkov
  2021-08-19 11:56 ` [PATCH 1/2] io_uring: remove mutex in io_req_task_cancel() Pavel Begunkov
  2021-08-19 11:56 ` [PATCH 2/2] io_uring: dedup tw-based request failing Pavel Begunkov
@ 2021-08-19 15:49 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2021-08-19 15:49 UTC (permalink / raw)
  To: Pavel Begunkov, io-uring

On 8/19/21 5:56 AM, Pavel Begunkov wrote:
> Two simple patches cleaning task_work handlers.
> 
> Pavel Begunkov (2):
>   io_uring: remove mutex in io_req_task_cancel()
>   io_uring: dedup tw-based request failing
> 
>  fs/io_uring.c | 14 +-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-08-19 15:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-19 11:56 [PATCH for-next 0/2] tw handlers cleanups Pavel Begunkov
2021-08-19 11:56 ` [PATCH 1/2] io_uring: remove mutex in io_req_task_cancel() Pavel Begunkov
2021-08-19 11:56 ` [PATCH 2/2] io_uring: dedup tw-based request failing Pavel Begunkov
2021-08-19 15:49 ` [PATCH for-next 0/2] tw handlers cleanups Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).