Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp129214lqo; Thu, 16 May 2024 01:05:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUtuYK4gbJ6vAxItzJfvJLXQKwJlwdxH6SI9hlv5gYSJvRD/Iae+S2qhdtdvlHp3p9l+IsRAynHkvgDptP+StN9k60TK2urDQd7ksps0w== X-Google-Smtp-Source: AGHT+IGfEtuupKWVo52aSPqCAbpeL8qdq0z6IrLFwcb/wWdvtq6MCvKmCaJk51fu3XqxGqJZwyb6 X-Received: by 2002:a05:6359:4c99:b0:192:84cb:925d with SMTP id e5c5f4694b2df-193bb5173d7mr1713117655d.8.1715846713488; Thu, 16 May 2024 01:05:13 -0700 (PDT) Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6341404fb0asi2070402a12.874.2024.05.16.01.05.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 01:05:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-180733-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=VuHs++ep; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-180733-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180733-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 27E92B21F3E for ; Thu, 16 May 2024 08:05:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1BA1C136672; Thu, 16 May 2024 08:04:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="VuHs++ep" Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2086.outbound.protection.outlook.com [40.107.117.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 764CB13443C for ; Thu, 16 May 2024 08:04:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.117.86 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715846656; cv=fail; b=BuyS5jcc3rFZgq2Ob7PqzTDGiS13Ffc0ba0Na26TEjWeTgxd+unrKxMLrcPMqv8MlgvwoxUuNyQvLEMoY0NbNZLNP8QnzP3w5DkPMmhI6WR71o9zyDmT7BCKGJ5biiLJKQ62Gb6anBRDmFNPzM29n16GbwaY2e1gcgDMLywDbRM= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715846656; c=relaxed/simple; bh=Ka0RlUPOcraRrZGtj2xqynrRqvKUIqfl5gHglLt+BvI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=u+DuTF4pL7H+z9L62fAACERpRRq9kaoiSQvaB7RZOul7lBWvlmxPeaJZWiY/Ncu6hsr9LinNtkORyliMEK/5BiAnNPX4c/KfFoxPx/Xq9bSLU5mUw1VNO8OM5EHEuC4xEtLagxed7vba5n+AqckTW9hAGx9dpXincbM7l3m6LT0= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com; spf=pass smtp.mailfrom=vivo.com; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b=VuHs++ep; arc=fail smtp.client-ip=40.107.117.86 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=vivo.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IeK1UKFCZk8WqQGk++D8O/mjhBWr/8XzSvee5/ceNu3kpJkrOo+M8WZxP1Tuq7PFXod+9zeU2M7JX7Rhi7iCqy3hPj95u1TIk1H8brXrlgflEGtDBQJStsVHPmJpoV0AxvjZ2Ifkr90j8NSSLilAoDxnngrc+GuQc1mpEeEC/JCHegoVrx4jMXqHidMgjtzCZCeXjjFJWYg/18nOT1//T1Tu9yeoiccclU0X9NjuafjDRkx5IWTMvNJsvVfsAg4RhRjm64SbhhOtltQ8qyePPARInt/OOFsScqJNmBPUqnB7ld/gg3DFSqNEPWYxFKOGmkQUc4QUFMdk4BGVbYgJGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IGw8QMlOkK53XoUQo8KmpkoyGxRrVd+a4gf6PImb2ko=; b=kGBbD7FpmM/SQGdqstEr7tIDfoaZJrA7JrOZ5K5x8BTmrIc/Yx/8WT4kMvk3iukzoRbx/G26N5rEhGmN/1tubaPtYR7ZuMgxhp/DuaX938p4KD/a2EhNN/pyco3XpmBnAcPVCyyaJP524Tv+n+f3XDHHiLEz7qtxQygh8nSxkS3XYUbuJnLgK1v6dUJclRE4VCIzOTEutqOJ/9HXLccNVuq+Sa5/60gLK5Xa8awYtklESDuIeDTUgCBJZ2oX5QJT2E7zOQv4egMA0MrokQXqCDFkysdjeElQiyAf+vf/tytXIZJIty/JEOvROqfz9IQp02H7SI0ixX6LCSlMG3oB+Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IGw8QMlOkK53XoUQo8KmpkoyGxRrVd+a4gf6PImb2ko=; b=VuHs++epf62mpRjBwVWA6S0JVCFSUS7NnT0FKh5EAeorLygHoLZSKJq6tt/c8UhyV6Lh/j0OV2n23YQ5pvZA+6BSv6U3sL003lbz0mPeL53bWxQV4BO31dryplb7/qAvsHzoUS3NZdZQwVAaW2idliOph6CVf0U5nvZd2H+KOwQBN1Nfn0R1gq07C9hp/kOnUEqBaLxR6l5lr2pByi2R+dFb6ont0o9RhZyuVZC3Gk9T4prOo8hAaBTUPgyxabRnwkz9Ah/YHXLOUv6gynGY1TAgA2bje+o5eiDwOsSsrBgyg7hfroLbi0MevWynXbUPCndMwhTEmRjymcgEXyF34w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from TYSPR06MB6411.apcprd06.prod.outlook.com (2603:1096:400:42a::11) by SEYPR06MB6830.apcprd06.prod.outlook.com (2603:1096:101:1b3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.28; Thu, 16 May 2024 08:04:13 +0000 Received: from TYSPR06MB6411.apcprd06.prod.outlook.com ([fe80::8e76:5af3:e027:ccee]) by TYSPR06MB6411.apcprd06.prod.outlook.com ([fe80::8e76:5af3:e027:ccee%3]) with mapi id 15.20.7587.025; Thu, 16 May 2024 08:04:13 +0000 From: Yang Yang To: Alasdair Kergon , Mike Snitzer , Mikulas Patocka , dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org Cc: Yang Yang Subject: [PATCH v4 4/5] dm: Avoid sending redundant empty flush bios to the same block device Date: Thu, 16 May 2024 16:03:17 +0800 Message-Id: <20240516080318.120231-5-yang.yang@vivo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240516080318.120231-1-yang.yang@vivo.com> References: <20240516080318.120231-1-yang.yang@vivo.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: TYCPR01CA0201.jpnprd01.prod.outlook.com (2603:1096:405:7a::18) To TYSPR06MB6411.apcprd06.prod.outlook.com (2603:1096:400:42a::11) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYSPR06MB6411:EE_|SEYPR06MB6830:EE_ X-MS-Office365-Filtering-Correlation-Id: 6ed83c32-e6bf-4f77-8611-08dc757ec67e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|52116005|1800799015|366007|38350700005; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?JjDkkDgH/Io2dPnOho9wjfvV9f1VsILh5Q1QRkJm+HoCwyehPWO8zmyLRKHE?= =?us-ascii?Q?Kaj3n2knHSakeH/J8Tai4fc/l5F47VhDDkxD4KDgLswEr7yry3iCjXHMuS/Y?= =?us-ascii?Q?oF50Dm10GJAcWiaYE1XrSmTbW9Wr+yFlQG/yr7hJT8NajMnvH0OAhVQG2MaI?= =?us-ascii?Q?SMMXbmT0p7L7lxFWyCip6S7HclCYr++K6JJWlWC0FkmnpSZC7ENctCTRzN7z?= =?us-ascii?Q?QgrHsbg5H0N67uIqGW+ZOUjutJqI8Vh3ZcWndGcHYxSR5PJpnzrh16LiHJ4u?= =?us-ascii?Q?egweAvzkkQTDPI3pOf66vLQQCriZM1S8XK4LP92d7KFb/52PP+F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OAvIlmCsvTd5e05zpaH7/zCB5W4XmhY+Hdg1?= =?us-ascii?Q?n5r6LiFqVn4ofJgg97knwa5LSYLy9pDDkoEdlWh31whoPAjm9OKrFbBTXDg+?= =?us-ascii?Q?I4IrWrJQUmiavLM6kpX3mIA08RGfFqYA7VewrXNCBEu71g=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYSPR06MB6411.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(52116005)(1800799015)(366007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?KI/mL0AeTwWoy0nDbkTVNimcTYlcZCzqAHb/hZcR9/elYENcp5tWyBsGDKfr?= =?us-ascii?Q?Hk/ke9z9eqoVCuFh6lyXu9HIplzjYUR5djQO4/PkaKK9XTUd4uKqVf5D/hGA?= =?us-ascii?Q?xdy6flGJ7+CfJElNZ5X3VtMTwcz8GXPfpwwXKe+9+u3dsnTHWj5VPbn0/Y+u?= =?us-ascii?Q?Dd1LyxJMHQSWifpiG6k7ypG16BNxGV1V293ICLg28ETO73iFHmTin25b1tUa?= =?us-ascii?Q?gWBvjkWv8YTa5jyiC6UEVqiu2VujB1WsfpEmMi+ne8OGMw51nHkM3BJ3tUha?= =?us-ascii?Q?AJsVdhFZ96EnobwKA5rEq3MkysZlQeZsnIbWwaALaNUYlUAWbvtLNgUo8wDr?= =?us-ascii?Q?/xWbvrZdudGCSj6X07hCULhowzV75JMFz/H2xWrOO0kYr5+Qpp1OGmuJMdgs?= =?us-ascii?Q?fCV2GKatKng8KQKwA7DImaNW5XPJ+vbq7c1tjubITLO/P5w3nwyXnZ4oDnmr?= =?us-ascii?Q?AEkZh51uaPNjXLl7aOStN+YJXkK8ZDfJK09c4uCw5MrcxY4MYoDS+u7diwgG?= =?us-ascii?Q?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QhyuSZxoLKyc4Gf?= =?us-ascii?Q?KRH4jyrQlp4q+FDUB1hPPOJHZvHYEFlft7W9sxKhHkVyaJ3X0Qn48ybj0Wzu?= =?us-ascii?Q?VgCp7adsC5BZWnBBnS9TOhSrM98nIpsi0wNBcyM0lUeZalU+Cpe96aGRHAGb?= =?us-ascii?Q?PH7qMMtqT63K27IpgA4v30WqdyET4hCDD52hPmdb?= X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6ed83c32-e6bf-4f77-8611-08dc757ec67e X-MS-Exchange-CrossTenant-AuthSource: TYSPR06MB6411.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 May 2024 08:04:13.7946 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: BeI8ubqFgMmQgk3sx0uObkAM5DLSuUeWSr6zRd/matPnYRh57OfKCW54NCLxsb3d9I21+5M3wyMqmrwsEi0X+A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB6830 If the num_targets is greater than the number of dm_devs in the dm_table's devices list, __send_empty_flush() might invoke __send_duplicate_bios() multiple times for the same block device. This could lead to a substantial decrease in performance when num_targets significantly exceeds the number of dm_devs. This patch ensure that __send_duplicate_bios() is only called once for each dm_dev. Signed-off-by: Yang Yang --- drivers/md/dm.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 25215b93c3cf..9dd0f5c97028 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1561,6 +1561,7 @@ static void __send_empty_flush(struct clone_info *ci) { struct dm_table *t = ci->map; struct bio flush_bio; + struct dm_dev_internal *dd; /* * Use an on-stack bio for this, it's safe since we don't @@ -1574,10 +1575,18 @@ static void __send_empty_flush(struct clone_info *ci) ci->sector_count = 0; ci->io->tio.clone.bi_iter.bi_size = 0; - for (unsigned int i = 0; i < t->num_targets; i++) { - struct dm_target *ti = dm_table_get_target(t, i); + if (!t->flush_pass_around) { + for (unsigned int i = 0; i < t->num_targets; i++) { + struct dm_target *ti = dm_table_get_target(t, i); + __send_empty_flush_bios(t, ti, ci); + } + } else { + down_read(&t->devices_lock); + + list_for_each_entry(dd, dm_table_get_devices(t), list) + __send_empty_flush_bios(t, dd->dm_dev->ti, ci); - __send_empty_flush_bios(t, ti, ci); + up_read(&t->devices_lock); } /* -- 2.34.1