Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp804139lqo; Fri, 17 May 2024 01:56:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUyIEOMNBMi8v45TnoyVzL5PE6XV/SY3206nT4kDKbWa1E9YpFugqPtpV3F8ZL6ez3/xKDZgXtC3jKAxa3beOsjzeqnP95TQRh/s8DaPA== X-Google-Smtp-Source: AGHT+IGw6Fkns4gyzeenUMlj2h/ZrX0q4w0yAuAQ8JQ/SrrTtGeEZqrNguizAgrUwP/rX/Dyh0J1 X-Received: by 2002:a05:6808:19a9:b0:3c9:9473:4300 with SMTP id 5614622812f47-3c9970d1a4amr27114858b6e.48.1715936173328; Fri, 17 May 2024 01:56:13 -0700 (PDT) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-792bf361dcfsi1754330685a.553.2024.05.17.01.56.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 01:56:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181885-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b="T/K3cUJN"; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-181885-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181885-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 012A81C210C0 for ; Fri, 17 May 2024 08:56:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 87B601D53F; Fri, 17 May 2024 08:56:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="T/K3cUJN" Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2065.outbound.protection.outlook.com [40.107.255.65]) (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 5D0E0EEC0 for ; Fri, 17 May 2024 08:56:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.255.65 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715936166; cv=fail; b=ruKffsI2f6a0409MyCa1MLBJpFFPEsjsPATP5k9MhWIFW8QZ1QnH3MXIuB41VUMJxi7+ZhqekUiKRaLAGrkjI6lLdawGLUYgIbLJ3dgLDmF7z07gIf9UkUxooF3X57mzAcdQ26ch8+yiaDsObCSyu+ubGf6arsjPaU/O6ujfGKo= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715936166; c=relaxed/simple; bh=ZSmsmExMIV3BPtG8+G1d6pRZ/b2ouH0rKVPpia2B6o0=; h=Message-ID:Date:Subject:To:Cc:References:From:In-Reply-To: Content-Type:MIME-Version; b=SRnBSozcsdtmNj6XqspkZMbvr4gTp4UACIttbk4A/L91+kXRdtbts8VogIVrteZZFjkz52ROrfPYx3weyuQ0HLlcUu/h7RSC6hOOGosTiKT1kzhHEhgWpQV2W7+vTM8vtlwIkNfbMhXZF3ripmYKjrl+3bh119WIfplDRa5Fq3A= 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=T/K3cUJN; arc=fail smtp.client-ip=40.107.255.65 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=h3O6b3DJOnV6lqCJePybZm8jhsYNRUZNGiibP6deNDhF1vIfupP4H6JAbTf91BboNT5c7ifdBoS+KlxbiB27uRehubIf3ppg0RXudSvRl/G694lIaI8GiZpS2DqDpUYSRdyKiIeXUuMPg93jxnFGoDs1i5fpUCjPAU45pv+TcWBP4cjK4IP5H3knt4vee/ggDGMcC7yHsYI2UBxqQUBr0MPjikQ8RicsK4ZRdWSYebV6KQEL1vN/ODO0F2Afiw/Ge26RFXs2dGGp2ky+VLqRPGWYll0+0hLcO6boKhv8d+IGBg8WXszAQOTDu0S7pa0ecygkoDYwcrkzplvfHWXbSQ== 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=tEgLbXj89fXnxcQ5F4AHW/ghe8p3w/edsB60JjpnhZ0=; b=h5wYb7oesP2pnZe6LSS0Y02a4yHTN/fhp78MUFzYvGHacFMywwrvssakB8rh8X4gvvhezgV981VCodsTbF7eqTs0qruIXnB814ixjcPgCJ7r15NxwUZgLQ1SHumhXsfzqGkXsdkoaNtEp1LQxViL1kPuv44SgqZgJE64bu38DjmxTPfCr3k8HFYXSfgeTkwybRHgc2RD1RHRbdfIlY3uVkG5OZ+ltI3msyhcF/+Lw5yUDHex3B3xN4tbmb3ruz03SFtL/UDnKrvsVEfNbzSv3+lLIADUizAlFhF2MWKEgQBFPcA14FX1527dZVkN6ZgMSds4ASz66kXC1KlnYj6bGg== 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=tEgLbXj89fXnxcQ5F4AHW/ghe8p3w/edsB60JjpnhZ0=; b=T/K3cUJNAnhpbNj9pZFBzjqIUiGm1hYYlTfqHpZcdbaQQiXXQPF8RG18X8VL22cPCSI/tg7w5Xb02M1HOlFX5uUMiX1jWQu33P5Ibp3aPxIrqfeYHJaf8IyvU8LEW/Nz8Ay4ziqwUagr9XS3Ut6AjIfa7PYMD7LsRZIIBrJh2oOxYPSVwT69xz+uLSUPnHReRUA3vQ6sYxPkOUFAclAC78cXo+7a3Og7b3c2Z3V1gZg83LANMOcfN9Ln61gU4TiSnbteeng4VA06s15mlJEk+Bi/4RH1QeQ9lF/YOh4i5OpGoHJj6z9liT3TVEka5AyIJkPpAEP79o/01CXayy8H8g== 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 TYZPR06MB7141.apcprd06.prod.outlook.com (2603:1096:405:b7::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55; Fri, 17 May 2024 08:55:58 +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.028; Fri, 17 May 2024 08:55:58 +0000 Message-ID: <753c5305-6104-44e1-b402-a5ed6ea03d82@vivo.com> Date: Fri, 17 May 2024 16:55:55 +0800 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] dm: optimize flushes Content-Language: en-US To: Mikulas Patocka , Benjamin Marzinski Cc: Alasdair Kergon , Mike Snitzer , dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org References: <20240514090445.2847-1-yang.yang@vivo.com> <20240514090445.2847-4-yang.yang@vivo.com> <60bd4b9-8edd-7e22-ce8b-e5d0e43da195@redhat.com> <90f4beb-2e15-3f9-4bc2-0d13872e8ea@redhat.com> From: YangYang In-Reply-To: <90f4beb-2e15-3f9-4bc2-0d13872e8ea@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: TYCP286CA0321.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:3b7::14) 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_|TYZPR06MB7141:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c7a6461-7f70-43f0-5d67-08dc764f2b74 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|1800799015|366007; X-Microsoft-Antispam-Message-Info: =?utf-8?B?MXh2OW5GWXFKRnFTWjJ3eVYvV2d5US8vUEZCSkxMSmd1UWc4dkV5akxWNHJT?= =?utf-8?B?b3dTNGloSUdTakJBQTR0NEs1eWljMVFuS3p2cHdLUXpjb1JUWkRUMCtvcUwr?= =?utf-8?B?TXFzUUhjY1VlYzVQYm5yTFlTT1BxeUc4cHlGTjNUNGJKT1NwQWQ0SVlqVS9q?= =?utf-8?B?TVM5dGhGeHJYaW53ZlRJSlFJVk10MUFPQzNOZXNVaXl5VTFUL1l3YW5mUmRB?= =?utf-8?B?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eHo0MEpN?= =?utf-8?B?QjNyc0t1Q1NjNWE0M3YzaVpVL0R0dGdLc0pvNFloT3pqamt2MUFHOEFjUW80?= =?utf-8?B?Z1EvNW5mb0JHSkFDVzFMeGoxM2t6Z01YRkVzZTBPWm12VVlFMzVJZHhsaFRT?= =?utf-8?B?bVRPOWJyWVBnd0dwdkZUTkZNU29KWWhhejVDYkMwR1hWRmpRQUxMbXRsYzZq?= =?utf-8?B?UXFKVUQ4M3hQMklVZTNFTEd4OHRVUklDK1V4VGR4Vlk2SjBsWDZXajlVSE91?= =?utf-8?B?eXlYOFZsMGZMYms5K016OFlaR1VSTVlGT2hQQ29ZL3B6VWdaSmFqQnB0d1pr?= =?utf-8?B?K2VqMFZMaEFQRGdMblRtWVM5QUgxMlBNNzkrT2xyS1ZxbzhGNTRnR1EvOWVL?= =?utf-8?B?aWJHcm5nKzdZaENkQmFwWFNMMjE5YjZBMFJHOU44TGE4aFk3ZXdwM3JRR0cv?= =?utf-8?B?TExPSHNJTlQzYUVvOGRuTXo3ZXNBK2pDTlpodHBiWUxYb0ZyZHJwNXBVVWtL?= =?utf-8?Q?dI+30atXYt4BfDoaS1wGSikcAhMqP2FPC8URK+sSLvpk=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)(1800799015)(366007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?QlphMFdTcnVwc3V5ejZnMXJMYzVIaTF2VnBtbGtnQm9IUXE0TG93c0NXTTVK?= =?utf-8?B?aHVtbEx3enNoaWhVbWoxRHJHRkR0VEhiZTNJNXlWM0E0bFpGaGJUeU4vYjFO?= =?utf-8?B?VHNFL3duUUNXQlNOUUQyT21Ra200TjVQZVhDaUV4dTBXZnlJeVRhbl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kJqbGIrQWlybm15azM3djNYUk0yZFVZaXlV?= =?utf-8?B?NDJZNDRkMzVyS3FUeC8wTTF2OEtjbFB6RFFtWWhpSkhsMzBZTDdrVjBVckVQ?= =?utf-8?B?ZEdTQnp6L1htSVhYc2lteDcwaXIyU3Q4eFVZWjBIU0k3QkdrSSt2K3c1L3Jp?= =?utf-8?Q?3ROrn3gMYJC7hcLdDwy3YQiMZ?= X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5c7a6461-7f70-43f0-5d67-08dc764f2b74 X-MS-Exchange-CrossTenant-AuthSource: TYSPR06MB6411.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2024 08:55:58.4104 (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: wQUSZJE/dKnwL+8BJToJsIsZumIIKBCdBArt8x5TMiNVUrwlqDczpNrOHG/pFuRdi0wR+GGKRAs7g0JiGYtsgA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB7141 On 2024/5/17 4:49, Mikulas Patocka wrote: > Device mapper sends flush bios to all the targets and the targets send it > to the underlying device. That may be inefficient, for example if a table > contains 10 linear targets pointing to the same physical device, then > device mapper would send 10 flush bios to that device - despite the fact > that only one bio would be sufficient. > > This commit optimizes the flush behavior. It introduces a per-target > variable flush_pass_around - it is set when the target supports flush > optimization - currently, the dm-linear and dm-stripe targets support it. > When all the targets in a table have flush_pass_around, flush_pass_around > on the table is set. __send_empty_flush tests if the table has > flush_pass_around - and if it has, no flush bios are sent to the targets > and the list dm_table->devices is iterated and the flush bios are sent to > each member of the list. > > Signed-off-by: Mikulas Patocka > Reported-by: Yang Yang > > --- > drivers/md/dm-core.h | 4 ++- > drivers/md/dm-linear.c | 1 > drivers/md/dm-stripe.c | 1 > drivers/md/dm-table.c | 4 +++ > drivers/md/dm.c | 47 +++++++++++++++++++++++++++++------------- > include/linux/device-mapper.h | 5 ++++ > 6 files changed, 47 insertions(+), 15 deletions(-) > > Index: linux-2.6/drivers/md/dm-core.h > =================================================================== > --- linux-2.6.orig/drivers/md/dm-core.h 2024-05-15 16:56:49.000000000 +0200 > +++ linux-2.6/drivers/md/dm-core.h 2024-05-15 16:56:49.000000000 +0200 > @@ -206,7 +206,9 @@ struct dm_table { > > bool integrity_supported:1; > bool singleton:1; > - unsigned integrity_added:1; > + bool integrity_added:1; > + /* set if all the targets in the table have "flush_pass_around" set */ > + bool flush_pass_around:1; > > /* > * Indicates the rw permissions for the new logical device. This > Index: linux-2.6/drivers/md/dm-linear.c > =================================================================== > --- linux-2.6.orig/drivers/md/dm-linear.c 2024-05-15 16:56:49.000000000 +0200 > +++ linux-2.6/drivers/md/dm-linear.c 2024-05-15 16:56:49.000000000 +0200 > @@ -62,6 +62,7 @@ static int linear_ctr(struct dm_target * > ti->num_discard_bios = 1; > ti->num_secure_erase_bios = 1; > ti->num_write_zeroes_bios = 1; > + ti->flush_pass_around = true; > ti->private = lc; > return 0; > > Index: linux-2.6/drivers/md/dm-stripe.c > =================================================================== > --- linux-2.6.orig/drivers/md/dm-stripe.c 2024-05-15 16:56:49.000000000 +0200 > +++ linux-2.6/drivers/md/dm-stripe.c 2024-05-15 16:56:49.000000000 +0200 > @@ -157,6 +157,7 @@ static int stripe_ctr(struct dm_target * > ti->num_discard_bios = stripes; > ti->num_secure_erase_bios = stripes; > ti->num_write_zeroes_bios = stripes; > + ti->flush_pass_around = true; > > sc->chunk_size = chunk_size; > if (chunk_size & (chunk_size - 1)) > Index: linux-2.6/drivers/md/dm-table.c > =================================================================== > --- linux-2.6.orig/drivers/md/dm-table.c 2024-05-15 16:56:49.000000000 +0200 > +++ linux-2.6/drivers/md/dm-table.c 2024-05-15 16:56:49.000000000 +0200 > @@ -160,6 +160,7 @@ int dm_table_create(struct dm_table **re > t->type = DM_TYPE_NONE; > t->mode = mode; > t->md = md; > + t->flush_pass_around = 1; > *result = t; > return 0; > } > @@ -738,6 +739,9 @@ int dm_table_add_target(struct dm_table > if (ti->limit_swap_bios && !static_key_enabled(&swap_bios_enabled.key)) > static_branch_enable(&swap_bios_enabled); > > + if (!ti->flush_pass_around) > + t->flush_pass_around = false; > + > return 0; > > bad: > Index: linux-2.6/include/linux/device-mapper.h > =================================================================== > --- linux-2.6.orig/include/linux/device-mapper.h 2024-05-15 16:56:49.000000000 +0200 > +++ linux-2.6/include/linux/device-mapper.h 2024-05-15 16:56:49.000000000 +0200 > @@ -397,6 +397,11 @@ struct dm_target { > * bio_set_dev(). NOTE: ideally a target should _not_ need this. > */ > bool needs_bio_set_dev:1; > + > + /* > + * Set if the target supports flush optimization > + */ > + bool flush_pass_around:1; > }; > > void *dm_per_bio_data(struct bio *bio, size_t data_size); > Index: linux-2.6/drivers/md/dm.c > =================================================================== > --- linux-2.6.orig/drivers/md/dm.c 2024-05-15 16:56:49.000000000 +0200 > +++ linux-2.6/drivers/md/dm.c 2024-05-16 20:06:32.000000000 +0200 > @@ -645,7 +645,7 @@ static struct bio *alloc_tio(struct clon > > /* Set default bdev, but target must bio_set_dev() before issuing IO */ > clone->bi_bdev = md->disk->part0; > - if (unlikely(ti->needs_bio_set_dev)) > + if (likely(ti != NULL) && unlikely(ti->needs_bio_set_dev)) > bio_set_dev(clone, md->disk->part0); > > if (len) { > @@ -1107,7 +1107,7 @@ static void clone_endio(struct bio *bio) > blk_status_t error = bio->bi_status; > struct dm_target_io *tio = clone_to_tio(bio); > struct dm_target *ti = tio->ti; > - dm_endio_fn endio = ti->type->end_io; > + dm_endio_fn endio = likely(ti != NULL) ? ti->type->end_io : NULL; > struct dm_io *io = tio->io; > struct mapped_device *md = io->md; > > @@ -1154,7 +1154,7 @@ static void clone_endio(struct bio *bio) > } > > if (static_branch_unlikely(&swap_bios_enabled) && > - unlikely(swap_bios_limit(ti, bio))) > + likely(ti != NULL) && unlikely(swap_bios_limit(ti, bio))) > up(&md->swap_bios_semaphore); > > free_tio(bio); > @@ -1566,17 +1566,36 @@ static void __send_empty_flush(struct cl > ci->sector_count = 0; > ci->io->tio.clone.bi_iter.bi_size = 0; > > - for (unsigned int i = 0; i < t->num_targets; i++) { > - unsigned int bios; > - struct dm_target *ti = dm_table_get_target(t, i); > - > - if (unlikely(ti->num_flush_bios == 0)) > - continue; > - > - atomic_add(ti->num_flush_bios, &ci->io->io_count); > - bios = __send_duplicate_bios(ci, ti, ti->num_flush_bios, > - NULL, GFP_NOWAIT); > - atomic_sub(ti->num_flush_bios - bios, &ci->io->io_count); > + if (!t->flush_pass_around) { > + for (unsigned int i = 0; i < t->num_targets; i++) { > + unsigned int bios; > + struct dm_target *ti = dm_table_get_target(t, i); > + > + if (unlikely(ti->num_flush_bios == 0)) > + continue; > + > + atomic_add(ti->num_flush_bios, &ci->io->io_count); > + bios = __send_duplicate_bios(ci, ti, ti->num_flush_bios, > + NULL, GFP_NOWAIT); > + atomic_sub(ti->num_flush_bios - bios, &ci->io->io_count); > + } > + } else { > + /* > + * Note that there's no need to grab t->devices_lock here > + * because the targets that support flush pass-around don't > + * modify the list of devices. > + */ > + struct list_head *devices = dm_table_get_devices(t); > + unsigned int len = 0; > + struct dm_dev_internal *dd; > + list_for_each_entry(dd, devices, list) { > + struct bio *clone; > + clone = alloc_tio(ci, NULL, 0, &len, GFP_NOIO); > + atomic_add(1, &ci->io->io_count); > + bio_set_dev(clone, dd->dm_dev->bdev); > + clone->bi_end_io = clone_endio; > + dm_submit_bio_remap(clone, NULL); > + } > } > > /* > Thanks, I tested this patch, and it fixed the issue for me!