]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
loop: release the lo_work_lock before queue_work
authorZhaoyang Huang <zhaoyang.huang@unisoc.com>
Fri, 7 Feb 2025 09:19:42 +0000 (17:19 +0800)
committerJens Axboe <axboe@kernel.dk>
Tue, 11 Feb 2025 14:14:28 +0000 (07:14 -0700)
queue_work could spin on wq->cpu_pwq->pool->lock which could lead to
concurrent loop_process_work failed on lo_work_lock contention and
increase the request latency. Remove this combination by moving the
lock release ahead of queue_work.

Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
Link: https://lore.kernel.org/r/20250207091942.3966756-1-zhaoyang.huang@unisoc.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/loop.c

index c05fe27a96b64f1f1ea3868510fdd0c7f4937f55..68c943a77e410c39da7f0c5a5090a5324a1e3cab 100644 (file)
@@ -894,8 +894,8 @@ queue_work:
                cmd_list = &lo->rootcg_cmd_list;
        }
        list_add_tail(&cmd->list_entry, cmd_list);
-       queue_work(lo->workqueue, work);
        spin_unlock_irq(&lo->lo_work_lock);
+       queue_work(lo->workqueue, work);
 }
 
 static void loop_set_timer(struct loop_device *lo)