Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp51838lqo; Wed, 15 May 2024 21:04:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV0E5VmfUFqHxMOeO646pXocV7ECoRj7AIzJJRMnXV0+zj/eNg9c2JIwGctzIfKIF03EI1FZYk4pg7YbrLNoivFxh14scVoTohZjTnQSA== X-Google-Smtp-Source: AGHT+IGEFwAe67y62sJ7p8ZyKyd787GFZOrwBnN+UbLJAXkE3ATaPsawYQrX4DRk1WEOVf3RTkyp X-Received: by 2002:a9d:6a46:0:b0:6f0:e64f:de95 with SMTP id 46e09a7af769-6f0e90fb70amr20218178a34.2.1715832265676; Wed, 15 May 2024 21:04:25 -0700 (PDT) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-63409e818ddsi15145545a12.18.2024.05.15.21.04.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 21:04:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-180613-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=V1fMd5TB; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-180613-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180613-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 4999F282825 for ; Thu, 16 May 2024 04:04:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A31C3EA68; Thu, 16 May 2024 04:03:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="V1fMd5TB" Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2061.outbound.protection.outlook.com [40.107.255.61]) (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 699E3381BA for ; Thu, 16 May 2024 04:03:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.255.61 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715832192; cv=fail; b=MFsi/kjOg4+CnQu8kh2WKS++ZpNtN98Wt0KZzg0rX9DySZaQ6K9Tx0llZxrnCOYH31n6L1f6uM6yI3KS7Go6pDC4IB9yd6ZWUanR4vEi1m0bbqFNgIqKSLSANx/H5W+gBEK3BoEnq+cDti//O6pppMaSOJOo7LRD91AseggGk+U= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715832192; c=relaxed/simple; bh=Ka0RlUPOcraRrZGtj2xqynrRqvKUIqfl5gHglLt+BvI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=nRVT59XnprpI4j0IUa1JwM9HjpW26UZeaWnRs9fkeNJoNIA/ywLJMX0c0UX7eRO6dx89Md281qVrciEDI2wH8g7IDscj5JOZw/saRx7jm4i+TB35HWlUp56MihZaW/kmrfFAb8QvaWTr89ZDXlLZ1c//XPNAyCk9G0dlBQnJxSE= 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=V1fMd5TB; arc=fail smtp.client-ip=40.107.255.61 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=IYHn73MYgEBPDnqEBrCrQVe4wIXYTxZoMDb0iIX55SL7SxtLp3XYlutLF/Ro/hw0GM3TOK9LGt9ByJuLXh3cdS5EcltQwAsiN1gIlWa8yR7q86xUQbopK0BLRcfKXSE0W22O5JjAouukSvOeg4zpKVUJCe1M1nKZ+0wcgsogaxGvgNfR8EC4r1RUzsxy1fXZi6YLMfwnNTGhOVIOkRdeQ7aMg4olHMZmP9v+2x7DHfg6k3Kv9aK3/vjy5MCbz7AKy5rJbiomXiSfeSvl8Hx4WDaj7gbN9gdmo8QU8cbiCrKO8lgcPch6rJLIdn5RrqeNGrxMrytxU46x/IGGynEKag== 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=nKs5WdZzwkomYPS0Mul/DmPZJII3hnGM5ZYTHyiG7XSKo2pvF/A7MhDXznMELys5IscoPka3Q7k16vCDdPALLCPgRL21FXTs96gHzm+P0oua/tgGWSPDpO50utATtJRlCRd1VQAaiOYcVy7a5YBhfjc2Vpn1hq761zpvIX9/aCFHO5GPN2/9QKcKTewAJ8ATXfrHAXxahnOwiZjNfbvrwpqzdy+xSTuaDQHP0wlURfOfOBHUk/DPQi7xAMeXZPDiNm7bsCYpyeLuJRRRMUPxsib5d5qxtn6kOI8h/MGFn6KIB6fMLvJfJw4q6y6oqrhPn5lK/ooCNYF/T6lvRbvBIg== 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=V1fMd5TBeEERok9k7hFMGtZlL5Q5clxT2+WMQzHnpzxvM3viuUWvMZHjSAMmD5AxLR9PN0W7gBy8Jpv12enFR9xWU1SRT12inhA/hpxqYtxCnVe7yTEl3bAuzJcoX6/sUAECQlk/D8MEAYJ7lXcyu5N0NzaOL1u7RWxZzVjONiMbasEdOSsTJV3JVcADwmgs30XQgbU/pEcsgV+GIPT289uM+4DxPCWyNwy3oNpuMzqCN/yMZZTK1x0yngvAC20NspaDdKfX3WqsEJxpD68iIKTdHdagWrmCZHzTXyInxFDNv0SHuCouWMubdgoTnZ1wRhIgThkQnoazyLn+hI9lTA== 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 TYZPR06MB6807.apcprd06.prod.outlook.com (2603:1096:405:1c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55; Thu, 16 May 2024 04:03:08 +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 04:03:08 +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 v3 4/5] dm: Avoid sending redundant empty flush bios to the same block device Date: Thu, 16 May 2024 12:02:33 +0800 Message-Id: <20240516040235.115651-5-yang.yang@vivo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240516040235.115651-1-yang.yang@vivo.com> References: <20240516040235.115651-1-yang.yang@vivo.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: TYWPR01CA0017.jpnprd01.prod.outlook.com (2603:1096:400:a9::22) 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_|TYZPR06MB6807:EE_ X-MS-Office365-Filtering-Correlation-Id: b89b3dc9-ed10-43ab-ca0b-08dc755d1832 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|52116005|366007|376005|38350700005; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?yhv6CWBVdzL/jByVitzlQRNMXcz1kNbzO0OyhF5osZzTGvZNAtSjKrwguXAn?= =?us-ascii?Q?c19s04j9FGNY2GZQ4t2kQU8Qii1y65EwPxwtmr7YZDzD38Elnyq2tXcTvrd+?= =?us-ascii?Q?9zDMMyYN5V5aj6kcFzrAnWQUwYX0skPrM/TUvZuceMLbxjsDI+peiBGXOAVa?= =?us-ascii?Q?6TGgQIoRimaqU1ZYWf3Zqs66b7wZhwtyLPWiRJmDbB1wpQ/4u/uWOFt7IpK0?= =?us-ascii?Q?WnDAHnhXH+R8m6+Oy3BJLfkoBo4fEO97qMab6r60TRzSmRvRvo+We3dq2J61?= =?us-ascii?Q?b8fFjVb3lz0cwitQphhIefPGfTXt44TD4B8RF/edM0eUJqlneB3ikWBFkfDc?= =?us-ascii?Q?cevMhNlHPujv0yrG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T/9PE5oBtoq/?= =?us-ascii?Q?XxOAghY1fTfLPvW1Rp3aMA03Y+foziT8k4sEY84cyULe0MOBpDIEyd4ZBTTP?= =?us-ascii?Q?XfLE5R+C7IfxhYu6HzfIscGanMaQ14+REFm9tJ9nDD0Mfg=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)(1800799015)(52116005)(366007)(376005)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?C0+vmcGrBrcHUoHV90iGBt6PLFd/qXcECOu7NXB6j1EJEYu0qx6EOYuGBkV2?= =?us-ascii?Q?s0H4IyaSsjwtTlYjhwpu06mbxMcVBNkub7FP888fOCJxGGeuJyIOg8nTTB3w?= =?us-ascii?Q?h+5Wch8k9mz3yn4kGHRhlSeq1/gL5N/XwEMH6Qj3spJSE2CtrDtk18wHi8Nt?= =?us-ascii?Q?R/D1b/LsNFNB1w8iIBL7nfgP8mYdGfEkd2khO93tKgvWijVXxMAClyNwHqXK?= =?us-ascii?Q?D07LAr+mYAosLMyB9deRpD9vf3mH++uh/rErvNZgSLLCqJQzhqA65mnFk7XT?= =?us-ascii?Q?ChwwxxhLM7iKXr4gAp6HUZ7HNKZM++i6BLr9k2G1NS8mf8mpAtqC2LdgNbF9?= =?us-ascii?Q?kOkjTenlIV62zaSJw0sVkbYYtprCFqFvMM7uUAxoPY5bTCghWBhp02JzrTGq?= =?us-ascii?Q?bokDi8ak/4sn6kFgj5to+YeOTff7IZu1nJ7mNpvq4f04u4OZN+1lWI1yhKca?= =?us-ascii?Q?qDukUZchPLorsIwoaXUmFvnN6CCKzFHs795B3+ZhysE4htwLFQZgqxfilh7j?= =?us-ascii?Q?an43kDulxpZNnEJlfIwmpv0f9HLIAZ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-ascii?Q?mcEPnAGPMkOAdcFsYC9EfS6djb+zUpvw5/h+z4tk7uJyK92bnLuZEicajkIQ?= =?us-ascii?Q?StnEqxoXqtkwmqBNj1cjp+yGz/2J9k5LIRRImGhDvG5xkftDZTKLoq0Da47X?= =?us-ascii?Q?RD6r3ySHocoJoFRYh8Q/LcIF+j+ztEvJrBPm2Yky?= X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b89b3dc9-ed10-43ab-ca0b-08dc755d1832 X-MS-Exchange-CrossTenant-AuthSource: TYSPR06MB6411.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 May 2024 04:03:07.9543 (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: CXCPGhp6pFtCw+jrl1s5RCiGxcrIuvMBU+KnfJB3rg9bisfFXPE3lACIbhgpk799qQI+91zmPvclQc7g/Dk1cQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB6807 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