From patchwork Fri Sep 15 18:38:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pankaj Raghav (Samsung)" X-Patchwork-Id: 13387463 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3390EED61A for ; Fri, 15 Sep 2023 18:39:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 94D5E6B03B1; Fri, 15 Sep 2023 14:39:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FDDF6B03B2; Fri, 15 Sep 2023 14:39:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7C56A6B03B3; Fri, 15 Sep 2023 14:39:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 6931F6B03B1 for ; Fri, 15 Sep 2023 14:39:03 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 390921A0BFF for ; Fri, 15 Sep 2023 18:39:03 +0000 (UTC) X-FDA: 81239693766.28.31A9259 Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by imf15.hostedemail.com (Postfix) with ESMTP id 8B871A0006 for ; Fri, 15 Sep 2023 18:39:01 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=H7FtLCns; dmarc=none; spf=pass (imf15.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.152 as permitted sender) smtp.mailfrom=me@pankajraghav.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694803141; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=brBNMMPFZ5PlP6sQBgu5Kl4G5NsTW4oPgHcishpd4rM=; b=QT8GJtNOnqk2w+RrqBnqrjpAJ+6jEcykLvGyWctYjG6yI/lsLTSWNPa7cRH9I8Rd7xGiXt 6AQ82aQSzEciuy0DctMeBStIbkW1RDqqJfiTxHv8g6hkzFjRhk93hlnjzB1leTVrtWDWKh a0ypEHPsLghRnBH+qZ3Rot275JAHQzg= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=H7FtLCns; dmarc=none; spf=pass (imf15.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.152 as permitted sender) smtp.mailfrom=me@pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694803141; a=rsa-sha256; cv=none; b=1GbIct3znCBn3Z7IIpHvkg/aX2DNJPDGXOi3XZVIvYM+v7ww/kUIITxcBAXnrzSBAf0N5F y/lu68C7B5vmmpbHO0//Aw+02YhVUGFppZqiGI+GCCMnSLqi/UjhQpQOagjAC9wtlWK/7m xchu0S1jqXnMrzQrnsD8n60gMme2phY= Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4RnNJ229ddz9sb6; Fri, 15 Sep 2023 20:38:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803138; 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=brBNMMPFZ5PlP6sQBgu5Kl4G5NsTW4oPgHcishpd4rM=; b=H7FtLCnsLxyZnEESEUmlYWwS3HUNf7y+ztfA2o6k0H9UD8DCi3iwUcQnp3b4jG22OqxQbD QFM0/lErD72ozGWznO0iOZsF/atrGWdf8N0u0R3Hkq8bk4gUT8aW8HcT+jRBFgWwrxd5Uu Vus+AuRm5kbgPF1yfrMOE6cGiK4o8d/jv+ywz+Xqn4cOuOZ1fLpob2vRdUi+oU+M3pmIxD 7LGMNt7s1tjXR7rXizanhCgb+FofT9t8HGdpJGNM+Kvt4gFJP8E3aU4RSYvWNgOL3dM2Cw rRU9mtKpZUVYEbkvs1/Q3spYJvwdrLhTQ+XZxP+V81DGW/fDC1ukMiA9Fhc+fQ== From: Pankaj Raghav To: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: p.raghav@samsung.com, david@fromorbit.com, da.gomez@samsung.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, willy@infradead.org, djwong@kernel.org, linux-mm@kvack.org, chandan.babu@oracle.com, mcgrof@kernel.org, gost.dev@samsung.com Subject: [RFC 02/23] pagemap: use mapping_min_order in fgf_set_order() Date: Fri, 15 Sep 2023 20:38:27 +0200 Message-Id: <20230915183848.1018717-3-kernel@pankajraghav.com> In-Reply-To: <20230915183848.1018717-1-kernel@pankajraghav.com> References: <20230915183848.1018717-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 8B871A0006 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: bbt7x9b8f94ig34nqxy5mst9z685zsfs X-HE-Tag: 1694803141-534676 X-HE-Meta: U2FsdGVkX1+ICiIbu2xYFvK/yHbQGbba+IYmIS1IBGeHW/RX0tM3uVF5ZNHLQ/Q4UZqIH8WyrQIY0ltsV1HWgzIKf89D7YlvKjHYaTKVLktPARNXUgKWhoYBNlUVrYkYs3/iCItGFYxcCE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EgHaLg/e/+/VSjKaIZ1kEoDDsJ7NiNR19QEq4QpLhDt/+wIDz0pjsEY8yCL5uYSWKSnc7hmENYupeDn/TkJjCmeSi7oPMXGT6ySSDYOMyd4wqlCVNyD8K/jboeciGHo9uySVNd+wtM9FFxQ= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Pankaj Raghav fgf_set_order() encodes optimal order in fgp flags. Set it to at least mapping_min_order from the page cache. Default to the old behaviour if min_order is not set. Signed-off-by: Pankaj Raghav --- fs/iomap/buffered-io.c | 2 +- include/linux/pagemap.h | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index ae8673ce08b1..d4613fd550c4 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -549,7 +549,7 @@ struct folio *iomap_get_folio(struct iomap_iter *iter, loff_t pos, size_t len) if (iter->flags & IOMAP_NOWAIT) fgp |= FGP_NOWAIT; - fgp |= fgf_set_order(len); + fgp |= fgf_set_order(iter->inode->i_mapping, len); return __filemap_get_folio(iter->inode->i_mapping, pos >> PAGE_SHIFT, fgp, mapping_gfp_mask(iter->inode->i_mapping)); diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index d2b5308cc59e..5d392366420a 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -620,6 +620,7 @@ typedef unsigned int __bitwise fgf_t; /** * fgf_set_order - Encode a length in the fgf_t flags. + * @mapping: address_space struct from the inode * @size: The suggested size of the folio to create. * * The caller of __filemap_get_folio() can use this to suggest a preferred @@ -629,13 +630,13 @@ typedef unsigned int __bitwise fgf_t; * due to alignment constraints, memory pressure, or the presence of * other folios at nearby indices. */ -static inline fgf_t fgf_set_order(size_t size) +static inline fgf_t fgf_set_order(struct address_space *mapping, size_t size) { unsigned int shift = ilog2(size); + unsigned int min_order = mapping_min_folio_order(mapping); + int order = max(min_order, shift - PAGE_SHIFT); - if (shift <= PAGE_SHIFT) - return 0; - return (__force fgf_t)((shift - PAGE_SHIFT) << 26); + return (__force fgf_t)((order) << 26); } void *filemap_get_entry(struct address_space *mapping, pgoff_t index);