From patchwork Thu Feb 29 11:38:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhihao Cheng X-Patchwork-Id: 208323 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp333829dyb; Thu, 29 Feb 2024 03:46:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWmAzGhlqILlgm8be6qrUnl5d66F6X466wfdBwgJHGbhUy0diIR/ebo6rNsC8y8JvfTGzVjTyVPGuSkD7efvijX4jOQVw== X-Google-Smtp-Source: AGHT+IFIuCVOfVkxK5Fhqc+CzlsFcOT0L06YCmpU+f57IuNDJu5hgTcFnm7ckEAsqlqAhS5J/X0d X-Received: by 2002:a05:6358:8a8:b0:17b:c1e6:c4dc with SMTP id m40-20020a05635808a800b0017bc1e6c4dcmr1929723rwj.21.1709207205292; Thu, 29 Feb 2024 03:46:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709207205; cv=pass; d=google.com; s=arc-20160816; b=MAEm1fyfVmNClkNmzkVGYzhONlCke7mWw8PSVE3p8Tcz0dORUr7nOB32MyGMOyCOqn syfRqLYFVESF3bM4i9pbDbBwZYvabui8RDpfQo9IxMok5QKbHv7jLpk0jxT+/mjB6FA0 Jb3aYAmrj/v0OiVYNrDAoJFWi0b3TCI7olmixLhTmMf88CHxlNmFnn6Jp59Oe+nfU8WR VlQz26AY8W2Pr5VozUgvYRyTY8uScjTRF7XzNejBEiONSjTL0wzF2jZqGvmfus+XhrDr UZe4ABRjsof5lfoFIYTUWYgOSBWwpC9VF7ezhFaPAVp3K0GKXBhj5dsgWer4WrEOumhh TfIw== 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=l7TpE+bRWx3aWSoe5SmNjVkaTm73uFrju/RBbLBdpC1j5uXpfBC4CBDUj2kIgll4OA qDR0ROD61zJn0stPXK7zG4svalqBGj+kWL0zKc2HQP2d+Np0+oy6OS+4Gvd5NWyelpeF iOK6jymDET+7y63YxEj9O7SqIiC6VyrlAvsxPunRy4P/QFxSQ7Lldq7jDmkjWWh5CXrV il24nDLDRrbfR/7y8B90y6+KG+/2WlxQO1sGnNqdtj8pbDT3+u3Oa2myufzHPTr4bvx7 foWGgdQbQpyVtgexXx1ujmVgAH8vmIeTE33mihVvEXekL4WuyqzRL6FTKqgzztZ2WRS+ yxEA==; 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-kernel+bounces-86651-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86651-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id qn18-20020a056214571200b0069007a575f5si1132151qvb.226.2024.02.29.03.46.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 03:46:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86651-ouuuleilei=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-kernel+bounces-86651-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86651-ouuuleilei=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 1773C1C20936 for ; Thu, 29 Feb 2024 11:46:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 676E87E0F8; Thu, 29 Feb 2024 11:45:39 +0000 (UTC) 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm600013.china.huawei.com (7.193.23.68) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792233654557093129 X-GMAIL-MSGID: 1792233654557093129 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;