All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 5.12] io_uring: fix locked_free_list caches_free()
@ 2021-02-23 22:17 Pavel Begunkov
  2021-02-24  2:20 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Begunkov @ 2021-02-23 22:17 UTC (permalink / raw)
  To: Jens Axboe, io-uring

Don't forget to zero locked_free_nr, it's not a disaster but makes it
attempting to flush it with extra locking when there is nothing in the
list. Also, don't traverse a potentially long list freeing requests
under spinlock, splice the list and do it afterwards.

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

diff --git a/fs/io_uring.c b/fs/io_uring.c
index bf9ad810c621..1a26898d23ed 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -8701,6 +8701,7 @@ static void io_req_cache_free(struct list_head *list, struct task_struct *tsk)
 static void io_req_caches_free(struct io_ring_ctx *ctx, struct task_struct *tsk)
 {
 	struct io_submit_state *submit_state = &ctx->submit_state;
+	struct io_comp_state *cs = &ctx->submit_state.comp;
 
 	mutex_lock(&ctx->uring_lock);
 
@@ -8710,12 +8711,13 @@ static void io_req_caches_free(struct io_ring_ctx *ctx, struct task_struct *tsk)
 		submit_state->free_reqs = 0;
 	}
 
-	io_req_cache_free(&submit_state->comp.free_list, NULL);
-
 	spin_lock_irq(&ctx->completion_lock);
-	io_req_cache_free(&submit_state->comp.locked_free_list, NULL);
+	list_splice_init(&cs->locked_free_list, &cs->free_list);
+	cs->locked_free_nr = 0;
 	spin_unlock_irq(&ctx->completion_lock);
 
+	io_req_cache_free(&cs->free_list, NULL);
+
 	mutex_unlock(&ctx->uring_lock);
 }
 
-- 
2.24.0


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

* Re: [PATCH v2 5.12] io_uring: fix locked_free_list caches_free()
  2021-02-23 22:17 [PATCH v2 5.12] io_uring: fix locked_free_list caches_free() Pavel Begunkov
@ 2021-02-24  2:20 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2021-02-24  2:20 UTC (permalink / raw)
  To: Pavel Begunkov, io-uring

On 2/23/21 3:17 PM, Pavel Begunkov wrote:
> Don't forget to zero locked_free_nr, it's not a disaster but makes it
> attempting to flush it with extra locking when there is nothing in the
> list. Also, don't traverse a potentially long list freeing requests
> under spinlock, splice the list and do it afterwards.

Applied, thanks.

-- 
Jens Axboe


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

end of thread, other threads:[~2021-02-24  2:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-23 22:17 [PATCH v2 5.12] io_uring: fix locked_free_list caches_free() Pavel Begunkov
2021-02-24  2:20 ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.