Patch "io_uring: fix bug in slow unregistering of nodes" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    io_uring: fix bug in slow unregistering of nodes

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     io_uring-fix-bug-in-slow-unregistering-of-nodes.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 17fedcb20213ce347eec38e133cebfa9f200991e
Author: Dylan Yudaken <dylany@xxxxxx>
Date:   Fri Jan 21 04:38:56 2022 -0800

    io_uring: fix bug in slow unregistering of nodes
    
    [ Upstream commit b36a2050040b2d839bdc044007cdd57101d7f881 ]
    
    In some cases io_rsrc_ref_quiesce will call io_rsrc_node_switch_start,
    and then immediately flush the delayed work queue &ctx->rsrc_put_work.
    
    However the percpu_ref_put does not immediately destroy the node, it
    will be called asynchronously via RCU. That ends up with
    io_rsrc_node_ref_zero only being called after rsrc_put_work has been
    flushed, and so the process ends up sleeping for 1 second unnecessarily.
    
    This patch executes the put code immediately if we are busy
    quiescing.
    
    Fixes: 4a38aed2a0a7 ("io_uring: batch reap of dead file registrations")
    Signed-off-by: Dylan Yudaken <dylany@xxxxxx>
    Link: https://lore.kernel.org/r/20220121123856.3557884-1-dylany@xxxxxx
    Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/io_uring.c b/fs/io_uring.c
index f713b91537f41..993913c585fbf 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -7718,10 +7718,15 @@ static void io_rsrc_node_ref_zero(struct percpu_ref *ref)
 	struct io_ring_ctx *ctx = node->rsrc_data->ctx;
 	unsigned long flags;
 	bool first_add = false;
+	unsigned long delay = HZ;
 
 	spin_lock_irqsave(&ctx->rsrc_ref_lock, flags);
 	node->done = true;
 
+	/* if we are mid-quiesce then do not delay */
+	if (node->rsrc_data->quiesce)
+		delay = 0;
+
 	while (!list_empty(&ctx->rsrc_ref_list)) {
 		node = list_first_entry(&ctx->rsrc_ref_list,
 					    struct io_rsrc_node, node);
@@ -7734,7 +7739,7 @@ static void io_rsrc_node_ref_zero(struct percpu_ref *ref)
 	spin_unlock_irqrestore(&ctx->rsrc_ref_lock, flags);
 
 	if (first_add)
-		mod_delayed_work(system_wq, &ctx->rsrc_put_work, HZ);
+		mod_delayed_work(system_wq, &ctx->rsrc_put_work, delay);
 }
 
 static struct io_rsrc_node *io_rsrc_node_alloc(struct io_ring_ctx *ctx)



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux