public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH for-next 0/2] 5.15 small improvements
@ 2021-08-25 19:51 Pavel Begunkov
  2021-08-25 19:51 ` [PATCH 1/2] io_uring: clarify io_req_task_cancel() locking Pavel Begunkov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Pavel Begunkov @ 2021-08-25 19:51 UTC (permalink / raw)
  To: Jens Axboe, io-uring

Just two small patches following past and potential problems

Pavel Begunkov (2):
  io_uring: clarify io_req_task_cancel() locking
  io_uring: add build check for buf_index overflows

 fs/io_uring.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

-- 
2.32.0


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

* [PATCH 1/2] io_uring: clarify io_req_task_cancel() locking
  2021-08-25 19:51 [PATCH for-next 0/2] 5.15 small improvements Pavel Begunkov
@ 2021-08-25 19:51 ` Pavel Begunkov
  2021-08-25 19:51 ` [PATCH 2/2] io_uring: add build check for buf_index overflows Pavel Begunkov
  2021-08-27 15:23 ` [PATCH for-next 0/2] 5.15 small improvements Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Pavel Begunkov @ 2021-08-25 19:51 UTC (permalink / raw)
  To: Jens Axboe, io-uring

It's too easy to forget and misjudge about synchronisation in
io_req_task_cancel(), add a comment clarifying it.

Signed-off-by: Pavel Begunkov <[email protected]>
---
 fs/io_uring.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 15728e63d6f9..712605fd04c2 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2138,7 +2138,7 @@ static void io_req_task_cancel(struct io_kiocb *req, bool *locked)
 {
 	struct io_ring_ctx *ctx = req->ctx;
 
-	/* ctx is guaranteed to stay alive while we hold uring_lock */
+	/* not needed for normal modes, but SQPOLL depends on it */
 	io_tw_lock(ctx, locked);
 	io_req_complete_failed(req, req->result);
 }
@@ -2147,7 +2147,6 @@ static void io_req_task_submit(struct io_kiocb *req, bool *locked)
 {
 	struct io_ring_ctx *ctx = req->ctx;
 
-	/* ctx stays valid until unlock, even if we drop all ours ctx->refs */
 	io_tw_lock(ctx, locked);
 	/* req->task == current here, checking PF_EXITING is safe */
 	if (likely(!(req->task->flags & PF_EXITING)))
-- 
2.32.0


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

* [PATCH 2/2] io_uring: add build check for buf_index overflows
  2021-08-25 19:51 [PATCH for-next 0/2] 5.15 small improvements Pavel Begunkov
  2021-08-25 19:51 ` [PATCH 1/2] io_uring: clarify io_req_task_cancel() locking Pavel Begunkov
@ 2021-08-25 19:51 ` Pavel Begunkov
  2021-08-27 15:23 ` [PATCH for-next 0/2] 5.15 small improvements Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Pavel Begunkov @ 2021-08-25 19:51 UTC (permalink / raw)
  To: Jens Axboe, io-uring

req->buf_index is u16 and so we rely on registered buffers indexes
fitting into it. Add a build check, so when the upper limit for the
number of buffers is lifted we get a compliation fail but not lurking
problems.

Signed-off-by: Pavel Begunkov <[email protected]>
---
 fs/io_uring.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 712605fd04c2..6112318a770c 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -10450,6 +10450,10 @@ static int __init io_uring_init(void)
 		     sizeof(struct io_uring_rsrc_update));
 	BUILD_BUG_ON(sizeof(struct io_uring_rsrc_update) >
 		     sizeof(struct io_uring_rsrc_update2));
+
+	/* ->buf_index is u16 */
+	BUILD_BUG_ON(IORING_MAX_REG_BUFFERS >= (1u << 16));
+
 	/* should fit into one byte */
 	BUILD_BUG_ON(SQE_VALID_FLAGS >= (1 << 8));
 
-- 
2.32.0


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

* Re: [PATCH for-next 0/2] 5.15 small improvements
  2021-08-25 19:51 [PATCH for-next 0/2] 5.15 small improvements Pavel Begunkov
  2021-08-25 19:51 ` [PATCH 1/2] io_uring: clarify io_req_task_cancel() locking Pavel Begunkov
  2021-08-25 19:51 ` [PATCH 2/2] io_uring: add build check for buf_index overflows Pavel Begunkov
@ 2021-08-27 15:23 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2021-08-27 15:23 UTC (permalink / raw)
  To: Pavel Begunkov, io-uring

On 8/25/21 1:51 PM, Pavel Begunkov wrote:
> Just two small patches following past and potential problems
> 
> Pavel Begunkov (2):
>   io_uring: clarify io_req_task_cancel() locking
>   io_uring: add build check for buf_index overflows
> 
>  fs/io_uring.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)

Applied, thanks.

-- 
Jens Axboe


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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-25 19:51 [PATCH for-next 0/2] 5.15 small improvements Pavel Begunkov
2021-08-25 19:51 ` [PATCH 1/2] io_uring: clarify io_req_task_cancel() locking Pavel Begunkov
2021-08-25 19:51 ` [PATCH 2/2] io_uring: add build check for buf_index overflows Pavel Begunkov
2021-08-27 15:23 ` [PATCH for-next 0/2] 5.15 small improvements Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox