Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1408529lqh; Mon, 6 May 2024 07:02:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVDRWV52bB6iYqiA+V0Hs3IAxo3VWIQGx8LHxdoX0aicZJ7nGzhCQM/VyhNByzMfca3rz/ORijoC2jysY/+MViV090LyACFggAKh6S28Q== X-Google-Smtp-Source: AGHT+IHzISy2j+K6B6Ull4rgCtgdDPOZBoqi7deBUw3XA5uoTiQsGWIaDzQoKhLvZGGtnmVO6+XQ X-Received: by 2002:a17:907:1b09:b0:a59:9a28:f1b9 with SMTP id mp9-20020a1709071b0900b00a599a28f1b9mr6769866ejc.67.1715004162124; Mon, 06 May 2024 07:02:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715004162; cv=pass; d=google.com; s=arc-20160816; b=dQUa8c00OdpiVKw+U1YVwsmW12zE/IKvkXAMGmFfLoWrOPWZb2Vw8S5jiATVYvrdRw CGPHRyKiRMxG1iWBq33Xokg+8s+Y6Ow4mM8LOtcr5tqtZ9fwXycd7GjHd+PAABrNDEtj 0Md+JeXFkhR9/c8IWdKdTygXSdRACD7oLS4WLTcA7rarGRwFgU9E6ZoPu5hMfC3lTpdR LrNe8ppiF2fi4cFbGwdLbVZSZf72t7qaVWzdDe7+1ijkY2a7OPYS0aPuK6urhTUGltTj iNVbji0Sa3ILHDXF98syWcwWfCAR8wJ8pSYdyssL1D/lYN2+xfYBGINJ0jGw3rKofgK/ c/PA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:user-agent:date :message-id:from:references:cc:to:subject; bh=tzirr46AhQV2sydmBjvhNQR+wDT1i0w3GQuUVDio51E=; fh=Osh4uBb3kdyegO/YWwQoGUhCgrrzgbnUvsz5EKu0a8s=; b=SiIzvKOiIMQ36a5ggSpje02gsmvqchONBnfd/HYUiUEeSQ0L/rrBi6aREkksarXTy/ fQyvSBqzqxXij2dh9ZF45wVcduAjKXawBt2h6WVnWSSXO18V4LFFosP+m/HqmcY58Uxk yhaUpYTLrYA5I5dSYJES7ThrpC0Eyud9B6krcRT5986hFQRueDIFbPyqPgqSpjLm7vfT KCf+OkslJ0XOFncJlXIhUzjmiqEjSJYi+v+TEouo/M5o6wZJpp7j0yZHUoRJeA6+EKSm O55Wn4wpOTCZrnDbPwG51eKd3vSscalTQ0UGMClEZC/mdzGh0FbvF+iR2donCBxrUZYq nQfA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-ext4+bounces-2317-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2317-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id qb12-20020a1709077e8c00b00a59b7220ff2si2355445ejc.414.2024.05.06.07.02.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 07:02:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-2317-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-ext4+bounces-2317-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2317-linux.lists.archive=gmail.com@vger.kernel.org" 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 am.mirrors.kernel.org (Postfix) with ESMTPS id ED7631F22DEB for ; Mon, 6 May 2024 14:02:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C365381742; Mon, 6 May 2024 14:02:27 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) (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 BFB25811F7; Mon, 6 May 2024 14:02:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715004147; cv=none; b=JeOSdDIM6flGsGZNLiL8s3ADaeAH+3gbSFeqlLqzdo0JTpsrTGVCKOIcEaPgZFt1crlJgy6TtLAgEMLX5D72iUAY+3umTP+nqIM1xtfk6XnPIlC4IUEqhx6p07HI3iqk1U54zkbP7qFrZ+nj3dIu5q+wh9xU/KZMhlKgG+ewuew= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715004147; c=relaxed/simple; bh=a/rC19e2I9iHG3TMQmCrv2WuR6H592ekcahsLjx1u+I=; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=PPY8rWEN+ZwCu3LKT4Ajbsf3yAgJmBDMXqd0mqtit3fZMTSj5p8e2hDGt/iC9VX00vUcZ8EPHbPJE8LEJdulwLSPoXAc9tw2YLfBSfhipVfupz9iKYw0TQot5dbvvNCZbiCd3Iq9ZHH/KRkQQbEvMy1yF86PXK4/DUObVKtZSCc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VY34g13G2z4f3lfy; Mon, 6 May 2024 22:02:11 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.75]) by mail.maildlp.com (Postfix) with ESMTP id E08041A0179; Mon, 6 May 2024 22:02:20 +0800 (CST) Received: from [10.174.179.80] (unknown [10.174.179.80]) by APP2 (Coremail) with SMTP id Syh0CgDnCg7q4jhmTvnUMA--.48428S3; Mon, 06 May 2024 22:02:20 +0800 (CST) Subject: Re: [RFC PATCH v4 33/34] ext4: don't mark IOMAP_F_DIRTY for buffer write To: Dave Chinner Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, ritesh.list@gmail.com, hch@infradead.org, djwong@kernel.org, willy@infradead.org, zokeefe@google.com, yi.zhang@huawei.com, chengzhihao1@huawei.com, yukuai3@huawei.com, wangkefeng.wang@huawei.com References: <20240410142948.2817554-1-yi.zhang@huaweicloud.com> <20240410150313.2820364-5-yi.zhang@huaweicloud.com> From: Zhang Yi Message-ID: <349d0d44-2ffc-6177-cf00-db7a3f48b60d@huaweicloud.com> Date: Mon, 6 May 2024 22:02:18 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CM-TRANSID:Syh0CgDnCg7q4jhmTvnUMA--.48428S3 X-Coremail-Antispam: 1UD129KBjvJXoWxur1DAF1DKw4rZr1kAF47Jwb_yoW5ArWDpr Z7Ka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 at 11:03:12PM +0800, Zhang Yi wrote: >> From: Zhang Yi >> >> The data sync dirty check in ext4_inode_datasync_dirty() is expansive >> since jbd2_transaction_committed() holds journal->j_state lock when >> journal is enabled, it costs a lot in high-concurrency iomap buffered >> read/write paths, but we never check IOMAP_F_DIRTY in these cases, so >> let's check it only in swap file, dax and direct IO cases. Tested by >> Unixbench on 100GB ramdisk: >> >> ./Run -c 128 -i 10 fstime fsbuffer fsdisk >> >> == without this patch == >> 128 CPUs in system; running 128 parallel copies of tests >> >> File Copy 1024 bufsize 2000 maxblocks 6332521.0 KBps >> File Copy 256 bufsize 500 maxblocks 1639726.0 KBps >> File Copy 4096 bufsize 8000 maxblocks 24018572.0 KBps >> >> == with this patch == >> 128 CPUs in system; running 128 parallel copies of tests >> >> File Copy 1024 bufsize 2000 maxblocks 49229257.0 KBps >> File Copy 256 bufsize 500 maxblocks 24057510.0 KBps >> File Copy 4096 bufsize 8000 maxblocks 75704437.0 KBps >> >> Signed-off-by: Zhang Yi >> --- >> fs/ext4/inode.c | 10 +++++++--- >> 1 file changed, 7 insertions(+), 3 deletions(-) >> >> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c >> index 1cb219d347af..269503749ef5 100644 >> --- a/fs/ext4/inode.c >> +++ b/fs/ext4/inode.c >> @@ -3281,9 +3281,13 @@ static void ext4_set_iomap(struct inode *inode, struct iomap *iomap, >> * there is no other metadata changes being made or are pending. >> */ >> iomap->flags = 0; >> - if (ext4_inode_datasync_dirty(inode) || >> - offset + length > i_size_read(inode)) >> - iomap->flags |= IOMAP_F_DIRTY; >> + if ((flags & (IOMAP_DAX | IOMAP_REPORT)) || >> + ((flags & (IOMAP_WRITE | IOMAP_DIRECT)) == >> + (IOMAP_WRITE | IOMAP_DIRECT))) { >> + if (offset + length > i_size_read(inode) || >> + ext4_inode_datasync_dirty(inode)) >> + iomap->flags |= IOMAP_F_DIRTY; >> + } > > NACK. This just adds a nasty landmine that anyone working on the > iomap infrastructure can step on. i.e. any time we add a new check > for IOMAP_F_DIRTY in the generic infrastructure, ext4 is going to > break because it won't set the IOMAP_F_DIRTY flag correctly. > > If checking an inode is dirty is expensive on ext4, then make it > less expensive and everyone will benefit. > > /me goes and looks at jbd2_transaction_committed() > > Oh, it it's just a sequence number comparison, and it needs a lock > because it has to dereference the running/committed transactions > structures to get the current sequence numbers. Why not just store > the commiting/running transaction tids in the journal_t, and then > you can sample them without needing any locking and the whole > ext4_inode_datasync_dirty() scalability problem goes away... > Indeed, it could be useful, and it seems could also simplify many other jbd2 processes. Thanks, Yi.