[Devel] [PATCH hci-8.2 1/9] dm-qcow2: move md_pages_lock off the deferred_lock cache line

Denis V. Lunev den at openvz.org
Wed Nov 25 04:25:17 MSK 2026


From: Denis V. Lunev <den at openvz.org>

Every request submitted to the device takes deferred_lock in
qcow2_submit_embedded_qio(), and every metadata parse takes
md_pages_lock in parse_metadata(). With the fast path both run on all
submitting CPUs at once. The two locks share a cache line, so each
one's traffic bounces the line under the other one's holders, and the
cost grows with the number of submitting CPUs.

Give md_pages_lock a cache line of its own and keep each lock next to
the lists it protects: the qio queues with deferred_lock, the discard
wait list and the writeback batch lists with md_pages_lock.

https://virtuozzo.atlassian.net/browse/VSTOR-95494
Feature: dm-qcow2: block device over QCOW2 files driver
Signed-off-by: Denis V. Lunev <den at openvz.org>
---
 drivers/md/dm-qcow2.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm-qcow2.h b/drivers/md/dm-qcow2.h
index 6c5d3e932691..1647ffa363aa 100644
--- a/drivers/md/dm-qcow2.h
+++ b/drivers/md/dm-qcow2.h
@@ -286,11 +286,11 @@ struct qcow2 {
 	u32 fault_injection; /* In 1%/QCOW2_FAULT_RATIO */
 
 	spinlock_t deferred_lock ____cacheline_aligned;
-	spinlock_t md_pages_lock;
-
 	struct list_head qios[QLIST_COUNT];
 	struct list_head resubmit_qios;
 	struct list_head paused_qios; /* For pause_submitting_qios */
+
+	spinlock_t md_pages_lock ____cacheline_aligned;
 	struct list_head discard_wait_list;
 
 	/* For batching md update: */
-- 
2.55.0



More information about the Devel mailing list