Received: by 2002:ab2:2997:0:b0:1ec:cbc4:63fb with SMTP id n23csp373053lqb; Thu, 29 Feb 2024 03:46:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXOE/JyKrfX61mk6hk4E1QBbjoAIwovRtfkl3Gq0n/qC/DSa8cHnXFP4dYPPggtUsO3/P4cf8nyI7xsSZA/CrgSKqeOgbtfgt0QsEgPyg== X-Google-Smtp-Source: AGHT+IHrSNAufaMj8Q1qJxgTxZtbUUY1bzm1rt5D4bwsspodOo10zjUd5f3H7xNk80g3G9dKUrS9 X-Received: by 2002:a37:f512:0:b0:787:c94e:840e with SMTP id l18-20020a37f512000000b00787c94e840emr1903384qkk.48.1709207184866; Thu, 29 Feb 2024 03:46:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709207184; cv=pass; d=google.com; s=arc-20160816; b=ndf1q9g1jk/qtyKVzPf8WSvdCD0kQPvrdp313XDzQA4h3oQSyuin4II0tPUba5bDUy VIjR86aXo9FgyAYG0P04lD/+xDr/AY6kwJP+XYLO5wBmeg3JgkNy/IqGTgbijYje62EU rWX4xGfCsXzVxFrI6yztGyndeN4hpylwNFcpObL6I2DGIfJKGZpK5xWqf8/1cAxJ/A8+ POdOqwwG7T2E7L6N+pOkh85YfeLJnzWMN9D8zWZ2zElAYPL4+RZywYr8R8QZDM3JctVj kN+jfySCPgTtFvUd9fxPT6m5Bwr2peGE0pXxBqRd+MCDdS/lUiq9iySXO7P7ooGLttt+ xWzw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=YdMTeFJeZCTxkHL2GBhprs0X8a/xbkUYyOntwU/EAbc=; fh=j8iJztQoZH37+dp0KfN6lSelMFOlYR/AH5vS0AfPd/0=; b=h52C2AyZqaG0YgZEMZGZ7Ny2zt11f7N+xzOFfDZvjPH7sVY/lpdkaCwsHLUpBV2+5j WZqo7JTVPGOtDcEzt287qkB0prNUqALKXKTHhmLOOj7gmQle/EQE2OD+rqAuYgvr9OlL gyPNz7JOh7sfDYlMhNRUggcSNce4xMMj9ckzxwCfouKu0oSLyvy4SypLyhCy3TRiZBDg x+r2ITabO3W4eQa3hW078G2+f7OYjASheXbhNnHl3PbdcFUmjX1NCWy6CMObPYVCY3Wh yED6zuJ4yhaPGos7HnHCQT12Lb/3eRMdUTX3HXu86/9BqDMxpIBRKDKNWFj+BVjbJxhz IGaA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-ext4+bounces-1430-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1430-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o9-20020a05620a22c900b00787c781083asi1226533qki.48.2024.02.29.03.46.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 03:46:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1430-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; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-ext4+bounces-1430-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1430-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.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 965BE1C20A1A for ; Thu, 29 Feb 2024 11:46:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F32367D09B; Thu, 29 Feb 2024 11:45:37 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (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 206917C6D2; Thu, 29 Feb 2024 11:45:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.35 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709207137; cv=none; b=FkwW9lJP2IkkEs2JpH/KlataUMMQuMAxX5At28vnfOjXvdTF95uIv5dA4+1l9vUVzU/86h3DApvlNzmy+z5eC181oB5hQLF3nnBNdmcDzMmjwu/09iuPEizAQWJ0TQJDU0AmpW+HCa+p2LcUeY+Pc3Xvf1CVIhrSdK28Nv0c4XY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709207137; c=relaxed/simple; bh=jsKCtJRRKaJUiyg4hQpnl4lXKjzxpQzJM96ZLAswM1U=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nTJk4a7ox/Ysm5+VTRp66E6CKzWiemB1swaS/Comtsy6GX8qN7jhGJNTsTGBDAIBsGvm1ASv7MaG3wyqth0mLE+yKSt3kuPJMJQYDFVF9OnHYQGV0DHhuyhP32TdWHp8ZMvFQmQKP7FKYEhlTv7X6mG9rP6JO6qi7QfUKb0mtsw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.35 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4Tlq9J2Zkdz1Q9Mp; Thu, 29 Feb 2024 19:43:16 +0800 (CST) Received: from kwepemm600013.china.huawei.com (unknown [7.193.23.68]) by mail.maildlp.com (Postfix) with ESMTPS id 9670D140390; Thu, 29 Feb 2024 19:45:32 +0800 (CST) Received: from huawei.com (10.175.104.67) by kwepemm600013.china.huawei.com (7.193.23.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Thu, 29 Feb 2024 19:45:31 +0800 From: Zhihao Cheng To: , , , , CC: , , , , Subject: [PATCH RFC 2/2] ext4: Optimize endio process for DIO overwrites Date: Thu, 29 Feb 2024 19:38:49 +0800 Message-ID: <20240229113849.2222577-3-chengzhihao1@huawei.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240229113849.2222577-1-chengzhihao1@huawei.com> References: <20240229113849.2222577-1-chengzhihao1@huawei.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm600013.china.huawei.com (7.193.23.68) In DIO overwriting case, there is no need to convert unwritten exntents and ext4_handle_inode_extension() can be ignored, which means that endio process can be executed under irq context. Since commit 240930fb7e6b5 ("ext4: dio take shared inode lock when overwriting preallocated blocks") has provided a method to judge whether overwriting is happening, just do nothing in endio process if DIO overwriting happens. This patch enables ext4 processing endio under irq context in DIO overwriting case, which brings a performance improvement in the following fio test on a x86 physical machine with nvme when irq and fio run on the same cpu: Test: fio -direct=1 -iodepth=128 -rw=randwrite -ioengine=libaio -bs=4k -size=2G -numjobs=1 -overwrite=1 -time_based -runtime=60 -group_reporting -filename=/test/test -name=Rand_write_Testing --cpus_allowed=1 before: 953 MiB/s after: 1350 MiB/s, ~41% perf improvement. Suggested-by: Zhang Yi Signed-off-by: Zhihao Cheng --- fs/ext4/file.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 54d6ff22585c..411a05c6b96e 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -503,6 +503,7 @@ static ssize_t ext4_dio_write_iter(struct kiocb *iocb, struct iov_iter *from) loff_t offset = iocb->ki_pos; size_t count = iov_iter_count(from); const struct iomap_ops *iomap_ops = &ext4_iomap_ops; + const struct iomap_dio_ops *iomap_dops = &ext4_dio_write_ops; bool extend = false, unwritten = false; bool ilock_shared = true; int dio_flags = 0; @@ -572,9 +573,12 @@ static ssize_t ext4_dio_write_iter(struct kiocb *iocb, struct iov_iter *from) ext4_journal_stop(handle); } - if (ilock_shared && !unwritten) + if (ilock_shared && !unwritten) { iomap_ops = &ext4_iomap_overwrite_ops; - ret = iomap_dio_rw(iocb, from, iomap_ops, &ext4_dio_write_ops, + iomap_dops = NULL; + dio_flags = IOMAP_DIO_MAY_INLINE_COMP; + } + ret = iomap_dio_rw(iocb, from, iomap_ops, iomap_dops, dio_flags, NULL, 0); if (ret == -ENOTBLK) ret = 0; -- 2.39.2