From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (mail.openvz.org [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id 6D9E080031 for ; Wed, 25 Nov 2026 01:27:01 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AP1Pm9t002578; Wed, 25 Nov 2026 04:25:49 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AP1Pm9t002578 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=default; t=1795569950; bh=6JRbW270uzFp2qlIck7uhEyNBJxK06/7rfBn7GyIP/U=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe; b=FNZ5anmh/p9uoMDTzUrPRP5Fa+ExAnF30tdoGC0+9Ex5M/WVe0ekXyWMQzcXgIORc 067EcTlB895NN9vm75pN/fmnhupwsFJTnVR5sin/ZyaqUlXJM1mA37ge6rKrKTQ2tC EZK6sr9tmMlBUxlhr0WTYXrjQ01TUslGlfgCNgW/Kdd0gfv2/+CWuZH+yYF/dVdxUa JP74hxRup8VramGULFxjIF+UeM1uwNU/xrYNXl7rUN1492CRIfVnwuhrbu5y2ZbiZA tdoplJsq3R5t651Lq5JC8xJyiaSIVNENb25YoPnGU3Z2vjyoRKdyrIs7X2VpvR6Tmv EGyV5diwRBAdg== Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AP1PbVB002507 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Wed, 25 Nov 2026 04:25:37 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AP1PbVB002507 Authentication-Results: mail.openvz.org; dkim=pass (2048-bit key) header.d=openvz.org header.i=@openvz.org header.b="aVa8FnRs" Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4ba01393800so33775385e9.1 for ; Tue, 24 Nov 2026 17:25:37 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErFUalFPH4uxM/AH7z8F/CSQg5LVaQegqRrbn+DOEmBn6K8zCP0/DlSFsMTXBknEaGsRFqRfnw==@openvz.org X-Gm-Message-State: APuU4Z9BP8jm3qH2N2K1YQjQZZyLgkRRHaMHHcxTdVEYH/ciIO6AB+Yy FsUlMgUJHKbFrFnGXRGFL1v/BVJ+3TMMoNAEUM9Y6KtYxPV9RVPY+H1Nn09IU29StJUu74Bf85r lEtrfkPmThHEebNDzBJOEYIpAF1Cec/XWxAkH7bTYTdr9dq3vhIQDZA== X-Gm-Gg: AZFdTZeSvLrV2DTZyuBwud9PHKwA+X7EC53XexYH8k0ErU2U/oq0mpE6aVFrnvN5B8w f0aHMBROA1GBsZh+cuUUllQ6lf5xaZNomLURayLDqK2muZKBcTk9yKCCOrtbdBys2yUDxG/mPYm jHV9OYpqkxmYNFHfRheSTTSwnIx0YljZnU7A46qw3MMlHSACge75uYzJaLmnVZACCjt+7Lj2XuG ZPIAh03+daXA0Jpa9mnMW3sZkmFwKwpiiumJuycbavDyQTCQTv/oLPJNreP+nMI/VpNsNHD0ZQQ gk5x5bggCA== X-Received: by 2002:a05:600c:3547:b0:4a2:a6e:80f5 with SMTP id 5b1f17b1804b1-4bb888098bfmr331716665e9.11.1795569937265; Tue, 24 Nov 2026 17:25:37 -0800 (PST) X-Received: by 2002:a05:600c:3547:b0:4a2:a6e:80f5 with SMTP id 5b1f17b1804b1-4bb888098bfmr331716505e9.11.1795569936830; Tue, 24 Nov 2026 17:25:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1795569936; cv=none; d=google.com; s=arc-20260327; b=RpSlvqzpFPUbnkkJ3xFiqM4La5AbA3RFxgQEiYVsHQM07Qxv34CZB4nqFTrywuOYWX rb1WP3o8XoDSe3cg7WPPMdJvI4cnHALpWP10gfnvAhtwggxLBmqtzpTEndpTK0HxGz6u MwLvAKzaJN5TZYVb9HHkPHgVIXxN3TS96qnZ00RUsSwdHj2QWGP0XOAAm/MZxM5FoHHz lJy/CRjJ8hGJsxUT5aMG5zic58bWYg3qX0ps/M6je7jaFKVryusgWrCj74hXc70Uk/Le BWzAklfIaQz19vLG1gIKW8pho0ctZeZnATiV2KVqAJdS3o8OXzHxHrBlsHc/Nn8Bbc/z lYSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=+saHKUvmgDeD/Er8HR2M685Jwp8QLzIzEzJa2ls09r8=; fh=Dt/eY6bRxOi5So2hWcnDfoHKcjGdcv8biRmHAjS9kZM=; b=C3TdUJ8DNX8isMMBUtvGVvKyrLTvdFAIM2a+KUPg2g5P/bwhofujHa24StXWMObTsA Ff3kCsV40zCbcvZBvXSsSGeKW+wGW8/Nh9hkEMPBKkbDWs70t/hrPKygbzNaOzEAGHWg ulzCghS+9OSotP7Se1/6hLker6hx7KV2f+9wStH9a+rUj4lCcFOgOO8Z48fOsqvZSlz2 2Kw1qgxq4KGH5V5uVy/rwQfwkaLkJYJEtphV6CZSmiMpNcK/VsTPXfrzE0Nu+Bs02ryQ 8nLVLZRsQX5QOKFKS9PK1rt9MdehZjRWXoXuK2fgRyJzLD9exwK589tzHruvYsTlEwIT KL0Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=aVa8FnRs; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:fc:665c:9984:4e97 as permitted sender) smtp.mailfrom=den@openvz.org; dara=neutral header.i=@openvz.org Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id 5b1f17b1804b1-4bb88755a6asor23359325e9.3.2026.11.24.17.25.36 for (Google Transport Security); Tue, 24 Nov 2026 17:25:36 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:fc:665c:9984:4e97 as permitted sender) client-ip=2a06:5b06:b600:300:fc:665c:9984:4e97; Authentication-Results: mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=aVa8FnRs; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:fc:665c:9984:4e97 as permitted sender) smtp.mailfrom=den@openvz.org; dara=neutral header.i=@openvz.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1795569936; x=1796174736; darn=openvz.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=+saHKUvmgDeD/Er8HR2M685Jwp8QLzIzEzJa2ls09r8=; b=aVa8FnRsW3cb4dFyThEcjmUzXOd+5WZt1IhGaiFOrXjEdkDRzy1GFi8b4M8Qq/f0Nh LP85/ublO6+2zA+yAr9loi1jBtPgdA1kmzZ/QnCj6jJCR2YxK/p3pwV+w7NBjvIsXS1s zNsneLILn1of9FpJnk8GQZ3Bju4zIFWRmyDh1esso19e7ABJZp7WImh5w9gkAFNAFWfM X+2wKkTk1tuy0NUfdQchfkhloLj/kyIEHqf54z032xup9QukaADxv7mfuc/1V/37Fum5 IUbOThAugKkbS/k1Nx9nb0kUd1vRB+gvO2Gcsd1Zbd0ajWZGMOy381zWoj5JoLwHrLuI 5Wxg== X-Forwarded-Encrypted: i=1; AL+hErEW0nbnIumjuXSSCil10GsQR9qEAL+ycjEmOzx+QIVTsuw5mW5cgQodDjzbD5AKVx4Hd8I5uw==@openvz.org X-Received: by 2002:a05:600d:1c:b0:4a4:fc8c:cfd9 with SMTP id 5b1f17b1804b1-4bb9de0d5ffmr96256075e9.25.1795569936459; Tue, 24 Nov 2026 17:25:36 -0800 (PST) Received: from artemis.sw.ru ([2a06:5b06:b600:300:fc:665c:9984:4e97]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb8526cbd0sm623632195e9.0.2026.11.24.17.25.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Nov 2026 17:25:36 -0800 (PST) From: "Denis V. Lunev" To: andrey.zhadchenko@virtuozzo.com, alexander.ivanov@virtuozzo.com, vasileios.almpanis@virtuozzo.com Date: Wed, 25 Nov 2026 02:25:22 +0100 Message-ID: <20261125012525.681662-7-den@openvz.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261125012525.681662-1-den@openvz.org> References: <20261125012525.681662-1-den@openvz.org> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.2 6/9] dm-rq: complete dm-qcow2 requests directly in task context X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org From: Denis V. Lunev dm-qcow2 ends a request through dm_complete_request(), which calls blk_mq_complete_request(). Request-based dm has one hardware queue by default, so this raises BLOCK_SOFTIRQ. The completion handler usually runs in task context, either in a target worker or when the backing store completes image I/O from a task (brd, FUSE, unwritten extent conversion). Raising the softirq from a task wakes ksoftirqd, and the completions wait for it to be scheduled, which costs IOPS and tail latency as the request rate grows. Add dm_complete_request_direct(), which in task context runs dm_softirq_done() in the caller via blk_mq_complete_request_direct(), and use it in qrq_endio(). This deliberately skips the IPI to the submitter's cache domain under the default rq_affinity=1 policy. Keep blk_mq_complete_request() for rq_affinity=2 to honour the submitting CPU preference, and for callers outside task context. Fault-injected timeouts still suppress completion. Only the target knows which locks it holds when the original request's bio end_io runs on its stack. dm-qcow2 calls its handler with no lock held. dm-multipath completes from end_clone_request() in whatever context the lower driver ends the clone, which is rarely a task, so it would gain little from switching helpers. The request may now end before the target handler returns. That could already happen when the raised softirq ran on an interrupt exit or in a ksoftirqd that preempted the handler. https://virtuozzo.atlassian.net/browse/VSTOR-95494 Feature: dm-qcow2: block device over QCOW2 files driver Signed-off-by: Denis V. Lunev --- drivers/md/dm-qcow2-map.c | 2 +- drivers/md/dm-rq.c | 20 ++++++++++++++++++++ drivers/md/dm-rq.h | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c index 17487f52c33e..d1dec85236b8 100644 --- a/drivers/md/dm-qcow2-map.c +++ b/drivers/md/dm-qcow2-map.c @@ -4834,7 +4834,7 @@ static void qrq_endio(struct qcow2_target *tgt, struct qio *qio, } mempool_free(qrq, tgt->qrq_pool); - dm_complete_request(rq, bi_status); + dm_complete_request_direct(rq, bi_status); } static void init_qrq(struct qcow2_rq *qrq, struct request *rq) diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c index 5a8cd59ec257..0d31fcf84aed 100644 --- a/drivers/md/dm-rq.c +++ b/drivers/md/dm-rq.c @@ -294,6 +294,26 @@ void dm_complete_request(struct request *rq, blk_status_t error) } EXPORT_SYMBOL(dm_complete_request); +/* + * Raising BLOCK_SOFTIRQ from a task wakes ksoftirqd. Complete inline + * if affinity permits. The caller must not hold a lock that completion + * of the original request may take. + */ +void dm_complete_request_direct(struct request *rq, blk_status_t error) +{ + struct dm_rq_target_io *tio = tio_from_request(rq); + + tio->error = error; + if (unlikely(blk_should_fake_timeout(rq->q))) + return; + + if (in_task() && !test_bit(QUEUE_FLAG_SAME_FORCE, &rq->q->queue_flags)) + blk_mq_complete_request_direct(rq, dm_softirq_done); + else + blk_mq_complete_request(rq); +} +EXPORT_SYMBOL(dm_complete_request_direct); + /* * Complete the not-mapped clone and the original request with the error status * through softirq context. diff --git a/drivers/md/dm-rq.h b/drivers/md/dm-rq.h index 53abc3cf9aee..d4d2460ee107 100644 --- a/drivers/md/dm-rq.h +++ b/drivers/md/dm-rq.h @@ -46,6 +46,7 @@ ssize_t dm_attr_rq_based_seq_io_merge_deadline_store(struct mapped_device *md, const char *buf, size_t count); void dm_complete_request(struct request *rq, blk_status_t error); +void dm_complete_request_direct(struct request *rq, blk_status_t error); void dm_requeue_original_rq(struct request *rq); #endif -- 2.55.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel