Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp720925lqs; Fri, 14 Jun 2024 03:59:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUzBwapiOQBEqZjhVYpOgH0zDiwKpRDu2ZbbmZWtSiWCDEkhFqwJvpZ0aeWcAWyilLzSYtqw4qTqqHpmZTtLK41QPZND8EniGNormiIag== X-Google-Smtp-Source: AGHT+IHOBov47/k0P27lKGjZTFDlrK0jY/ff3/dgUosuy31hU7i4I1EHowEcwZ6Pp0hjMEH9yBZL X-Received: by 2002:a17:903:41c9:b0:1f7:2dca:ea65 with SMTP id d9443c01a7336-1f862c25e20mr26574595ad.69.1718362795316; Fri, 14 Jun 2024 03:59:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718362795; cv=pass; d=google.com; s=arc-20160816; b=B+dPtZNU8mu7HP1EgCRQC12JyLkT2iSyqMR9AR8Z7HqWG8vLh3dVgupjR2/aT2EI/d oKhwxloBYR8VLOKTOE5L5gmWwE6ASD10jHucDoU0z8GGuvjAwZTbXqao+MU9m5McBlTN fj8SsbWQf00EksBs5UvSc6n17c9HrqCmsxhHYR0o2peOg+Wds8e+Emo0YrDifmXckFdC 5YygQqDbTi5l9m959dtCbyUiot3BcPG3aa2p7QvHxscEvz6Gm8G2fgHm2B96AIxv1Amj YHGNn4klA7OFHIH4HeGkZ8WWHOTMd3S4fR4tnqx2Xl+B4JRGd36khsrjVMsI5x81VZiG AZIA== 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:dkim-signature; bh=CrPG7rd88hoRsGFAKAqpUnCfo3BYaLv2EBMdGcByx7Q=; fh=P0iqb8nWt3LG5d71f7oTg2nvp+hp9ZVVIWQyZBNms5c=; b=A8txPuupW1bpYD7/At4RwQMu05qMMG4zjSzs3iar11AnRpiFJodMgD/9IpitM1dHRX 1ENXlE7v9zD3/2zEKIvcBtHzXO2OW5ntVdgaRG0CVddRyh+8xSuYsPhxwzd0WKtwC/lY cV2MkQ2TmKjJsDP4qLZr9kgo5bg43G/mIKNbkv0SUHthVFzFR7HtGBNslLYOp+udNCyE c4Lv/XUHsD5+EuU3QQppGFiFgx6+hAgS4yg++X3F7sAWXSxwgRTqqatT2W2oKVK62fKd JPl7ZH6Mf1LiKL3NtqUMNH+JiEb4T7kTfn4hxYri9wXr/0T3Tkj3Hl6fEzQcr2P9SEcu Yocg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@pankajraghav.com header.s=MBO0001 header.b=Q5m1RtaN; arc=pass (i=1 spf=pass spfdomain=pankajraghav.com dkim=pass dkdomain=pankajraghav.com dmarc=pass fromdomain=pankajraghav.com); spf=pass (google.com: domain of linux-kernel+bounces-214819-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214819-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pankajraghav.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f855f1ac33si32462735ad.598.2024.06.14.03.59.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 03:59:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-214819-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=@pankajraghav.com header.s=MBO0001 header.b=Q5m1RtaN; arc=pass (i=1 spf=pass spfdomain=pankajraghav.com dkim=pass dkdomain=pankajraghav.com dmarc=pass fromdomain=pankajraghav.com); spf=pass (google.com: domain of linux-kernel+bounces-214819-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214819-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pankajraghav.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 28F0128A74E for ; Fri, 14 Jun 2024 10:51:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C2738196C72; Fri, 14 Jun 2024 10:50:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pankajraghav.com header.i=@pankajraghav.com header.b="Q5m1RtaN" Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) (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 1111E1957F3; Fri, 14 Jun 2024 10:50:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.241.56.152 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718362243; cv=none; b=SE8L2w473O0bHwc38sb/V8AtwBd7gnr6HrOlCvrfgQuU+874cJz6D68VYCQVZ7FocQKCEOUmcg2j9PdzZk/F1I+sdTK18/6T2WgdbWimtlfdmP1QmEHsIBr6IY903fZanYJAHN/VgWyhmZqaijJZ06vL8m5fSArPHlL/zXORnbs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718362243; c=relaxed/simple; bh=RvT456eSgnYsXlxc1lkKdAdRmMkX5mVmeOV8t6IuOwg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nx5EhteC7GkVtb6Wpyfwm+s4JLygd4J2QISg/Jdj2lu3WDWDmmFLU3ap8RGnm6Dx1xB86KEBQKzDzRcqFPioqEx/J+AcNyQZkrgjZY3zptOJygCUlIxhnjtxJUP56tih4O1LGGfKv8LFZ37RBKLbFgh002kghEv3jM5H2u2pMTA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pankajraghav.com; spf=pass smtp.mailfrom=pankajraghav.com; dkim=pass (2048-bit key) header.d=pankajraghav.com header.i=@pankajraghav.com header.b=Q5m1RtaN; arc=none smtp.client-ip=80.241.56.152 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pankajraghav.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pankajraghav.com Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4W0wzd0hGQz9smv; Fri, 14 Jun 2024 12:50:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1718362237; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CrPG7rd88hoRsGFAKAqpUnCfo3BYaLv2EBMdGcByx7Q=; b=Q5m1RtaNRYG6C6VXOYfenCnmOjYk5x1yb12ZuGbpAeAZ8Rhui+dg9+0Yr1Vgm+SgpdoAU1 bc+WRZkN4/iEGSA7QPwIoxLd4VZuqwJiiowXy9l6/ue7d+jTdNa7Pu9ESNln4UVw6wASp+ QieShjvS2zhUL11VEDk+FDIJy43SM4HONoQAhG/UXyToM4NhC1lXhL7RTkA3YOxkdxBDmH nIBZPcF0X17uqCaDPbVZb1wSl86Y2iuzK1pLPlNg7i7xo9dF7La2kNC0IUStSBbKYuUxRf 5huoS3H8vkVSdAPASp+LNvVs/CE7oUGtLV8/+0sn0LCo6icl3g2UtAdBnmG83Q== From: "Pankaj Raghav (Samsung)" To: Brian Foster , Kent Overstreet Cc: linux-bcachefs@vger.kernel.org, willy@infradead.org, linux-kernel@vger.kernel.org, Pankaj Raghav Subject: [PATCH 2/2] bcachefs: set fgf order hint before starting a buffered write Date: Fri, 14 Jun 2024 10:50:31 +0000 Message-ID: <20240614105031.57032-3-kernel@pankajraghav.com> In-Reply-To: <20240614105031.57032-1-kernel@pankajraghav.com> References: <20240614105031.57032-1-kernel@pankajraghav.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4W0wzd0hGQz9smv From: Pankaj Raghav Set the preferred folio order in the fgp_flags by calling fgf_set_order(). Page cache will try to allocate large folio of the preferred order whenever possible instead of allocating multiple 0 order folios. This improves the buffered write performance up to 1.25x with default mount options and up to 1.57x when mounted with no_data_io option with the following fio workload: fio --name=bcachefs --filename=/mnt/test --size=100G \ --ioengine=io_uring --iodepth=16 --rw=write --bs=128k Signed-off-by: Pankaj Raghav --- fs/bcachefs/fs-io-buffered.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/bcachefs/fs-io-buffered.c b/fs/bcachefs/fs-io-buffered.c index 865691dd0173..1355d618f988 100644 --- a/fs/bcachefs/fs-io-buffered.c +++ b/fs/bcachefs/fs-io-buffered.c @@ -677,7 +677,8 @@ int bch2_write_begin(struct file *file, struct address_space *mapping, bch2_pagecache_add_get(inode); - folio = __filemap_get_folio(mapping, pos >> PAGE_SHIFT, FGP_WRITEBEGIN, + folio = __filemap_get_folio(mapping, pos >> PAGE_SHIFT, + FGP_WRITEBEGIN | fgf_set_order(len), mapping_gfp_mask(mapping)); if (IS_ERR_OR_NULL(folio)) goto err_unlock; @@ -819,7 +820,7 @@ static int __bch2_buffered_write(struct bch_inode_info *inode, darray_init(&fs); ret = bch2_filemap_get_contig_folios_d(mapping, pos, end, - FGP_WRITEBEGIN, + FGP_WRITEBEGIN | fgf_set_order(len), mapping_gfp_mask(mapping), &fs); if (ret) goto out; -- 2.44.1