From patchwork Fri Sep 15 18:38:26 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: 13387462 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 A2C7BEED61F for ; Fri, 15 Sep 2023 18:39:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3CEDF6B03AF; Fri, 15 Sep 2023 14:39:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3814A6B03B0; Fri, 15 Sep 2023 14:39:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 26E7E6B03B1; Fri, 15 Sep 2023 14:39:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 1A3296B03AF for ; Fri, 15 Sep 2023 14:39:01 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E684FC0776 for ; Fri, 15 Sep 2023 18:39:00 +0000 (UTC) X-FDA: 81239693640.17.EE62B30 Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by imf19.hostedemail.com (Postfix) with ESMTP id 165331A0017 for ; Fri, 15 Sep 2023 18:38:58 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=hsUb3KY4; dmarc=none; spf=pass (imf19.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.172 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=1694803139; 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=pCLutTTx1nXzynufX5Rc0GaxeJJRiIKE41sPKA97GlA=; b=lZJJtxCWoDtmbBrAtaoVlrUM+pKundQFCFbm9/N+EwAXxv7wmL20MVI9+efTzHIKv4iiH6 BOmOw5prh/VpddqOB1JrTtdXrB2ZgIS9572HYaR40xVXJXb6M0N3G6SP8gVAcQkwNlkITq +9+ke6nZkMX8TJHVc5WW+Ns30oX6HjE= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=hsUb3KY4; dmarc=none; spf=pass (imf19.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.172 as permitted sender) smtp.mailfrom=me@pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694803139; a=rsa-sha256; cv=none; b=VPLExujOv6z10umLplTY3e965Hv6zuyVb1Gk9nLwZYsWnmshCZKIzZefsHF/++T2dkU1K1 v0XECAKlLLmbzyqbNlt9cT4fVnNIbsA2xOyPAXUH9zC2GUVbj9F/DqDed5dtM8y6w5CFe3 XcaTBteWDYthxqYB0zZfh+NH0hFx1u4= Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (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-202.mailbox.org (Postfix) with ESMTPS id 4RnNHz3428z9sSS; Fri, 15 Sep 2023 20:38:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803135; 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=pCLutTTx1nXzynufX5Rc0GaxeJJRiIKE41sPKA97GlA=; b=hsUb3KY4XvzrJ/umA8hy7LoJ99BD3KFTp3A7geTDr8UuQPQSYjMxDoznaGguaLUp7+zDIb SpPpJCMfaXeSHycMiA5SkGcdhUnKdR3h+9BxRRTe16EO607wdLjOeBmcoXsuLn52tuqvDv 6vmC+15VxzBBalR61EhCSDFSmIsNKNLAGWw8wrAVsAyDjZWOJY6PUd+mtQyjsROOAYhLGS NBJ3482DeuVAANzY1Xw0ipSZdmdT2UWd+jwufpsrPntaDwop5mTrOij6aXocMWbBhTaL3+ hzIlOi0fN7bzc6CO2LU+jTDYY2GYSV06QMUd7bZZKQ4eRqAmRVXDL0y/e0ivFQ== 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 01/23] fs: Allow fine-grained control of folio sizes Date: Fri, 15 Sep 2023 20:38:26 +0200 Message-Id: <20230915183848.1018717-2-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-Server: rspam09 X-Rspamd-Queue-Id: 165331A0017 X-Stat-Signature: fz1t7p7niaf8u1gs1tww8enmfrhjunrm X-Rspam-User: X-HE-Tag: 1694803138-338917 X-HE-Meta: U2FsdGVkX1+QOgtx6K2XS2IG+IYjWyk6Xj2F79B+mE+NWgjqvlv4T0dU+GcA7EATAPQbQ+WP6B7ZXIbfkXk/Zs42uBUtD3PKImLcXE8FKG9ofu1mDpcT7WplHLeaihvb9nxUyI68PsftSrZPyv21ZWxNWadzs+5Tr/qeDNRhPZBsbh95EyoyJQQzuF9G60Ydq5+tn3W/N63s8n/FSmQX1nN8TxZyrn78+iNdIfOyARm0i7z+3oG4oh1VZTDE3EXQqehJrs2ESfz8L2ETf6rLhxMdoQF8TAflmMUGDxl1KJM+yXJxD9Nh1e742HjVw4az7+QKCcAsIzXE97jrSWQdifIO+GhjcNIthYm5eZlcdmsjowZ1ZDg+tNgCez+JEjRXK6OBJ4RK+8bVhUi+18rF9zIqm9cU1cxtO4IS+a8QNZa80DDeIJDRyCn0BOjHXTSDU+ub0J8m+/Gp1ag696aI1Nctu16qCL2GtIWlaFxjNPuIBSnvYzqEkFKrQQ/M/7uIj3me4Ec5i46yooUC+/8teYBsStBBTXBz5wUDFL4z3h9RKJ3O8Die/A8ABTkZRcj8wJE3ztOpAVaEs9K0maVRlpczBZrBHzE78CesHbphvR4wrUq9M3sRzDRqfLZnlGIv1YPNsh6hExI6wpvUkDfJ0T4Y8U3zVqx9J7vaTXsv4w64FyQqer4SpJ/3V8J2ZWCybWfPrFmq3SwSRz3xF9cMPYCmKMgOwCoG9XF47jaygTQiqRk/ePeIAsDqQmUODfu2Yok1r0s8biNloIgZtR7g+3oUoXyC1xo448yFnMxgmavlODMFXKTvioFd6v2YsApmHKb0YWqn+5WihY/1UaeFE/9F76MORJAhwwvPxJwLjE0qa0U3HFRicM9lrWDDqtjVyTQ67vrw5RNbzRE/BiIem45ppZzBXQRmVsr3t0g5RLEPoe+34hob5P0+HW32F7R8elwCnf8zg/UR3RXO8hM S7acYmhH HVuEi0kJBUrg35ntwkNLctFCEby6DaV1q0KKiZmP37Ln+3fuE5iApOgt++P0Wi/V1GEYMSZCdb3aUiQbyLJgf6YCcLIA5FBUFOFi453/VV3/MYIIPBtf4/gjKLKj00CZW0b26hy+58/JfS54bnA+oki8nC1ieJKrgfLllNkrzsVyAEkGBWAzJ1+esDN6hYb6jxnJqI07aYaqF8mNIgv/XIjF8UAlkmK0Q0wrL9LfYGnUnm16OlDIVzexSgA/AIeWOMPwM8GCj1F+ftYmoiVm6L+5my2HaJH9fGdBHQuzWUaVUAyzlwLL+wevwc87X/aE8ATBqbrRANnZllpXRmSWXmtpcitk4XW+rzICm6ptcWPYbCL+nlJ92KXST+w== 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: "Matthew Wilcox (Oracle)" Some filesystems want to be able to limit the maximum size of folios, and some want to be able to ensure that folios are at least a certain size. Add mapping_set_folio_orders() to allow this level of control. The max folio order parameter is ignored and it is always set to MAX_PAGECACHE_ORDER. [Pankaj]: added mapping_min_folio_order(), changed MAX_MASK to 0x0003e000 Signed-off-by: Pankaj Raghav [mcgrof: rebase in light of "mm, netfs, fscache: stop read optimisation when folio removed from pagecache" which adds AS_RELEASE_ALWAYS] Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/pagemap.h | 78 +++++++++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 18 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 759b29d9a69a..d2b5308cc59e 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -202,10 +202,16 @@ enum mapping_flags { AS_EXITING = 4, /* final truncate in progress */ /* writeback related tags are not used */ AS_NO_WRITEBACK_TAGS = 5, - AS_LARGE_FOLIO_SUPPORT = 6, - AS_RELEASE_ALWAYS, /* Call ->release_folio(), even if no private data */ + AS_RELEASE_ALWAYS = 6, /* Call ->release_folio(), even if no private data */ + AS_FOLIO_ORDER_MIN = 8, + AS_FOLIO_ORDER_MAX = 13, + /* 8-17 are used for FOLIO_ORDER */ }; +#define AS_FOLIO_ORDER_MIN_MASK 0x00001f00 +#define AS_FOLIO_ORDER_MAX_MASK 0x0003e000 +#define AS_FOLIO_ORDER_MASK (AS_FOLIO_ORDER_MIN_MASK | AS_FOLIO_ORDER_MAX_MASK) + /** * mapping_set_error - record a writeback error in the address_space * @mapping: the mapping in which an error should be set @@ -310,6 +316,46 @@ static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask) m->gfp_mask = mask; } +/* + * There are some parts of the kernel which assume that PMD entries + * are exactly HPAGE_PMD_ORDER. Those should be fixed, but until then, + * limit the maximum allocation order to PMD size. I'm not aware of any + * assumptions about maximum order if THP are disabled, but 8 seems like + * a good order (that's 1MB if you're using 4kB pages) + */ +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +#define MAX_PAGECACHE_ORDER HPAGE_PMD_ORDER +#else +#define MAX_PAGECACHE_ORDER 8 +#endif + +/* + * mapping_set_folio_orders() - Set the range of folio sizes supported. + * @mapping: The file. + * @min: Minimum folio order (between 0-MAX_PAGECACHE_ORDER inclusive). + * @max: Maximum folio order (between 0-MAX_PAGECACHE_ORDER inclusive). + * + * The filesystem should call this function in its inode constructor to + * indicate which sizes of folio the VFS can use to cache the contents + * of the file. This should only be used if the filesystem needs special + * handling of folio sizes (ie there is something the core cannot know). + * Do not tune it based on, eg, i_size. + * + * Context: This should not be called while the inode is active as it + * is non-atomic. + */ +static inline void mapping_set_folio_orders(struct address_space *mapping, + unsigned int min, unsigned int max) +{ + /* + * XXX: max is ignored as only minimum folio order is supported + * currently. + */ + mapping->flags = (mapping->flags & ~AS_FOLIO_ORDER_MASK) | + (min << AS_FOLIO_ORDER_MIN) | + (MAX_PAGECACHE_ORDER << AS_FOLIO_ORDER_MAX); +} + /** * mapping_set_large_folios() - Indicate the file supports large folios. * @mapping: The file. @@ -323,7 +369,17 @@ static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask) */ static inline void mapping_set_large_folios(struct address_space *mapping) { - __set_bit(AS_LARGE_FOLIO_SUPPORT, &mapping->flags); + mapping_set_folio_orders(mapping, 0, MAX_PAGECACHE_ORDER); +} + +static inline unsigned int mapping_max_folio_order(struct address_space *mapping) +{ + return (mapping->flags & AS_FOLIO_ORDER_MAX_MASK) >> AS_FOLIO_ORDER_MAX; +} + +static inline unsigned int mapping_min_folio_order(struct address_space *mapping) +{ + return (mapping->flags & AS_FOLIO_ORDER_MIN_MASK) >> AS_FOLIO_ORDER_MIN; } /* @@ -332,8 +388,7 @@ static inline void mapping_set_large_folios(struct address_space *mapping) */ static inline bool mapping_large_folio_support(struct address_space *mapping) { - return IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && - test_bit(AS_LARGE_FOLIO_SUPPORT, &mapping->flags); + return mapping_max_folio_order(mapping) > 0; } static inline int filemap_nr_thps(struct address_space *mapping) @@ -494,19 +549,6 @@ static inline void *detach_page_private(struct page *page) return folio_detach_private(page_folio(page)); } -/* - * There are some parts of the kernel which assume that PMD entries - * are exactly HPAGE_PMD_ORDER. Those should be fixed, but until then, - * limit the maximum allocation order to PMD size. I'm not aware of any - * assumptions about maximum order if THP are disabled, but 8 seems like - * a good order (that's 1MB if you're using 4kB pages) - */ -#ifdef CONFIG_TRANSPARENT_HUGEPAGE -#define MAX_PAGECACHE_ORDER HPAGE_PMD_ORDER -#else -#define MAX_PAGECACHE_ORDER 8 -#endif - #ifdef CONFIG_NUMA struct folio *filemap_alloc_folio(gfp_t gfp, unsigned int order); #else 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/iCItGFYxcCEvyDrAPeegIPSg96qqahphDY5B8gkTU2OncjkeENNq1u0lyZJ6IdOvkMsaN2HQWvyafZdnXYiVJbS5iiTTv9lsQqXBknu9XXiDRKhRQkaQ53Zc5LYW//q+3/+ZjMJcwrgzHYLRGzr/xnFo1r0wn3jpTwjhYlID57QhO3HbKQ3Lipa1JyQoZfT4P8PNgq0KD4DZ3oIQ+8hcPC6p5430OAgobMoCnGPcqhTGoKp+0hhMYCcYRIqI+SS8qjASkrVO6jwY1q7dmwQSlH0FaMaE1qjj5U3d0iDdHbMr15Agorskmp1zPWpiIRHZF9jKwsrUWF96aCbtYLVEm0NbLS8XZjVUv4S90rALvFanbS3uAf6796vsvtMSibV/ju9hY969Pug9L3+B3STDSgbCvTJTm2t9/X1Mshwy/OW++ykGjDnbv+qNL02fqFNoQz3R8ZXljRttvB57OVd1amNuzFQw6byO6MVhY5Pj5rAJEFidottBVTd3jolQ3Gr6KrVZJp6slxTzxZJMCL6W+Giv7rk9E1e8Av5oHjPE/MkLj5ibypBMu/LKO+C336DEcioRhoNEOLXCJzPn5EQB0W8Lgv/6xwTfr9dxxvU+YL5yZU50QtOjmB81yb0sGqZuvI8jDt5cQBy2wryzOqYvtXKIKpQjTuyEhv4zW0Tr6Bd+ShhIG8BrOmCdjIrAwuDdOEHZFcG/1StCQQmdKk+TXQC5t+IKpG4WM1eDSFq+e3viUgmMUYl8ZW6XhgaChkXi+ZfFIuN0sNoLN2M0hm1IvTHdk+oqSnZN+0zUtfbHQq8p50f4vD2CFQN7otj4jKQ3uM9mWRmj9x0kxQms Eu1Pmxnm TSqAmtNsARcx5i+iAoB0mjaoKiKhVlTZqVl6g0SfbldNmHsvbgzqtelQhG0NPzDWR0ZDAHmS8ChQwSf/oeQtU1ORbixaYybMm5rGWfNkGEX4h8gR4fmNln+q48+DeAxgKXAuVsVNXTkfgbfLpdJ1xpdvOnxBO6F2xix3vTXPtW3xc99W8EZfVO9ePUId4gm1+vli6V7VEh0sWikXkEg44uCcHCy/C1M4OEgHaLg/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); From patchwork Fri Sep 15 18:38:28 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: 13387464 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 798E4EED61E for ; Fri, 15 Sep 2023 18:39:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 13A5F6B03B3; Fri, 15 Sep 2023 14:39:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C5A56B03B4; Fri, 15 Sep 2023 14:39:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E7F166B03B5; Fri, 15 Sep 2023 14:39:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id D3A5E6B03B3 for ; Fri, 15 Sep 2023 14:39:05 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id AA66C40B20 for ; Fri, 15 Sep 2023 18:39:05 +0000 (UTC) X-FDA: 81239693850.04.720598A Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by imf13.hostedemail.com (Postfix) with ESMTP id EC85B20020 for ; Fri, 15 Sep 2023 18:39:03 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=r+lyXdNh; spf=pass (imf13.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.171 as permitted sender) smtp.mailfrom=me@pankajraghav.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694803144; 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=FLdOtec4vpzZfm3InvylkSWZf3/uIigm2EerkCxMy5w=; b=7Thyhj/kW8t0LHYb1jpSUGiQ2zvsAyjREYcKso3iXBH9kVBs180jBWUTmcGrg/XZZgd7Nk jtbYnu3Vk0cHilUlUBzaF2rZhcjJInojlqRwW9AiwBcRC5fJCW7+xcg8r+qL0G91q1o7Bb uVpaysFmRFFTUdwsQCAX1RqTXsvnDoo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694803144; a=rsa-sha256; cv=none; b=JGO5ldg1gFR/JYGQA3MAb0Zeti639J+4fGUY2JFkFq85C2vX8PjtfNat2Tl7QZUAYs1zXH OhIGJMekqsgCSNR8vLgiwblCjmVSHxIMLRH7rmdEzyndSdtfWVaqQGgfu08HDPnpbwylGr tsJAvfGa+0ZkT+sgiN/eUkj/bEu1Vew= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=r+lyXdNh; spf=pass (imf13.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.171 as permitted sender) smtp.mailfrom=me@pankajraghav.com; dmarc=none Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (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-201.mailbox.org (Postfix) with ESMTPS id 4RnNJ46BJgz9sVy; Fri, 15 Sep 2023 20:39:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803140; 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=FLdOtec4vpzZfm3InvylkSWZf3/uIigm2EerkCxMy5w=; b=r+lyXdNhKhaZUDV6ta1NOOz4t9XIqBsPWGKdpL52UeGGpc0w2l1GrjQoagDyLq1XmHgALR g1EqfgXzxsfYSrEIgCmHV7nHfJUR65ZXBz1qPyVMU38LzQvwBAQfX8hG15HCbnG3RfUlUX iSsWS6wC7+rnNjpeSwf3O99fKY75M5jL78ggnhb2038nR0JjItKOOiGG6wCGGFRnuDZBUU NgPx6r4jz+JR36KDLUuFNvBWQsWENMcB0tcPeeRxQuUQ5ZEuJPrOFCuxxalzPD+24MFPdX zSeo8UqEgsrlR9EtOCgcPXonCPqSD7HdZB8KudYD6ZpQglZJPmDfFUMnntpKfw== 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 03/23] filemap: add folio with at least mapping_min_order in __filemap_get_folio Date: Fri, 15 Sep 2023 20:38:28 +0200 Message-Id: <20230915183848.1018717-4-kernel@pankajraghav.com> In-Reply-To: <20230915183848.1018717-1-kernel@pankajraghav.com> References: <20230915183848.1018717-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Stat-Signature: mfb1973x6a6y84wxtt6zpi78s5ewwg7u X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: EC85B20020 X-Rspam-User: X-HE-Tag: 1694803143-793387 X-HE-Meta: U2FsdGVkX1/JE1eXHnZYv+Qw/BVO6Int0VKtVadzRtFBR8X2ZHKvvoFra4vQDSGcv8IWVp0ixNUcBUPNwDKAgJYDyCQ88CfsIFM72m3G6T0j3Fwj1xF91DGdEq30oOnG2Enp+qMiOrqVyLI3lIiMSpVLApKpDXP5hdWnjVd+L/2LVIyx0cl7T2PpJSQzz9YaPgBy48CJd+hanXwW3adARTeQbHGlJMgC9/Ta/ZER038rGtA9Hmom0mmaiR0OtIYxvyYHrAValvF78ewwjrG89CIAPyFjbw2WQRmMynG4dJzEg47RXKYIfK9qjn6t6r9ezftXm7jRO52DQ5CeXh+P/K7bsk4HQYh/KupglPfNJsIpM8TTuoxlRW049DoOIljQfOrtHd5/yp1t/3GEW52weVicvLvL3P9pOnFIsjyo+UE6ns4oCa/ZZIzjfLpIXgI50A21kVq06s7TjZTbnB+ANIl/t0+r0eJy/RojFeVDiTNHd0uQRKyFRC6plIFQv0jBLwpwR5PM3ipzmA0vzFBeme08PeAkz4RJ+CRUw0wBdGkgGIM9oWEdZp5xsnxLZyoHfFnoOtI7vjbBBSMatsZUu9p/myJ3Br+CloZtEtI9oX7bZNdrwWJ7APnCJP8FzPj192Zim04AKtB7hkOkl+7hOqGlWKo9BHbRB5wxrfGF0JxkQROpCBOTf9lHaGG3DZj8cur5L1+K9WgpKK2OAw2NH9ukqkkZUrUIs0LG6O5h/FbOSMw9ipE8Mu93yIIjEACecLISyRHBMxe/5e4CB7yVioAiuwEANuZu+32nSiUP0T1iRbgA2rVnHki8n0mebaHLuNJFt1GV01YNQv9o1rM/11FZDI4wno+0PjKWoTCQaZsP2NDFsBGShPWf+wGr+iWk7h5RnIBWKImu3WBTqbTMkCTIEQ9dmugAWUXnDdDEWlnYBoaT55chEIMJ0yu1tHNUbUjyj1+lleS547lIihs JSdkuH/r 8sy2izUk8F+UxfkN+bBUgeOOAdYmt2LF0J6+l+fdmEN2uTSCPwwS91TTiKNq2QLk6twUPcHjo/84JC4Qcam+W/rzK/TErrop+ja+kct9/YKgDYDu0fCEeBW8FWYmINoU5D1sfNn3eTNIP59B23ijxRjqdpm/XW2XcbHQv3MxV85nHuZEduTbr6uGwLPfoVLZ11XyFl8iBhyufEfVfBENYqjBpzRzRBXERXGYRWvkunHjkL/tBMezGI8rAnlIEOnJLTXzJ5D/H6GeYcmGfdik1ueU4cre33HJheMmLGgcGHPST92Qew1SCbtqJIzpCsgBw3Dygig7hQOUm2e10MBFu+zpHJ8n0TLWC5frALcrCVycpMJGPtND9gHt/86OJvU8+Ej23 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 __filemap_get_folio() with FGP_CREAT should allocate at least folio of filemap's min_order set using folio_set_mapping_orders(). A higher order folio than min_order by definition is a multiple of the min_order. If an index is aligned to an order higher than a min_order, it will also be aligned to the min order. Signed-off-by: Pankaj Raghav --- mm/filemap.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mm/filemap.c b/mm/filemap.c index 8962d1255905..b1ce63143df5 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1862,6 +1862,10 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, fgf_t fgp_flags, gfp_t gfp) { struct folio *folio; + int min_order = mapping_min_folio_order(mapping); + int nr_of_pages = (1U << min_order); + + index = round_down(index, nr_of_pages); repeat: folio = filemap_get_entry(mapping, index); @@ -1929,8 +1933,14 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, err = -ENOMEM; if (order == 1) order = 0; + if (order < min_order) + order = min_order; if (order > 0) alloc_gfp |= __GFP_NORETRY | __GFP_NOWARN; + + if (min_order) + VM_BUG_ON(index & ((1UL << order) - 1)); + folio = filemap_alloc_folio(alloc_gfp, order); if (!folio) continue; @@ -1944,7 +1954,7 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, break; folio_put(folio); folio = NULL; - } while (order-- > 0); + } while (order-- > min_order); if (err == -EEXIST) goto repeat; From patchwork Fri Sep 15 18:38:29 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: 13387465 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 190E5EED61A for ; Fri, 15 Sep 2023 18:39:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A3AB66B03B5; Fri, 15 Sep 2023 14:39:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9C1FC6B03B6; Fri, 15 Sep 2023 14:39:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 750B26B03B7; Fri, 15 Sep 2023 14:39:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 6305E6B03B5 for ; Fri, 15 Sep 2023 14:39:08 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3C0881607A8 for ; Fri, 15 Sep 2023 18:39:08 +0000 (UTC) X-FDA: 81239693976.15.B2FCF51 Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [80.241.56.161]) by imf11.hostedemail.com (Postfix) with ESMTP id 925C74000D for ; Fri, 15 Sep 2023 18:39:06 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=hVgB1L3L; dmarc=none; spf=pass (imf11.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.161 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=1694803146; 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=vFsIs+qRJRSVkUkhUlyZ9H4Jh3BsQexeaTYNPM7knQw=; b=jb4gVOCxHjZcqH/kMVhLF3hQI1u11YjjKjkOJDnmNp23Dx2JQPTt4vy62hazOw5IsIujnB g/jerPgd5R2AiV1+3sCECIeXHpOt74W2PZNXZuG3YNA8RhemPsMReD7qUjG9omqUReabZq 7KKdh4iZ1ElEElk4U+YVQh2jQDfpZsM= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=hVgB1L3L; dmarc=none; spf=pass (imf11.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.161 as permitted sender) smtp.mailfrom=me@pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694803146; a=rsa-sha256; cv=none; b=S/tCa/ogKP/+B9moT7jMuRJcvkYZ97zgPmRVbfcHH8olmjUfeNbCmuj4h1TPKlYGkeh5hc zLoNPwIcfAD1xTl8/4KMiM1YBJrcH4NH3CGRrklNzxDV6eBtMABWEADJ3EuYNsvtMNOdOD VbspP2LvSI5pD4S6QKKSt8PVX5cmz7U= Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (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-103.mailbox.org (Postfix) with ESMTPS id 4RnNJ73F62z9spF; Fri, 15 Sep 2023 20:39:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803143; 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=vFsIs+qRJRSVkUkhUlyZ9H4Jh3BsQexeaTYNPM7knQw=; b=hVgB1L3L+hfbOFs9pzt7JSZ0hL75va+f5dGTqbKq35/LHth7vuCtJyolpUYaCtZSdpXEix JXkNguxLkbblJKEYeBRWw4sugGoImquURo+WUPFARno3LgpZs20LLYLTi+D1WoWj+VLGNq uk+eLY+KxGkhRGjoDU09147fIC6cq8HBY7YH1MqbB89sTKYaddEmbOywPuL2wAm0HAG1d7 uT6Hp9zxX7OT0WFkFyl90rEJTT/PqBgWimlkD0UmghcqOvuwIJ8F+Ojn/orHfim//bDchH UtjJ+Oczct31qILqny72oU57MW1XThTi8wVKz646qcGe6HdWO6Pw8qfKMm7E8Q== 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 04/23] filemap: set the order of the index in page_cache_delete_batch() Date: Fri, 15 Sep 2023 20:38:29 +0200 Message-Id: <20230915183848.1018717-5-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: 925C74000D X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: am16ridcmn3oju8wr5gbmkwc4ai11y83 X-HE-Tag: 1694803146-388863 X-HE-Meta: U2FsdGVkX18y3B8Ip7B1ZUUaqZSGSN+ygQ65Ozb+5ibrA6hhvu5PcD1OtdtH/fPsTjeQMQ6rdFPe5LgOrYEbW143aPG64s5waI8kvv4Mn3BrIpQqt4MIinwPs+6QZ/seIN2pUYUbjPvJF8aUgttfQ7EZ0xhfuSq2u06rdfFJUnYn1Dbzia+k6F9T+oo6Ccqwnx4xQB1yWn1AEjFxdfIJOHmcY1jLI11jsC0yn/SY1Kz69ZKEG5MBsPbnOHFXwvVIgggjA0kVX/homPv8cZk2EHB/NQlCxu2ry133agIaabTAHAQcU7GjpCHZTspSM83aOBcChon/YPUCeWPdnIHrHSwR66K9OSmX9WCpG06jHn2ePe8rMBLKsjEkeughb5VMY2G8ts6wEtriBNXUGvDhNr0Ol2hIGMcf/zzb0IdPkGXGpbgjOfluGjeu3AHihaSBGDG6CO8WyfZESz7xraB3+AhaPw3AZOZVij5XwefJt95dzNCt86R3jxQmmVYsVA7tmVNlXH88Cks/K1Ik5yfbgyslKhY4g20ImhCFoNthQM7OctLc1ReYJQxWXvHOtPmwhOpNPLn9MmamMJ65sh/SzeAcY7TkyBqze5e4e+fMO3r+OkeaPQA7KihkgGTJt0MOAF0ZNdU0S1k4VWtDaw3P3xe9N5IC9qXrUYYFcuspwJPO9MH+8AmlgBGA41lmpwUIFey/pzrPJ9FDx6PA7R+VSrmyIraebCHByw2s3cL5ZMWAd7UkqOJYdTSKcK9QY2KBJx2FUoKsn+AMxBd4iUz33JhAWNb7ElqN58SuXzNjoDSNLnv0z+vakfaSUOlocTQqLk8MDLqqTs/If9DX0zxGZsXG480AT8Pze9sEbeSrjvyWF0gWCWu2GKaMJBryf3ItZ+E/beJ0nMHJviPjBWyVjqV2fq8NslwEoxySAwr7jxEL9SkoAgCKWzq9ryDjPgogsqKar2N2u1sqbFmvaBO dWGTzhi4 XGDYrmymN0GmMYHFdkJkoyvYOqsEUqG+ArRk+DmpWfRlc9effrvkoiXEigbdregnyebjAYkmJ6nCv6tqSTSrESLsctw703T1A/lmMdGd1HKREnvKWWLLZ7IPnOwqcInZa2+d8ZTNkHMefqIGTqjnEucL9Kh7zVing1bp7nNmlxQM3MNm3eMUT48V8fkv2Vbor2LSS624B3EznqCAwQSBJsGzS1C2LWg5Iu7buYYirgRDIpavk7AjDRUxGrbA/tkoP2FsHSEtwlp14Ga40o6WKy67tBHb3/BPxs4+W+8KavJLyR4pYgRJLVIoOsM34izoiUWM1bX3Az98HxE20RC9ZhGFlFevUytviijOiQyDUlu8A0arRe4Bfziy9e+mq1kitz+uzPGULv3MYcZ4= 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: Luis Chamberlain Similar to page_cache_delete(), call xas_set_order for non-hugetlb pages while deleting an entry from the page cache. Also put BUG_ON if the order of the folio is less than the mapping min_order. Signed-off-by: Luis Chamberlain --- mm/filemap.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mm/filemap.c b/mm/filemap.c index b1ce63143df5..2c47729dc8b0 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -126,6 +126,7 @@ static void page_cache_delete(struct address_space *mapping, struct folio *folio, void *shadow) { + unsigned int min_order = mapping_min_folio_order(mapping); XA_STATE(xas, &mapping->i_pages, folio->index); long nr = 1; @@ -134,6 +135,7 @@ static void page_cache_delete(struct address_space *mapping, xas_set_order(&xas, folio->index, folio_order(folio)); nr = folio_nr_pages(folio); + VM_BUG_ON_FOLIO(folio_order(folio) < min_order, folio); VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio); xas_store(&xas, shadow); @@ -276,6 +278,7 @@ void filemap_remove_folio(struct folio *folio) static void page_cache_delete_batch(struct address_space *mapping, struct folio_batch *fbatch) { + unsigned int min_order = mapping_min_folio_order(mapping); XA_STATE(xas, &mapping->i_pages, fbatch->folios[0]->index); long total_pages = 0; int i = 0; @@ -304,6 +307,11 @@ static void page_cache_delete_batch(struct address_space *mapping, WARN_ON_ONCE(!folio_test_locked(folio)); + /* hugetlb pages are represented by a single entry in the xarray */ + if (!folio_test_hugetlb(folio)) { + VM_BUG_ON_FOLIO(folio_order(folio) < min_order, folio); + xas_set_order(&xas, folio->index, folio_order(folio)); + } folio->mapping = NULL; /* Leave folio->index set: truncation lookup relies on it */ From patchwork Fri Sep 15 18:38:30 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: 13387466 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 BAE49EED61E for ; Fri, 15 Sep 2023 18:39:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 509F46B03B7; Fri, 15 Sep 2023 14:39:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 492F46B03B8; Fri, 15 Sep 2023 14:39:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 333426B03B9; Fri, 15 Sep 2023 14:39:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 1EA0B6B03B7 for ; Fri, 15 Sep 2023 14:39:11 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D7D5A80786 for ; Fri, 15 Sep 2023 18:39:10 +0000 (UTC) X-FDA: 81239694060.21.8B5C02B Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [80.241.56.161]) by imf12.hostedemail.com (Postfix) with ESMTP id 3E61E4000B for ; Fri, 15 Sep 2023 18:39:08 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=gScikhRf; dmarc=none; spf=pass (imf12.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.161 as permitted sender) smtp.mailfrom=me@pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694803149; a=rsa-sha256; cv=none; b=Piw4Zwqs53WUI/+QdlUoLlXbAf4p/bU61dHaE+GUr4OTblMVnnXyv2QlEkGzfzRa6BIf4P l30VzSnPtS/tKjZztvvhZPd+mqOnh1il4Mh/ffQOXxGlgWWz84DW8k1o0XYxzHi4+swUmt 1XbCyLqKT5epcLn+TNKQEsq7JLVhWdI= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=gScikhRf; dmarc=none; spf=pass (imf12.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.161 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=1694803149; 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=v1ROluVJSO7Og0x78gpfVtBYiLqeXgpCBUoOyNe/wDk=; b=da7T4sDHFmNrhj5GwOnR0oVVXxXZc1SJo110VJANol53WHJIfrSYPKMNnkQXyg8wQ8dfO/ D8Bg4XEJPlkOLmljZQambrhG9sM5QqvDuEvjb9kJmFMuzJ9XYNNy1ueW3SroTLK+hSjdPd iSXX1xn9KnhmOlO4T7n0sOxLgvZET58= Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (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-103.mailbox.org (Postfix) with ESMTPS id 4RnNJB14wvz9spX; Fri, 15 Sep 2023 20:39:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803146; 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=v1ROluVJSO7Og0x78gpfVtBYiLqeXgpCBUoOyNe/wDk=; b=gScikhRfoSfUAACxzO+p12H84XzAf0M/1y/sXgTZwi/SgPURdSIOMvREaunNOLzkA85V5k CkYo7Lcirhjq/rxs9lLFIlbq+saLu5YE4wAsu553hUQgaAdLpnd6lWIJPRf79Do52gShSl MApjJ5VYI5gdB2GmwbCQdVfYyscSdpvjxz/UD/mMTo3yWb5Oo9lRMwslcX/s5/Dme/ByaM pvoVjRe/LuOWXOvQ4z+1rMTn2nLNkOeteypbQeBaG7pl4lV2R9pYHLCIU7ryNihhJRCQKb P/Zo3IhJskWPDN4dnUQANxUvg31hX/f2ObFgnkjEJb2nLswBC4EENX4tks9G3g== 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 05/23] filemap: align index to mapping_min_order in filemap_range_has_page() Date: Fri, 15 Sep 2023 20:38:30 +0200 Message-Id: <20230915183848.1018717-6-kernel@pankajraghav.com> In-Reply-To: <20230915183848.1018717-1-kernel@pankajraghav.com> References: <20230915183848.1018717-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 3E61E4000B X-Stat-Signature: xj6g3socm9u4e8gguwk9tq399s44s5cq X-HE-Tag: 1694803148-915057 X-HE-Meta: U2FsdGVkX18aAe6vRy1FYcpQQPpXiZFC3aBMLGqgUAzk0cJ+NBdtViC8N8mkI1T7jr+sAjtEcZ4knSnPV+k0Lyw5oPTp4dDUXXSlnGMaXYDcNq/lDZeX1vMmZ1FMeexV9jCa53s7KJBR2Gxiy7uHxe13Z6JOgRmH7U58xXQpx+iUK93GfeSMo0r0O9P1EmPFPr9gbj6WAbcdEd1Nu5czowWbeQhGjyGedMkPv5BL+lvqJrqQ34hsKRZHcQB2u9wudeoi+UHDaQloYl7jaaxAQkuTjKemMxHCNpLwdDYicsBHKm/0BPu9CouR8ei4HEdPeuUHaJYxlvPDktTdhKs3wNlgVDaw13OzZAAaXYmq2opB7vajmRPz+uOi8C1INH5B4XATi59IF5DvGAR1viBM8yqzBZLN35CV+J0GnBYmA47JYWwt9UqVICzeIf71HNoqMj0qPDB7XBv0c9XBkqqvJ0u7xnuKlu+AwfNzzPY6wmY8wkKd+5fW/yh1Z2jR+PDWC0UWoideUOE7Wq/i3TZiNcn9m/sLlYcHoZxgPAgdwehUSnEOlX9RKY0J/ZXIANYLm6w4dqKU/LlfVB/ZjpdCSPnst1Sep3E6FPq4WOK7pVG8m9q+xrQQAwbhoJA2Sfw6y5owlVPFuBwyfwJNZc6LNVeBE3I0TuzdhzheRSZyJJ1YlLE6aSQrP+2Z8A9zvvG7Yfiwt4j3K0kU8kmSdLbI1DM6qCGr0JtQUlHzhHSCGE88H34RZBm9e9XBQ8JQcS16BMilX4C/m6acql1YOzL8ERh3oCUO5M4VOW3zXPDTULYfHm5JeQip29+Jt26PQ8+uG0Gz6eeWPANuatfVaGYpRGyUQWVWH9t9pEDjUMZUlD3GccVI07M/D1OcEnJLFPYZb1lsbBKk8wGiWyPMV3Gxe6PhtYSiJ7nYlvPCPWA2vinPVp512c8AkcQx/MMA6i9I4rdOC+H6+Lq1VIPoK5r ZcpOayaC R5YYyLN/k+kwbTMzXvzYoC9j+F+BhRzfNAQkj6T+d3tHtCkiGCZ9qlaNAHOaMaVgU06yMjAyMXpEuXDs61HGOKHD2xZnhsyEK36KtBaT7jb1SVJM7F+3yY+cx2sNUZekRCGadTmVyz1e9IUiDDwMXKJossUv3b8psraVhYwIqzCcmAEOP3/AKcuSFIfoxIgd02bHhEVmKmUh7wWokupDttnye9wJFQ2ca86vlMzlo1mxiTiKc4QuFbYn3MCnGx3j9ci1VaNeiAvrZ1PC26Mxm+dzIzi3jNSJfDE9xWC0L6onLhtNaqM8I/9E466ncWnUwl0B9JgIiCGaofw0ORDP1BLXg2D52hoUtIlZkFQoT7qSYlMYrWkos7/9D0QjwqmSxsAthxXThMOGrXUJXVCAEfgwUsKOeQZyhLY2a 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: Luis Chamberlain page cache is mapping min_folio_order aligned. Use mapping min_folio_order to align the start_byte and end_byte in filemap_range_has_page(). Signed-off-by: Luis Chamberlain --- mm/filemap.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 2c47729dc8b0..4dee24b5b61c 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -477,9 +477,12 @@ EXPORT_SYMBOL(filemap_flush); bool filemap_range_has_page(struct address_space *mapping, loff_t start_byte, loff_t end_byte) { + unsigned int min_order = mapping_min_folio_order(mapping); + unsigned int nrpages = 1UL << min_order; + pgoff_t index = round_down(start_byte >> PAGE_SHIFT, nrpages); struct folio *folio; - XA_STATE(xas, &mapping->i_pages, start_byte >> PAGE_SHIFT); - pgoff_t max = end_byte >> PAGE_SHIFT; + XA_STATE(xas, &mapping->i_pages, index); + pgoff_t max = round_down(end_byte >> PAGE_SHIFT, nrpages); if (end_byte < start_byte) return false; From patchwork Fri Sep 15 18:38:31 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: 13387467 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 DCC71EED61E for ; Fri, 15 Sep 2023 18:39:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E0DD36B03B9; Fri, 15 Sep 2023 14:39:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DB99E6B03BA; Fri, 15 Sep 2023 14:39:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BE6976B03BB; Fri, 15 Sep 2023 14:39:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id AEAFA6B03B9 for ; Fri, 15 Sep 2023 14:39:13 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8F0FD1604EF for ; Fri, 15 Sep 2023 18:39:13 +0000 (UTC) X-FDA: 81239694186.30.C15D3A2 Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by imf20.hostedemail.com (Postfix) with ESMTP id D4A7C1C0022 for ; Fri, 15 Sep 2023 18:39:11 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b="j/WoRm7k"; spf=pass (imf20.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.171 as permitted sender) smtp.mailfrom=me@pankajraghav.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694803152; 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=2grCxcqK8FKtyCgTOlZ0MTRPcri5sYlchrmngCOgl8U=; b=pQquoK+ntUhkKwk4UvDa6/R7qcEzHXq69f9t7UkDatFJWgocE+Qp+iJTDOs9gVUYktfQoi FnJ0MVye1EIxDrVTNl07BVf/gk26QCvTGY+kXmbApmLe23I2t8uik5YLgWhMf+IFQ4Ym6R IBBbqK6QuVNU/zJO9yYY3O+E2dgXMCE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694803152; a=rsa-sha256; cv=none; b=1ez57ALXuH9txYOeX+pDEdr9NlE1tFsFCrPi+iTc51Y2dUyN+a3zJ9mWrND+P4RhHnQktS dYaC2a3taX0xWITh+prBGXFMMNKyftcbSsEs1UgKlE7sLvcMOZUG+iSJxoGIVUj/DlxB1k Kh4Ir3R6fNV95CiFlayAlR0Dx0ih+v8= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b="j/WoRm7k"; spf=pass (imf20.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.171 as permitted sender) smtp.mailfrom=me@pankajraghav.com; dmarc=none Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (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-201.mailbox.org (Postfix) with ESMTPS id 4RnNJD57K5z9sW2; Fri, 15 Sep 2023 20:39:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803148; 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=2grCxcqK8FKtyCgTOlZ0MTRPcri5sYlchrmngCOgl8U=; b=j/WoRm7kqZ2NoZ5OjDxKOQdGsBPUtApoPN7xyVBhTkrQsnhPqztuwiVWc2+UMXFhXmucnn yV+5CVecVrEDZ/RgmtLrE4lsA0aMvZFUc6TXMrY/E0TUv11fr40etSwDNW4JstoTE3PGdc wzKsqHxrr54nqKGxraGFN5jT4guAQfbru8I95DPokA3ewiwi5qz50a3aIhjBlV9pFFIWnV /3j3RMZ/xhGVgtsWXbHphYwPMEotMMqn+UED9KX4/9IgzyhYXmjjJeptgYB1o9oG1BDw5K SfyVH8Havcutw80kiMU8+RDv5/rYTA2MFLmQBkfN08ZgPi5O8qpzk1LIGJ1oUw== 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 06/23] mm: call xas_set_order() in replace_page_cache_folio() Date: Fri, 15 Sep 2023 20:38:31 +0200 Message-Id: <20230915183848.1018717-7-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: D4A7C1C0022 X-Rspam-User: X-Stat-Signature: 6zbiq1hth9f6wsxfrpxxecf6xoogtja1 X-Rspamd-Server: rspam03 X-HE-Tag: 1694803151-313170 X-HE-Meta: U2FsdGVkX18cWggy3e8P85JTBCIEOCvdHKHmRcUf5XkgTEPFI8iLbvmY0+5NLRmCt25INERvHiHLeageN8lxmHNGtIoJ8bDqr91NmdpWb2dfr+IkvM46oS2xaAiEZmBUg5pgGIRCPMRFafegEqyoq2G3Tan77NlUsY/hU4pg2ZTBMRKIiztDTdRBsWkcF3uWG10ktRn4nQnhiEG8T0vACUcg6PYt28EcXxBuXYygIbDHSzHyj5UFgwUJfAdE3jkw0jEFupuzA7tMW9vExuNaUX813Zc4+a7Je11HnRfF5CbjUDYpMNwj49gg6vrEFikbbY1H0xd4WvIFr3UqxqTCqhHeeVhk08iNFjUBYceI+CL3Lz+T/Duhf6oBHHMRBflAv4W9DDhACsPWltSPLOLBAREpaYb2lU+GSgmxXe0GYjKaZMprUBaV9cJWGZ8PVjUrcJPH/n0LHTl2XtYIHIyKDiO9N3ctP+1DVEhpx4N4O/mHw1Kfs+KEJQOl4P3FGaA2t5ikx4wZgaBXF5l0qwetq/1N+7GIFcRsRqjr7rQ5tuH8GCWl/cGf72yMraR/aNNtRtwse+81VR3saDLdsJc7TfpexUSBdKbQT7cIaXq8WxvUMhKCb6SSD/uBUpSB1pE6TGU0/yyGyhklECs/EN+xuanXFvlHNcsc8bdVZyBxjDfL6q9AewtEE7UdQlum3cKOagN1+bWWwQ/IUVpTKXgryO10Rxu3WzOWElsJDb8mDf03uB6oCR8xVeVOUJdrNf5HkHF9UziuGwcuso6XlaJeynED2IHNBhWiS1wm9U+FvcMDHJocNq0kFO7nFP+GH8S7fRi4JAOUnef5HqnYSjHVwX4VFXJtJG0vOfpOf1uwm2fB77K/UOrtZ39JvIdOIs/FTVvzHXXpL17lMIIa7/kvPhRaRaAO/1HC2iuUbRlgXRT4btQ19t5JSkwMXf7C8e6zb4ThtOoHczhcV+YJ1xx ofa+O2/V 0K41JJpJ0Gvb2WYiF4Q1PojoZRry0lK0hh0ZIsqgcobyPt+E1MFrE1oysGMGt/vS8LDeGB5dJ8RKar9n/j9eKUwdPrSiguvutdPGpZI7D8mW8ArsW7y23y9BkA+G7wHW9cwJi4oUt3XnN/ATcRslld4EAQk/RukA1Vuhkt4NnAhNBLToniQ6spFRqPICEKNEcgdFaC72h2GePxW6BgiSnx4K3y/2QCGqOHygu9SqWagE+g5qk12tX+lbNwu6EvyQGvJ01MUchjbXNnFKMIEEwd6B7Y8Bg2qfTqqVmIfL3wujl2qFmXhxYVkgGNyhWs/zXGF6mk3bQMEqOZ/BQhNv1qbY4GXxXSyl67y9bn54DC44gkvfwJVgEj8AxvLaehDaSh8CTv5IKtIwkSYQ= 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: Luis Chamberlain Call xas_set_order() in replace_page_cache_folio() for non hugetlb pages. Signed-off-by: Luis Chamberlain --- mm/filemap.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mm/filemap.c b/mm/filemap.c index 4dee24b5b61c..33de71bfa953 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -815,12 +815,14 @@ EXPORT_SYMBOL(file_write_and_wait_range); void replace_page_cache_folio(struct folio *old, struct folio *new) { struct address_space *mapping = old->mapping; + unsigned int min_order = mapping_min_folio_order(mapping); void (*free_folio)(struct folio *) = mapping->a_ops->free_folio; pgoff_t offset = old->index; XA_STATE(xas, &mapping->i_pages, offset); VM_BUG_ON_FOLIO(!folio_test_locked(old), old); VM_BUG_ON_FOLIO(!folio_test_locked(new), new); + VM_BUG_ON_FOLIO(folio_order(new) != folio_order(old), new); VM_BUG_ON_FOLIO(new->mapping, new); folio_get(new); @@ -829,6 +831,11 @@ void replace_page_cache_folio(struct folio *old, struct folio *new) mem_cgroup_migrate(old, new); + if (!folio_test_hugetlb(new)) { + VM_BUG_ON_FOLIO(folio_order(new) < min_order, new); + xas_set_order(&xas, offset, folio_order(new)); + } + xas_lock_irq(&xas); xas_store(&xas, new); From patchwork Fri Sep 15 18:38:32 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: 13387468 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 B46AAEED61E for ; Fri, 15 Sep 2023 18:39:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D6FA36B03BA; Fri, 15 Sep 2023 14:39:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CF6F26B03BB; Fri, 15 Sep 2023 14:39:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B97AB6B03BC; Fri, 15 Sep 2023 14:39:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A5C676B03BA for ; Fri, 15 Sep 2023 14:39:14 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 5AE5416075E for ; Fri, 15 Sep 2023 18:39:14 +0000 (UTC) X-FDA: 81239694228.25.B65C19F Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by imf30.hostedemail.com (Postfix) with ESMTP id B410D80028 for ; Fri, 15 Sep 2023 18:39:12 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=WfMPs8ow; dmarc=none; spf=pass (imf30.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.172 as permitted sender) smtp.mailfrom=me@pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694803152; a=rsa-sha256; cv=none; b=3QOAZeRcD+zVg/c7VGEe2PmRnkPKxcEzTeoQxlOk1VuXAk4QTOVEMOcL1U/VQqs63SHL4l aVgJyPEK/D6XDC3n5amdDcgMz/h2gM6EOZaDQbSXJ1A+6fqHuodMDTIa47bGAv0wP+sO97 nSwHrlfrU/7m27F7wglWXxij2jCP/Y8= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=WfMPs8ow; dmarc=none; spf=pass (imf30.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.172 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=1694803152; 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=fo0VXOu7M+9NKfjAGLZXjFApmoEpRKKJEPK75Mez2cA=; b=P2cLwbqaAnYeFCf6NXgLOC5tqwE1qJy43cvgHFuK6vycJS95PT4DWX66eAAvOF5F2j2iPC fiHj5uBkwJGrrb6BhnagPAk/lGIOpDlKLe+fe77kClIRTU3ATexgzLYt76T/vlCmmpwq0X /JjsL3eKaliDSZIAU3j66UIlcjAT+Lk= Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (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-202.mailbox.org (Postfix) with ESMTPS id 4RnNJH1Xljz9sQf; Fri, 15 Sep 2023 20:39:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803151; 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=fo0VXOu7M+9NKfjAGLZXjFApmoEpRKKJEPK75Mez2cA=; b=WfMPs8owDY4qNpPNRRBf2P7n6I/k1Vb8R9SOGAa4d0T5FLvv4ZHDjWd9yFS4HA1DKcDXoZ Hs9/Lc7bdPIjyElTcSGwwlLTk8E9vLbEnQREiltl5xwCZxZhmZW2W/MIWqbzt/L0UBGJkL Pg1tzwwKa0ivqVeh/dlhg7mGJoM5RT/rjcmVhwnmzmeYieP7bnYJI0tIsDaZcaMFCiYk9l eQpfZrnKOiSrp4if8lwa+VZrXN/gYt7pEAXj9fNCZan1DgEdMMHsjyF5BcnH2QER2lpu5Q 2yAY1aQhY540+9mUaXvvL33VXZsMEat6/i+Ojfu5vHN2X5uVaD4JlKa3e5Z7bA== 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 07/23] filemap: align the index to mapping_min_order in __filemap_add_folio() Date: Fri, 15 Sep 2023 20:38:32 +0200 Message-Id: <20230915183848.1018717-8-kernel@pankajraghav.com> In-Reply-To: <20230915183848.1018717-1-kernel@pankajraghav.com> References: <20230915183848.1018717-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: B410D80028 X-Stat-Signature: c5uzxya9sna5ssrqfao1euxqpw1ztgaj X-HE-Tag: 1694803152-512299 X-HE-Meta: U2FsdGVkX18kRUPcEsHBXEzB7BJNL/N/P+FudYCCHhdfnXR2jqmPVQBUqhFKNUxj84taJo2H8FN+yG6SE6mlbyhpoBpaCjR3wPg6qKLAMhEU84rpDX73xhJHIDkID6ZxjZPom+RbHoGUkA7fdzhPIR0HGFRHaPwb4Voihij/SjabIkHxMIA1y8fSJADVBKMfTI2VtYhySy9Ai8OWeALG8ZGtIwx6H93VnakiuIR9u6JOGtbO6KoI7VsEFAoBjZJo0OmSN+qyTFsBkEFr+Mmi7ZzOpiUJAlDTt7I6oox1GO5nS0cqo3B8WHMDPvc4JuszFqACES17wZmKYumn3AbmBvcqTECq42JM6WX/dhODNOVefNcGJEo6f3KDHy9tzyDbbK8F795kP9vcpMYLkorpv9u7owuS7BL980J3vdUbYYTUoczSezRIAIzIR7VifoKMJ5RQmB5Y4Oj9XkmKDJI2s6ukc33t97YaFDX8khfMmdcHW7D+nv5h8+G1wPHtgpIfoehlVp/S8Uv8fLEklkmH1poGqk2OESWS+NjhYnTvURNq+FULfEtJ5xfHhYHoSKNfRNGQSaioYPEjobe9YQXxQrO9LOjOL65+1DkGiOPcruPy9iTOG1lst6IqJbQ0F/uMrifo/79pSRyMVzYr6yCtnUpItsJ/bOCAvCHDPcBRF8hx4tWVQ9gBB5Qiie+GqhC+7bSIlhbjtj6q6BcVm5o2whJfONIZawrGVPvH8QwiHB8ueWvZdeysCNWIWYl+x24HT/H4wB39MOmcVrE2MwJeLYw+fT7f8jlzrIx5H0yqvpjQoxzxftSqGdxpQq276I1K0tsmouyPq+Uygs8jbvhj1kpp+YU+AriLMMDFcBNq1O2GHKapq6C6Zo+dcz1p4jyh/9f0sex6WtlEyRxUxCPoX7XOD/+Svh6E20dl87DSQHIFwn/xw+3X9hZNnF0wbLlBbjHb2fB7oavOWIGKX/N S3bPbC0J jRfwQ12xASQZPWemeqj7SZ+0BOvWeWTij549Wk5Q3950m8GzbEdZAFqi80yw2kQiIUhzK2GcCY92egUc+vazU5Jki7ZBR+gGZ1U0V1X0mMo6T0sd9/lyqMcjsE5mvRYCpwbbQsrKBHFWXg8MveO8mt1cX9X9F9h452jC2pJ/bX7XcnQGWvNx52bNELQ34ABg63299zXBtH6JYbArobKKCS8Myop8FlogFjKV7ppDxNCF32fTGVxHYH7HCGH8Y1m80Y105MSqoH4ctmj2Q6oXU7cprMcIzTwbf82i0S8kLgS8o0fRfjnxsG6ZKo8u7xmLO1ISUFIahEu2AyhvNddfJ1NRIKbbO64SH/WYTq9t3gXe8WFgjBjx/0lUjyHgzk18BFwjUhcGL+56Cdnw= 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: Luis Chamberlain Align the index to the mapping_min_order number of pages while setting the XA_STATE and xas_set_order(). Signed-off-by: Luis Chamberlain --- mm/filemap.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 33de71bfa953..15bc810bfc89 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -859,7 +859,10 @@ EXPORT_SYMBOL_GPL(replace_page_cache_folio); noinline int __filemap_add_folio(struct address_space *mapping, struct folio *folio, pgoff_t index, gfp_t gfp, void **shadowp) { - XA_STATE(xas, &mapping->i_pages, index); + unsigned int min_order = mapping_min_folio_order(mapping); + unsigned int nr_of_pages = (1U << min_order); + pgoff_t rounded_index = round_down(index, nr_of_pages); + XA_STATE(xas, &mapping->i_pages, rounded_index); int huge = folio_test_hugetlb(folio); bool charged = false; long nr = 1; @@ -875,8 +878,8 @@ noinline int __filemap_add_folio(struct address_space *mapping, charged = true; } - VM_BUG_ON_FOLIO(index & (folio_nr_pages(folio) - 1), folio); - xas_set_order(&xas, index, folio_order(folio)); + VM_BUG_ON_FOLIO(rounded_index & (folio_nr_pages(folio) - 1), folio); + xas_set_order(&xas, rounded_index, folio_order(folio)); nr = folio_nr_pages(folio); gfp &= GFP_RECLAIM_MASK; @@ -913,6 +916,7 @@ noinline int __filemap_add_folio(struct address_space *mapping, } } + VM_BUG_ON_FOLIO(folio_order(folio) < min_order, folio); xas_store(&xas, folio); if (xas_error(&xas)) goto unlock; From patchwork Fri Sep 15 18:38:33 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: 13387469 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 9487BEED61A for ; Fri, 15 Sep 2023 18:39:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 691586B03BD; Fri, 15 Sep 2023 14:39:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 64D466B03BE; Fri, 15 Sep 2023 14:39:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4DFCE6B03BF; Fri, 15 Sep 2023 14:39:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 3E2096B03BD for ; Fri, 15 Sep 2023 14:39:19 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 0340C1CA77C for ; Fri, 15 Sep 2023 18:39:18 +0000 (UTC) X-FDA: 81239694438.15.134A61A Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by imf27.hostedemail.com (Postfix) with ESMTP id 570174002A for ; Fri, 15 Sep 2023 18:39:17 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=sLkequQ3; spf=pass (imf27.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.171 as permitted sender) smtp.mailfrom=me@pankajraghav.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694803157; 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=qYagWwQkQyBo9FUt+Wer66h9atojNQ2DWonnQYgzdlw=; b=yHXMM40rJFxU/OSnWvYrlhMSW+HIEqU5lKA8IYW+JrKIW8Z5A62Sa7HKXV2ZONwAn6JicV 5WF/2XENLlgjA37SorZSElDDQODvQprvdMmqRzGq7GXTkgnww/JAcpcoCaPQm4sLFCVYL1 bgZFaQeMgDWlvNs9zFm7Sts1i3oEeck= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694803157; a=rsa-sha256; cv=none; b=KRkwtBYgtJPhEEyM6ob+Avx/CQhWMYzqhODylw+DI03s6Arzh0QkEJZhAvMrE69C4DI4n1 tiave1iMh8FMBCbnRy1HSr4i1LvRcQiQhcxyrUZJq2IcXJx3Ibo3IxyjXLgSINx23rUtNJ HW8vteGoRyzQRfVRdi95h2FNopPqvpQ= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=sLkequQ3; spf=pass (imf27.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.171 as permitted sender) smtp.mailfrom=me@pankajraghav.com; dmarc=none Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (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-201.mailbox.org (Postfix) with ESMTPS id 4RnNJL12VYz9sTm; Fri, 15 Sep 2023 20:39:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803154; 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=qYagWwQkQyBo9FUt+Wer66h9atojNQ2DWonnQYgzdlw=; b=sLkequQ37CkU3k8W1DxxgB42DpoCWPVkiye6O36mnozEtbvveaSpVg02AQr9gRNrsG1StT zaL/G92Pk3Q9LxMD3dVHNbwZKUF2uE0xvuy7ixhERejXQHjckMQRVs4nVmKTcZ8B4ZlwxF dilFyBmIzK3geH/C55u1tMzeAId6PQM20aaVRonwgd4u+BGaOLBKOVd7hyimLCr/FrViWj YBvOAyGNd9SQBuLQuz8bCS/+MMijxud/FLCWs8ijotAjn63u2NB1NyM8wO0y+syInk6R+Q VvQVj3aV97v3/+RLzo4tjrdpk9/BPKcdYe+8EcQcR29kNlkW4twTvSq1m+u2PQ== 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 08/23] filemap: align the index to mapping_min_order in filemap_get_folios_tag() Date: Fri, 15 Sep 2023 20:38:33 +0200 Message-Id: <20230915183848.1018717-9-kernel@pankajraghav.com> In-Reply-To: <20230915183848.1018717-1-kernel@pankajraghav.com> References: <20230915183848.1018717-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Stat-Signature: xwoy8a3jo5zh9oqpifjzud8mxapzsphe X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 570174002A X-Rspam-User: X-HE-Tag: 1694803157-327543 X-HE-Meta: U2FsdGVkX1/Xwgjz15O6l+Qv/3GcFN6nXVZsL/R9lnWC7DojuDxdHgNnM0XJuVLkIRAvLFR8dvrEP6LfYsga/o+E++fJYA1YJZop8Kfezrfhx8Fe9QEYGnCcSynsijC5105XInGBCwUNm4zxP5xfRC+HQnT6MNU0WQGlkProbWWEIXKsU6n/+kcDzEfG2NCdmqrfOa8I+rg1c1pw0zWFOuyr7JLg7f4gYXoVrENmJZwCpRuND6Uz47I6azAWpGa0WTCSNnY1lPlQO+tL+SxxeW9lslzZI0wwAuflIgVSLPR6gUwq8ieuqapZftxwKEdcV7nofHyMqKu/8X7XXh8hVEKJxm//3oyWUL8muenoXNBRHrbX7SX0fkBULPppB6hAqp//b6HkfuRhvySD98CIZns0aK1RyPr0dibdZTKs9uMustPtbzLLPOBfLC/S0uGW9N4DZwcfsG0NVuareS1jKbbjHMo808DBRCr9FJXJ28a+1NWwuapanGylGQ+fe6Ko4+5FDTjVVqhXm7EsQPQJAGJWjysuDkBxtnCmCbHJw/S/oZjrBUdAscuMCYKGx2hOpgNk9lJ2erknP8COYus7HSHtGuELQUmjy/yY3dLsEC3aD6Ot1c12KOYcPACGSwSDzxYntHJLhWjaWVmlZsLCcWtOI7uSoTtGCfeK0idvZVG4+5k0g9FAXaTcjDO3x0RXPB9em8b0grIYsoAbLkukAind+2YHwgFFCRz8e6LijVLCTozIRMUOm0LbwKepwugrAgwlAPkoeAOhB8VFHBDXsKxsA9iUJjuT8rFWvgfBzCDF1SNZqfCy2RWD9xz2EcmN6OPo0tpA/N1u/9/XTYJetd+BjWhNMFBF/1XJ17tQoLHFPpoPq+17u/IlvLKURZTcHP0K8moO3i8U0yv0BHBFT3ser5Dkfy26NLYZQhrQUInxa/MnV3qn/cWixJjT/hz4y54Qxo56Df1FvTXTCFo oOEmhonH K1qPtbZz6u9i+/D5ZSTSJXaT72asjxCfgZbgxmKV3rIhLUJg70I524KX+tUxOgXR1woNaMv71BKPyqCPWOKjiB1UELtphtEWhtuW7c0O1E/XR8ky0t8UJo+tP+CnCBQskwN2ItFlsHSfg+50bdPyhMjOQLMORyJpxZXvIl6xmGGr64c643zatBpukS+WA9bkUT5UNzIIU436W3O/5nMnbysfYM+aztvqEIU3L6Pxood874oTWSJtlw0frxRaVbdZ6MecnrfxoecvXu6X4yLeMA+xw2md8nm3ECBw0IEW8W70G9aNILd1OlRW+++A0gN+P+oHwJ9g3WUTYaj2tXV7PwVmWAGIM+sYM+5LRTUR77iRQp5b5MYcs85YeTO0YmGCU/ndVo4XbAT/cwxY= 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: Luis Chamberlain Align the index to the mapping_min_order number of pages while setting the XA_STATE in filemap_get_folios_tag(). Signed-off-by: Luis Chamberlain --- mm/filemap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/filemap.c b/mm/filemap.c index 15bc810bfc89..21e1341526ab 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2280,7 +2280,9 @@ EXPORT_SYMBOL(filemap_get_folios_contig); unsigned filemap_get_folios_tag(struct address_space *mapping, pgoff_t *start, pgoff_t end, xa_mark_t tag, struct folio_batch *fbatch) { - XA_STATE(xas, &mapping->i_pages, *start); + unsigned int min_order = mapping_min_folio_order(mapping); + unsigned int nrpages = 1UL << min_order; + XA_STATE(xas, &mapping->i_pages, round_down(*start, nrpages)); struct folio *folio; rcu_read_lock(); From patchwork Fri Sep 15 18:38:34 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: 13387470 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 A6C29EED61E for ; Fri, 15 Sep 2023 18:39:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 335D66B03BF; Fri, 15 Sep 2023 14:39:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E6A96B03C0; Fri, 15 Sep 2023 14:39:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 184F66B03C1; Fri, 15 Sep 2023 14:39:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id EC81F6B03BF for ; Fri, 15 Sep 2023 14:39:22 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 98A5A140239 for ; Fri, 15 Sep 2023 18:39:22 +0000 (UTC) X-FDA: 81239694564.14.6BF3341 Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by imf03.hostedemail.com (Postfix) with ESMTP id 01D6D2001E for ; Fri, 15 Sep 2023 18:39:20 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=Zj3MnwSG; dmarc=none; spf=pass (imf03.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.172 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=1694803161; 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=3APo23DtYMF4HiSm9np03AfVKr1TDxQPEqBIBU7EQLQ=; b=aPGIV9WQ5rrSF2mfdCUxLTBXoQhmYpFKIRjRUtchmbbYOfdymY0WplvbgKBOUB1WS5ls8y KuluB3mPVSC9EzVeZ5vZJGuATM5Euok2BaLCfHxhlYadXbDNhL5zomi3GljDfgAcW1EaB2 TLjgEZ4/0a3/jg2HcF1TTkAgDSmIIM4= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=Zj3MnwSG; dmarc=none; spf=pass (imf03.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.172 as permitted sender) smtp.mailfrom=me@pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694803161; a=rsa-sha256; cv=none; b=1pZjBfOUG1GGirzPuT6mfmePKuiBY985hJcSOeSfQtAFy4Ubj8FSvXnvF/lomth9tGAuPn Lw09dFehoKXg093i46HSlC884PP8X4TBbi8lIMGeXMfSXT2ZEInOa7mmL/VSJBff2vttlv MvhInaMJj9uy9Sh5wubAM70qmg8QwuM= Received: from smtp1.mailbox.org (smtp1.mailbox.org [10.196.197.1]) (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-202.mailbox.org (Postfix) with ESMTPS id 4RnNJQ0N8tz9sZ5; Fri, 15 Sep 2023 20:39:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803158; 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=3APo23DtYMF4HiSm9np03AfVKr1TDxQPEqBIBU7EQLQ=; b=Zj3MnwSGDMAwBq1bun9wQMD03apsZ8TkPzzZY0G+xVuRFHlA8jTRS9j0z03rhiuPfuRL6p sz/dnlC30Ddq95aZ8BgLQPzAOrlr7XRSaj2o2j1LWlJXmR+xzOB4D1lfcoHYkXXJNM7T+e o1eXt+BU1FmCmk3Anh7cikxoynzKwfGc8hH7UoHccj4k2DZXzQFOkU0phBCRGBrFG42T8t rlNeZG/822yhWUKUgM45Id9Xd6OxjN5FfHbNRbbHF90yh5ppnDsJruqnEsC/WrQJlyPF8N aYOfhwR5VntP4ab9n0nA+F2XRQXfgH4LmqvrkX9lLSLR7mCEJyhlXYJSK5HJdQ== 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 09/23] filemap: use mapping_min_order while allocating folios Date: Fri, 15 Sep 2023 20:38:34 +0200 Message-Id: <20230915183848.1018717-10-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: 01D6D2001E X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: rne8rgq5446zqosatsu7ng7dpmf6onst X-HE-Tag: 1694803160-324 X-HE-Meta: U2FsdGVkX1+6dnpQrNgwSinfBTMQI0vdJSHda+TzNL9AubLVE0FdsfLftCcS5Ryqck/AsaZ8YIdhIEGY6ZfskILJsvJRnOD8jiHx04ZhuUaDxY4PLenGngonW5o+Cr1EHhE2LgZis+xhB/LfXX+utB8smyl9r6wFPHzPLG9dnqCPJ/6sbA9hEcc1s0a9XnleZXMC+ExutRFJPXok3H/x+rcvx7Zqpi5Uh9QQ+u6qYYp/Vfz9+WQ6ZPr2jNLM+mCUfxCq8oz2CQur7AP0O+H/GI0vDMnpG9kz+iQZQu9iGlUFfeN62VZmTk7cEZsjG+GQ/01JMF+xsntU145YElF4fMwiXSRA+DXFhm+QeXhJT0S0pcD+Rlv2ALDo8v58ZfrzgXvEoG2vaUwy7fMzCXQYxP94pVQL1EtKEuwwWJ7BHJyDJ1dHCVkAfQJNQdWxi+z/YSXOUinLsVJTHWLD3steIFaeXPLX1wIDqxPhZ/B1L5b7ax6nzAs7QgiM6sPz4+64BW0vijOWCjcO7x3aeJ1FevgVsRxhj5rrPnGYHTbehd7x4Ki3eIjQzYdvOtjxuXz2UdM8hQRJ6Uh+gSTCVjvGhbEj9uYGaoSOjsrUz/pG424WiEi8xuYKR7aaCio4mZo8x2m/GxEdgCdAvoAxcM30U9Az+3LI3fjdAzS9tjq7xsiaCwnS4l/kxySkmyqi1RxJW+Omm3qK6eaDsQq2U33IQc+0tCPy6PNEvfqDALML5T04zF0RuK9feeHt2LOlhFX3FelSvZHL6Bxu1F/WpA7gXv137hREF7NnQz4CKh87pmYMfj2cKnZ5PakXCYYT3ly/FIhnkVeJ5xbqiAYHdgVIzx2lXiVQmgI00dgFGEW1jwLG0gvsOr6NNCABKj3yu3wEALbX5QbaFs1DqZwTOoYMzpbi5n0574/ZKiiCaok7afZEJRnhd5Qi3Qrmevj04YY2ueaQYKh/1OWgM2N7xFm 9L6Xo8vE qHKGG9rAUm8YjX/XHtYv94pyFg+SF8n5miTmBw6d5N5+Vr76ipQHmwBJGbmUzIG7WVF233lH4DxQFHdtpLmfh/mbet5cBsjKcmCu2G7UOVamuCrLVn8T+TxllkhkAjUQCPeSbxEP6FNNrsI0MZnuUyndEMew7YdCQd+qchvJDO2rSv/IDJq2z2KtiB1d2Bn80cuTykEtKwnHQASKrX0t4qUuSwSWIt3DO7tyjMQE17yGtbarSxcTxhFBcZ3hlROwf9rtWeCuyquVsoqpamhwr2mC/dVn8nEFuqMcCU/1OY/fukEyEEGoc/V7gpGJDF7wnfWv/8W66SFX/0E13FxVb0LhDvGBuZNhV/qo8zeOnnCf6aZ8= 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 Allocate al teast mapping_min_order when creating new folio for the filemap in filemap_create_folio() and do_read_cache_folio(). Signed-off-by: Pankaj Raghav --- mm/filemap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 21e1341526ab..e4d46f79e95d 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2502,7 +2502,8 @@ static int filemap_create_folio(struct file *file, struct folio *folio; int error; - folio = filemap_alloc_folio(mapping_gfp_mask(mapping), 0); + folio = filemap_alloc_folio(mapping_gfp_mask(mapping), + mapping_min_folio_order(mapping)); if (!folio) return -ENOMEM; @@ -3696,7 +3697,8 @@ static struct folio *do_read_cache_folio(struct address_space *mapping, repeat: folio = filemap_get_folio(mapping, index); if (IS_ERR(folio)) { - folio = filemap_alloc_folio(gfp, 0); + folio = filemap_alloc_folio(gfp, + mapping_min_folio_order(mapping)); if (!folio) return ERR_PTR(-ENOMEM); err = filemap_add_folio(mapping, folio, index, gfp); From patchwork Fri Sep 15 18:38:35 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: 13387471 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 35818EED61E for ; Fri, 15 Sep 2023 18:39:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 928A56B03C1; Fri, 15 Sep 2023 14:39:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8D74D6B03C2; Fri, 15 Sep 2023 14:39:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 778E56B03C3; Fri, 15 Sep 2023 14:39:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 581AF6B03C1 for ; Fri, 15 Sep 2023 14:39:25 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 2CF231CAACA for ; Fri, 15 Sep 2023 18:39:25 +0000 (UTC) X-FDA: 81239694690.17.DB2B4BD Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by imf16.hostedemail.com (Postfix) with ESMTP id 70090180025 for ; Fri, 15 Sep 2023 18:39:23 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=zv1eBTD7; spf=pass (imf16.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.172 as permitted sender) smtp.mailfrom=me@pankajraghav.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694803163; a=rsa-sha256; cv=none; b=my7UhQQJTPqQaTXpCgsFrgqqgchScSQJBgPVIQsbDHtn8WqXa15KpV0k2nJJHKQE170bF5 9SdIfcp0HsQUHwq0/Wh3EIx2RXNOaf848I71YKAXM84V78l3XUh1WRoOaroV8SmFr+CfE/ hxFrm1JRUS2j0agj8iYIdST2IYkZIJ0= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=zv1eBTD7; spf=pass (imf16.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.172 as permitted sender) smtp.mailfrom=me@pankajraghav.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694803163; 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=SzrHPPmJTKjWfDrn3YXBgU9n1TNPo/kiGOZujmxfC3o=; b=6aCJQq+j2OOerDU8oobw898PfEi8asERsvEDthSa1f3qm1pTvx8X0e6p07sI1HkcZdW//r 8NshLmyq9KZwztde7Bk41CWDPOPmi1SNiWMW6phgJV1vkGfgEgnnmdi5J5uYGUww70vs5j OucaUEcTRYrLq0tvM0wLGio3P9U2drM= Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (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-202.mailbox.org (Postfix) with ESMTPS id 4RnNJS3W0Xz9sbL; Fri, 15 Sep 2023 20:39:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803160; 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=SzrHPPmJTKjWfDrn3YXBgU9n1TNPo/kiGOZujmxfC3o=; b=zv1eBTD7DSyKB/ZHl4zr3fiwfusUpLKbzkWEafjVoKUx2xfMK7rklsQPPIp19HKeoo3l8c FWeg/koAWMOCS5X6e/FiZsa8S/OteBDH7E1VOVQjIAhxRZxG2855TiW8pZ388XhUkviYq2 bUYv3/X5vM3Wi4vWfiFfR93e4/3fPoNylQkICflCDoirfo2ziNslgUpmYPd0h1VRhy/zgi U9QpS/GtWY71h/CXkrwsXNlNbS9TdIZ8rep7TVuhIWNrq3bhlA9o+chV8bjGafiMcWHOQs lIMWb0XukJXAYtVaua7Mngo8ueNlG8zrZT38tUYnIZNdtKRF4sPJFkbVEB/wNA== 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 10/23] filemap: align the index to mapping_min_order in filemap_get_pages() Date: Fri, 15 Sep 2023 20:38:35 +0200 Message-Id: <20230915183848.1018717-11-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-Server: rspam08 X-Rspamd-Queue-Id: 70090180025 X-Stat-Signature: peymcnmkxj3swsdx7w4japtja5m5kb3j X-Rspam-User: X-HE-Tag: 1694803163-419005 X-HE-Meta: U2FsdGVkX19TQFtsrBLhsdmj2HBT+B31wbidNKcKugHzaVvI7q3o4tcS3CGYuhCbHHX6t7TSJGuOTgj5RFQslxloStFHpfeuSsQ9OMb88p8bhogvXuV6jLZFfaOqlD6NKKBbOvnr+4+rTT/6jf5lsCeY49TzjW6M9y14WqCm6bZAuxSa8k+PjY0eQOlAiFOiK217p8FS3tDYb24Sej/Tl4KKeqFuTeGAp3HSULgH3xHId1htqk9WgdKh2QI/YrHwHX74I/LO9ISgl/urfLagiFkd9ZrHxDlCPIvLjR8bpGqyrwCibhen0DSHg5FH3rgz2KU/joGRuRVSYQViLV7sG3JR9hMixkd+qutEj7NgsQNVICA63dP3T06cUYSflp4ZR+T2LpQvfQ7Fp6UhgH/IrTSiUyVA3CGjSaAmp2xaLnwwzwLiYKAhtZmyiKZ8PcgrNts3jmQuJ8xlonHxilu0AXIfRDlHLbUipZ2PZ1IwwUprtfb/jNXOXUbXViX7qRA4GIyrbcoGw3k2nuNUkXIy/KOTGWS4nPkGoiheslPt06A7OOaFdyYB55QyHcS27kAhssfrlTP5JOyl9bV6PkUaJ08xBpynM0pHmfF+pigm627TWE2oEsqfeVlC7yB4CHAvVvmw2hYnOe00wfsj31ReGDLI3W8IjyP+Siioq8dH2onny5dnm8wFxURbPCJtjjthiI4y74WNaZ36VEzNIdqYfaOici7M9hgaxndkTEEGtIid90IlIetJ4vDtaLmRf9oQ6Dl48X1zQcD5F76+PauqTpXb6RF5F51PhT6oUnIwqWcxvlncfEvUUL5KMvgZUr+lOzm2j0eK7OGXhlOR2IiC5MhQONh0N2KfzONrWRVEvkUet3jhJMKJCqWzhsXmZxfdviYQxWjPW8MrRGEKw0sTnsxWdIXdpPkiJzDumzccNHr8+J2Qng9v+FsQ3DjkIPtQNUrxVuaTrFcSRmrBp57 OmRbx8DD ncMh3rsZcTJK7+RcxgQq3zIui/N9hAcfMia292tgXIu0RN/gbndZ9zbgpwbOyHNzOqjTa5O4s3/Wtl4DGV7jg2EdD4HoasTvNkzU5l7GWIRqY68J0ANYpYQG3qwzOQb19/eiGvP8q9kBqzAPwFmBDVlWJJvYo6EyBIOaKvKjAZ4Nb/J4hr3AeypaE9nNdblN0VZyL1GB3yT6UGjL2pIev7+6sI22yH9VSAbpDPKFr3/zsa2MWb4XbCYzDhZhQWiHO7fZYk3PagkbUqTSjl4r3c+zUNt53O3eWNy6IA1eJ7UAiuNkJnY5XSSA4PyvV22oN69xFxz/cTvPk1truUxpyc7BM+Prm104BUAWdGYEiMSbsN6GnYmTkxK9gGyzaeDqsf5Eg4dnv6cOKQD0= 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: Luis Chamberlain Align the index to the mapping_min_order number of pages in filemap_get_pages(). Signed-off-by: Luis Chamberlain --- generic/451 triggers a crash in this path for bs = 16k. mm/filemap.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index e4d46f79e95d..8a4bbddcf575 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2558,14 +2558,17 @@ static int filemap_get_pages(struct kiocb *iocb, size_t count, { struct file *filp = iocb->ki_filp; struct address_space *mapping = filp->f_mapping; + unsigned int min_order = mapping_min_folio_order(mapping); + unsigned int nrpages = 1UL << min_order; struct file_ra_state *ra = &filp->f_ra; - pgoff_t index = iocb->ki_pos >> PAGE_SHIFT; + pgoff_t index = round_down(iocb->ki_pos >> PAGE_SHIFT, nrpages); pgoff_t last_index; struct folio *folio; int err = 0; /* "last_index" is the index of the page beyond the end of the read */ last_index = DIV_ROUND_UP(iocb->ki_pos + count, PAGE_SIZE); + last_index = round_up(last_index, nrpages); retry: if (fatal_signal_pending(current)) return -EINTR; @@ -2581,8 +2584,7 @@ static int filemap_get_pages(struct kiocb *iocb, size_t count, if (!folio_batch_count(fbatch)) { if (iocb->ki_flags & (IOCB_NOWAIT | IOCB_WAITQ)) return -EAGAIN; - err = filemap_create_folio(filp, mapping, - iocb->ki_pos >> PAGE_SHIFT, fbatch); + err = filemap_create_folio(filp, mapping, index, fbatch); if (err == AOP_TRUNCATED_PAGE) goto retry; return err; From patchwork Fri Sep 15 18:38:36 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: 13387472 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 89EB0EED61E for ; Fri, 15 Sep 2023 18:39:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 954566B03C3; Fri, 15 Sep 2023 14:39:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 900826B03C4; Fri, 15 Sep 2023 14:39:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 77B086B03C5; Fri, 15 Sep 2023 14:39:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5E6336B03C3 for ; Fri, 15 Sep 2023 14:39:28 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 03D4E80775 for ; Fri, 15 Sep 2023 18:39:27 +0000 (UTC) X-FDA: 81239694816.18.6BE3DFA Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by imf15.hostedemail.com (Postfix) with ESMTP id 403E8A000B for ; Fri, 15 Sep 2023 18:39:26 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=nuY8POIA; spf=pass (imf15.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.152 as permitted sender) smtp.mailfrom=me@pankajraghav.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694803166; 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=SlByD57EXAWo3wBYWh+1jomz9iI/v3Qz7x+/AUImBzs=; b=WYp0N3OnYJc45UbzwubDF3UPqQNV2VJEk/3gZsObvNK69LKK53gp4GK4lVFdh3dpCLiiRh ELAdP33QOIYrJP8fBQWbks8bhGSJ1ftPsdkCX5/qhuWLYhMYhtBfVXfApJ+cGvMVbBrGxx bTtxZ/D9frUpCe8SSlxEcvnCzSnDNDA= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=nuY8POIA; spf=pass (imf15.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.152 as permitted sender) smtp.mailfrom=me@pankajraghav.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694803166; a=rsa-sha256; cv=none; b=7j+KNwr4cfdMNB9DBNE696xH8wwsJDiEjRpGQlbECpxX0+MwS3V07x0+uWqMkIWHByY3+o DG+rhGqmxdKxju44Nk+gfEysFKHlW6AEXDi0IRK4yoK5DF/2w71KardBUZlcAwqN/2Jv4f k5lxhV95RgAAT5QVA5YN26AHVRHDj0I= Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (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 4RnNJW0zkCz9sZG; Fri, 15 Sep 2023 20:39:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803163; 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=SlByD57EXAWo3wBYWh+1jomz9iI/v3Qz7x+/AUImBzs=; b=nuY8POIALXl0in4GfMc25TJC8coBeQG43+Ouex9LRzUcKwK8I5c7EEHIH+My1vP7A91IWR JpL8fg2KOkRRAcvKGXz+vA5/mbGmclH2WEI7vYKQZvUUY4PW+gydMVf/nU+wSdB/tEf3iD 7fIcfZwKxubSL8Be38uKFiNVIgOf5DyDHV87W0Y8X7Qk+tOJCtgkLZ61qi2KNIDwl4i7WX csxEGgzn3f5nPGSOcT7rO7zljDx1HiVZ9pDcU5CfZ4XyxCcK3iXZVxeySqazerokuxygMm 51rE3zIIvycA/2oxNMkX9/yceDwSbawy5u9l3xIe2eEB7PyD2gY58zVvZs2hxA== 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 11/23] filemap: align the index to mapping_min_order in do_[a]sync_mmap_readahead Date: Fri, 15 Sep 2023 20:38:36 +0200 Message-Id: <20230915183848.1018717-12-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: 403E8A000B X-Rspam-User: X-Stat-Signature: k89a4gobcphfmb4wm6rj6mp16kh78675 X-Rspamd-Server: rspam01 X-HE-Tag: 1694803166-294250 X-HE-Meta: U2FsdGVkX1+NMWW35Z1lJ7jwoDavWlGnkn5+Q3WJVMGlrfmF5/K/I1tHIpL7J5oJ+Q/8k0rOZKXxz7i2m8Hd0AVbxq1BdTDnotDiMXXKHyz0CAj1x4oe91zaMKuAb7yJ0qBGVHrQZLtm2epDu05kFU26PxVo6cglSjoOe8Hl3ECxoH4Lh949Kv+BnbGIl1fbLZ8FMPJtmg+1eQfrprno5oEdnMNXTYxnjqwtPkPZN7HmlgqbGIuZqHkdwXgOa/yOClsRBkXwpbJh6d+RX3MU2Ep7eVMc7DjBYqOT5Le0WM8RmbEw1SbM17IwTebA8Y2C1DgE3Yh5kpEbua2k/Fdlgitf0AxevvrvBscNVPjnJNFTsIGdhw34HWLQymdGgprww6wZicutFlY/SUdGf6St0gB/5NwvkKvcyacsjHBdA+ugXhtKBKqqr7d/lTu/V5ZZSqHGFOjFA7PAaJi0auG6gQ5VLCZxJVJY4OlY35XeEhE2cpau12Yq+sNFjO26c3XcJlQ6s8VnSwlvWl39GzeTMXcFj22jnUUuhdglAwbclm/6rHO+bNZ/Bcb+rnd1bX3DgxwwK0aQ2hj2kQT51Nskd++HZL+VBW6KHL0luO9f6obP1hmcyKv2r+d89C3j0Py7PCFdoxuVBjngAHhWKfgOBQz1gTNlMuMFuJQ+IyXwEEkQi/aVyatXJ1v301DGB1ZvltUkkHOmn0zn+nKqFEP0735wLvxybDemvQQnZ/vXPvaJPOL9KXO1yOmxhtG7SXptz7j3s0NLcSjf/OakwGwbsaLVmMDd3FFBuUVkg0pYgpQmDzMlZjniMJmYuVdBlMkPNajOgo9xCqxcvhCCV/a4P+q5QnXmHNZVnSMHUSb4heMD4xkIDqonU0veEcuYaAWOqTShihkfb3fOeDDi6XZOGdl+TncL2kzLzPRemKWFxoqB4av0NHRvVG+RXOU4Tw8bPlinDPe2F4iKhgM+aom X0mEUR8S hBgPIkdu1qxeQwXOKR4diY3v55JWz4LeCsXssRZAS08zIreMs4PLhuY7l9ZIXoVu2NO+4s9X68EubcoxE3NTjU/zghlmb5/XVS/bAnkaF599S1Jg10kIeQMbkd/JawkYsPGRUNcmMuOqjo+/pD5Vc925G3e49hlTHVSoqfNXwDWmw1mARpTZQBkMmtnbOoD2X42Ix6N0ODj+bPeQfVTzZS+WMHw+On6WMRiHSciY7Rp6vt31Q5A08d3NG8RustPeeQ89obZfp2iovM7M99xvshkBFojE6r3EhVqtYr136vpo/DJbRpBZyQhIpqprqpMrMkxJibQAwsuaedGvB8qNEvaY9Pnog2t0ICQ5y 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 Align the index to the mapping_min_order number of pages in do_[a]sync_mmap_readahead(). Signed-off-by: Pankaj Raghav --- mm/filemap.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 8a4bbddcf575..3853df90f9cf 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3164,7 +3164,10 @@ static struct file *do_sync_mmap_readahead(struct vm_fault *vmf) struct file *file = vmf->vma->vm_file; struct file_ra_state *ra = &file->f_ra; struct address_space *mapping = file->f_mapping; - DEFINE_READAHEAD(ractl, file, ra, mapping, vmf->pgoff); + int order = mapping_min_folio_order(mapping); + unsigned int nrpages = 1U << order; + pgoff_t index = round_down(vmf->pgoff, nrpages); + DEFINE_READAHEAD(ractl, file, ra, mapping, index); struct file *fpin = NULL; unsigned long vm_flags = vmf->vma->vm_flags; unsigned int mmap_miss; @@ -3216,10 +3219,11 @@ static struct file *do_sync_mmap_readahead(struct vm_fault *vmf) */ fpin = maybe_unlock_mmap_for_io(vmf, fpin); ra->start = max_t(long, 0, vmf->pgoff - ra->ra_pages / 2); + ra->start = round_down(ra->start, nrpages); ra->size = ra->ra_pages; ra->async_size = ra->ra_pages / 4; ractl._index = ra->start; - page_cache_ra_order(&ractl, ra, 0); + page_cache_ra_order(&ractl, ra, order); return fpin; } @@ -3233,7 +3237,10 @@ static struct file *do_async_mmap_readahead(struct vm_fault *vmf, { struct file *file = vmf->vma->vm_file; struct file_ra_state *ra = &file->f_ra; - DEFINE_READAHEAD(ractl, file, ra, file->f_mapping, vmf->pgoff); + int order = mapping_min_folio_order(file->f_mapping); + unsigned int nrpages = 1U << order; + pgoff_t index = round_down(vmf->pgoff, nrpages); + DEFINE_READAHEAD(ractl, file, ra, file->f_mapping, index); struct file *fpin = NULL; unsigned int mmap_miss; From patchwork Fri Sep 15 18:38:37 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: 13387473 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 F1E88EED61A for ; Fri, 15 Sep 2023 18:39:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AD6E76B03C4; Fri, 15 Sep 2023 14:39:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 951926B03C5; Fri, 15 Sep 2023 14:39:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7A4766B03C6; Fri, 15 Sep 2023 14:39:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5A4546B03C4 for ; Fri, 15 Sep 2023 14:39:30 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 38440A0669 for ; Fri, 15 Sep 2023 18:39:30 +0000 (UTC) X-FDA: 81239694900.03.54AAB84 Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by imf07.hostedemail.com (Postfix) with ESMTP id 7FA8440023 for ; Fri, 15 Sep 2023 18:39:28 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=k4Yc0Oos; dmarc=none; spf=pass (imf07.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=1694803168; 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=JnevztC5Xa5eXhjQG5gs4g0W7d3IJ4EIEPKbSlyaPoo=; b=2nkSUU9EKrR9wvUBTwZPpxROO/KzTf33TlkFOk605MM1mNu3jAe5BiqrBsohW6cnAg9Brj m5hTGAkhxEqtlv8+sX/kOYgG1jf+L4wTYfWfeF2w/G08h7PAm/JVq8jMZzrFwiDprBvQD3 1w3+G2B87d/IpABpxNkazqqSutecbuI= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=k4Yc0Oos; dmarc=none; spf=pass (imf07.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=1694803168; a=rsa-sha256; cv=none; b=abNmT7zo4UJkgAEBpemTp9LT5uUHR1119nh+ZX2Erp+jAPykihYgI8MLrqFoSzokaBaGcl JE9fJSNWg1u1EIG4/EXFMGxqAeAkOT9+aMD0QxHIiGxcFEQvle73OpdYCdluiSJt3NJ68c k1O9kL0kcYhBXeZ1b0s2MHl2fWlVWes= Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (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 4RnNJY3FJzz9scf; Fri, 15 Sep 2023 20:39:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803165; 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=JnevztC5Xa5eXhjQG5gs4g0W7d3IJ4EIEPKbSlyaPoo=; b=k4Yc0OosuSwPR3GTilJO7yik1UFI1e6xzGKpUTNNry/gNO9lqC1Hn++uqllS/hFhBaUp6j 6BBBUZpa/0JEi+Ai24ps3Zh96w+C5hA/SBom+sueFZylFoXiFJ3xBsGSVR7Kx39XhlqT2H YOlLsSed4aroEit7x8wYZ8RvZOJZ+pga6uAq12op8NlVwJZFuRyGjiIOX/IasnXvy7of8E Bw4C9te4wO/7VvuvE2h4jtQPMc4DTeaiNz65EMObnRF4FhfyLBhafL3EofkDiD+TjE1xXb nF23dD6KEojM6yEaCJImMCaCLpilwthMJTX0vmP0FilI3KujhBBnBd4Doz0C6w== 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 12/23] filemap: align index to mapping_min_order in filemap_fault() Date: Fri, 15 Sep 2023 20:38:37 +0200 Message-Id: <20230915183848.1018717-13-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: 7FA8440023 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 9n1udxsskyp1tw6d3xt5hd1hmeoa6a9j X-HE-Tag: 1694803168-901167 X-HE-Meta: U2FsdGVkX19eykoiOwN9aw/QlDp5LTQG58izWYb7S6jH8bm/WAdz7zjo7C0G6AI2MtgYEt6J1Qz7RiSC+QH8R1S0kdT1MIy3Gr4S9Ig9aUOrGxcwMFEbGOdhUUvCXZczBNtLNlLkeWMPOfNrPaEssr/uf5NIijwhvhpbjZsHsObtQcYm9xBmmk3Sq9QcboiCBoFGgB2PzLTyypRpvB7YQRr5Ab8FPbDNcBLef/ayUUFOT2hIArpdBRkIdsipsYeLRJnZW6mdNKHxWd8y5APh+M0oVW77cPRyIUdH0ab4EyscKXIJhfsv9GbsK5V9W5bHeB20ihCPtO99nx6PJqjGhO8zQtVPj+gjwreTYYOWtoEBHsYYXAYabd4yQmSm9Xkl5t5wYvHX27Rad6XD4D6p74Vl0uGYJ0qOPkg4463v0VQOY1zAfTraewctZxI/ahDjU4eFhDvntgfdBT1Un2SOILRCJtutcrxlNhBSp2FeuGBpz6skLob3CBHm/sIJAqmLighftohXnsz2YYTzWT2lUG6rgE+uUbcvXqd3omtsLc5hLk92GyEgf1rS4T5H3MfMRsPB168QuH7uH0QBNu4t/dCs/rrvgLj7tQjolMJNPXivzklVJlfHCRDckRA5yi9+N2484KNHb0Wy1PEJquxZySo2QB9Yvq+Rgzbjheld6mF7rMGQycLfaYoka6ebXKPbdKdJpM0z/oAQeHfj4qLVZD8CjZ+Ih+oSiBRbeopZjCE5ZrGq4ib32OMfVIrYzkxyHMI6F2CFXI18E0a1TL2DnQ1DwgE2k+DbZ7S11oF+WMo3Wch07zy80n1rzspEFLUIub6SkkAv92y1twsbLk34UWktg7YEqQJazbnGUslLK2bfOn/YEig0YwoZbxSvlqAnH2jXO8A1I2sKXFKqEo8aHL7iWwBOzdk/ABcHooEnX5naafHQ6z8ix8qcB+s7Pt/GYDylUQ2Dd9CdhqCU1Ch nagL9Jqz /HOLPdqtp3YYRYD5ugvn3nrMiNOR1bsGdxjqB6NOeUEqFBKw53q7nWP/0cPo6yt43FHY7BNRRZL6bhOQZTpfMq7CnGbYnXI04koJNvk9yjeVmNakKmbmr1x+Na+jXfnWc73q4Ltqb7ou5GnI5F2OAmunnbohdlS0hrXDkhdKxNXJsLkBJEJk24AzR/u05Yq2SCAfRLPsTzlx2sl/freDhLMveL7sgAS/JkPNi/DN4WV66egHOEjDTmDxCo7AF0FpbLofiinENeJt64waa6C++hG/SP2xNoF1CKtGMfPfKTQiLo2sbFmaGBegZwydqLJ8fiYd1KVhxT4MKWoFg9rR4he2B4Hd290sijJjwXa49QNNRsBk= 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 ALign the indices to mapping_min_order number of pages in filemap_fault(). Signed-off-by: Pankaj Raghav --- mm/filemap.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 3853df90f9cf..f97099de80b3 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3288,13 +3288,17 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) struct file *file = vmf->vma->vm_file; struct file *fpin = NULL; struct address_space *mapping = file->f_mapping; + unsigned int min_order = mapping_min_folio_order(mapping); + unsigned int nrpages = 1UL << min_order; struct inode *inode = mapping->host; - pgoff_t max_idx, index = vmf->pgoff; + pgoff_t max_idx, index = round_down(vmf->pgoff, nrpages); struct folio *folio; vm_fault_t ret = 0; bool mapping_locked = false; max_idx = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE); + max_idx = round_up(max_idx, nrpages); + if (unlikely(index >= max_idx)) return VM_FAULT_SIGBUS; @@ -3386,13 +3390,17 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) * We must recheck i_size under page lock. */ max_idx = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE); + max_idx = round_up(max_idx, nrpages); + if (unlikely(index >= max_idx)) { folio_unlock(folio); folio_put(folio); return VM_FAULT_SIGBUS; } - vmf->page = folio_file_page(folio, index); + VM_BUG_ON_FOLIO(folio_order(folio) < min_order, folio); + + vmf->page = folio_file_page(folio, vmf->pgoff); return ret | VM_FAULT_LOCKED; page_not_uptodate: From patchwork Fri Sep 15 18:38:38 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: 13387474 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 1F035EED61A for ; Fri, 15 Sep 2023 18:39:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 583DF6B03C6; Fri, 15 Sep 2023 14:39:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E7986B03C7; Fri, 15 Sep 2023 14:39:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E8786B03C8; Fri, 15 Sep 2023 14:39:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 1351B6B03C6 for ; Fri, 15 Sep 2023 14:39:33 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id DE03016022F for ; Fri, 15 Sep 2023 18:39:32 +0000 (UTC) X-FDA: 81239694984.03.3C21D25 Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [80.241.56.161]) by imf16.hostedemail.com (Postfix) with ESMTP id 3ACEF180011 for ; Fri, 15 Sep 2023 18:39:30 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=RPZ4s8vK; dmarc=none; spf=pass (imf16.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.161 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=1694803171; 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=q4TCivlOldBFT8Z2wAp0Ng9dYEvWAP3/q/X1t2+ztPU=; b=G0sfgx16bwnomKQKODvQHUXszlN7A9Zi0ktgi4UTFJvveUu1y5npxvPAldQGEVbRzU05RP U5BgRB3qUJ/NkbYzSgeE3opV0xYnQh5Qvl0Moq5WXtprn6nGWZCwTAaLQ/hYkQuopHtm3k 7V5x4MACsLU/9k5HzNoLEmOV+xbayUE= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=RPZ4s8vK; dmarc=none; spf=pass (imf16.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.161 as permitted sender) smtp.mailfrom=me@pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694803171; a=rsa-sha256; cv=none; b=tQJqNO6M3bXZaKdzSB+s5B2dp9HGTfX6WKwjcwgkPc7i1jcEhIp5M9gihSDTVWci2LGuah gPKNDinSX0dw/9F/Nnq3B7feeu89nKnPyKjyJQJHe2sos/FZAtl526juRexdMJ/5GtJlyK gzxMhzxxOt3uKubkrhwyv7zEixK5JQc= Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (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-103.mailbox.org (Postfix) with ESMTPS id 4RnNJc0jbrz9skM; Fri, 15 Sep 2023 20:39:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803168; 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=q4TCivlOldBFT8Z2wAp0Ng9dYEvWAP3/q/X1t2+ztPU=; b=RPZ4s8vKpZT/VgCDTXGfaQnmmINoQDMFRzcMXIHnpBidw45xmmsecAsEx/bgHiklwedk3E jvirvcLSdjCEKPoKBTXOwRhiD+JcHZqICcAdTub1hkWK1sl+vUO2I19nRcEBG44QWyKZYa Q9/F/S6P5EG0+NyIw3zXCVgYKM66eP7A+kreb4oIgyIl6glr1J0ELYt+/5YuNN/+WZ++4c gG0NIEJsO5zNGaAPcdC78ZH6UEtst+I+MpVN/IUixQdfIfKRDwezhqBQuACrnDm0eW/GMh 9oc+cvHQHKIr4P0CNSWVZ8eOFxkQ1CJn2IaTfklFETTMeeOw5hpiP+jYbhuJCg== 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 13/23] readahead: set file_ra_state->ra_pages to be at least mapping_min_order Date: Fri, 15 Sep 2023 20:38:38 +0200 Message-Id: <20230915183848.1018717-14-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-Server: rspam09 X-Rspamd-Queue-Id: 3ACEF180011 X-Stat-Signature: opf7azf38qoy1u4tzbe5ts186c4c416i X-Rspam-User: X-HE-Tag: 1694803170-303403 X-HE-Meta: U2FsdGVkX1+rACvFKl4XGTLFjldpV19MRhX6fb5FR+SmexipYXcPLEn6PHwpfoOwV6lRnV2hNcsXhWu1hZ2TPzmGv7b+3BiMgQE21yXhMKkNBdys5JKvxVrOVm9PSbUFgl0N4bLvCyoswZx5pkLRMPBBgXUsfnsm8lwzwqAIpRdr7cCqL8UhsL5RowpoRQI9hIbQsGbNbCGkoma7DFK+Z7j/1Pwz4UygcB/SnEnQup8TCx/cFuzPd1+XaW09zEAZvHYPEGqIRcV/jrQJm+f4rVTG8U6fEwLETF9UbgBoT+i/OOeO/AamSrG1ySHiEtbxWoRn36RbK7yYKwQ7bIJBbAA32VSdGxruWVUGSAiBongnkKm21RMuFUScLrMxg5i5j0usEsnnUKx4irj7+msNlSOtcFQToK+1lMLc0HnLO066zaOtl8sGSmngZzGQ5p4n6ANLA6SQreZvrEMiFgrt7sFxw5e3DXXn5uxBwa7VOh+NTjwwByAPl6LdhsLNob3oabZjcrdQU+XT09HmHh1MQ8wzx3w2+M3SZcFwD8nNJj0cZVKHWzuidCiEVo1J/3yXg9BRXQlgrgDEbScoFa+8xP6Csf28hGzdCH3KKN5otHnh9ER2/vLrq//noI+0Tbdp8EGL7EckVSzOEnDh1w4VL8D+KQJImQDokVT8OUoIodL0wn43VhNsXmFH8YWxELuKbRTwADSp3q/8W6W/LxGAqI3qjUeS5InAfrlsGELN8Ao+m0SrN/uxc+by2rMJg1RadUNnonWMfUH5F6bGltal86ajQZoWZ4ZXa+Jv5pdXherltnsEO6tB+l6+WJgLF1IQ685qFepNDzKRDAvhJVGgzuldH7snEV2WPoDqnVj7Pr0bLhtLpoZF24cD7+kx5zixjkCZyUi4yNCliEcFRD+NdmYIzXRVd8LUguzb3DKrncCY2TmCC+BreKFTVmjZ9/5OK1pvF6u/hPW3ufJiQSs kzo8jhXZ Ltq5kPW3SfeWgtsZj0n7OCHnUb+e4gXLxtb4H53aMchEze3xp9sVL6woBtk0DdmT0CWoeD8bHvzk2JT3TZTi/7T8uRdQut85b82Gmcq8C7SYOukSDfkxu93j04s+W8mHTEzST35wr5z4dUdRrGSblP/PC0QF4qZdpAmRvP5D9Ax7cItvzDPlHfGrTs/FTE9CLERaurxbmvKiR1AjGsX868E641O0uOxGzyV/DkhXtcnDk5mUKMg05tG2QViP176btgxERKw4ZcMs5O/yUze7ODwpKNbEmH9/qXYHkH816/zKZJJKpMiyLquJAA0MVfAizCiDhx+KfBxnOhd+ruZgxCTuDrGqHpbTGHvBhbT7/ave4UzALPMLx4XEkcyD5Cxv7CrBqckArXh8g/jEOuLJdQNf66Ud1OEKibgYn X-Bogosity: Ham, tests=bogofilter, spamicity=0.000021, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Luis Chamberlain Set the file_ra_state->ra_pages in file_ra_state_init() to be at least mapping_min_order of pages if the bdi->ra_pages is less than that. Signed-off-by: Luis Chamberlain --- mm/readahead.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/readahead.c b/mm/readahead.c index ef3b23a41973..5c4e7ee64dc1 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -138,7 +138,13 @@ void file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping) { + unsigned int order = mapping_min_folio_order(mapping); + unsigned int min_nrpages = 1U << order; + unsigned int max_pages = inode_to_bdi(mapping->host)->io_pages; + ra->ra_pages = inode_to_bdi(mapping->host)->ra_pages; + if (ra->ra_pages < min_nrpages && min_nrpages < max_pages) + ra->ra_pages = min_nrpages; ra->prev_pos = -1; } EXPORT_SYMBOL_GPL(file_ra_state_init); From patchwork Fri Sep 15 18:38:39 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: 13387475 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 51CA3EED61E for ; Fri, 15 Sep 2023 18:39:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 72CA06B03C8; Fri, 15 Sep 2023 14:39:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 66A1E6B03C9; Fri, 15 Sep 2023 14:39:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 494D36B03CA; Fri, 15 Sep 2023 14:39:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 283336B03C8 for ; Fri, 15 Sep 2023 14:39:36 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id EBA531201B8 for ; Fri, 15 Sep 2023 18:39:35 +0000 (UTC) X-FDA: 81239695110.29.56B548C Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [80.241.56.151]) by imf12.hostedemail.com (Postfix) with ESMTP id 31FED40015 for ; Fri, 15 Sep 2023 18:39:33 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=vcPcMUF6; dmarc=none; spf=pass (imf12.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.151 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=1694803174; 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=591wcX/aNYK1i2+Gpz2G47nBurFy4yzLeb3z8BH/s7c=; b=i4Kfl50BO27Gtg53TGHpWeKB3oZ/gQZL/yx5af3pzW2pXrfsjP5tc2kBcrkoF0oB0pn5Ay Trasjm/Bc97MFbjHLg+CJVdGG/Z3sJ46SFGl8fSu5cDdqatOkkrJSNr+aaL/waYrAl0irv J/H1oAMDsf6ntT1RRh4xFOBPbDnQMjk= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=vcPcMUF6; dmarc=none; spf=pass (imf12.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.151 as permitted sender) smtp.mailfrom=me@pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694803174; a=rsa-sha256; cv=none; b=Fn8RKYHNEXeGS3yBAQ3NZ80YPe+knSxc7jMBtM/bY91Ul2GVFsQ+RZ95VKTs30JKPB7H6a d3Fe44wz3ltmoSgaNyIoA1+5Cs6tO/hgjdJTK/CjajnUlBO12gcS4D7eq1mryw5pb5CiQX ssQEosMWD4RoV6U4ULYpdmgCpXRHn6k= Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (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-101.mailbox.org (Postfix) with ESMTPS id 4RnNJg0GXfz9spB; Fri, 15 Sep 2023 20:39:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803171; 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=591wcX/aNYK1i2+Gpz2G47nBurFy4yzLeb3z8BH/s7c=; b=vcPcMUF61bQ2Sox+rVmcmmFCT5EqJKJRSDzMWuT3qx6Cthz50vAI4MWCBIJ+/FXhvQQT73 aUeCtC3yGQQ9yF6AYkBBl/xbuC7mwlJcI6rdrJUfFIxTR6mKGWW+d8riBrqwJycp2FTOK+ rSdoOS7Y9ZY2iIqkKtC/1Mzz0BmkWZt3aY7oRXjFsQGGWCf7vZNYfMMwkyXPXqdMYBuSqv YshJdlp/P1VfVHttkHmJg2rDfDIzV5tFlpdaI9rPLXUlzcICnaqjt1ipzU55sAxa6mse0B f3qJ8/OF95BjLF3LDOCPsStttf1OOn3/f/YPMTzUtd/kfRx+XXvz7QdxF3gFbA== 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 14/23] readahead: allocate folios with mapping_min_order in ra_unbounded() Date: Fri, 15 Sep 2023 20:38:39 +0200 Message-Id: <20230915183848.1018717-15-kernel@pankajraghav.com> In-Reply-To: <20230915183848.1018717-1-kernel@pankajraghav.com> References: <20230915183848.1018717-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 31FED40015 X-Stat-Signature: c3uy48x73ws1hts9x69qkfx6xn5pcks6 X-HE-Tag: 1694803173-272698 X-HE-Meta: U2FsdGVkX19Y0/NGyVGKKspjLuc+G0SmSaMzPP5VRlNnXxK3CoQqjpVR7rQdnP+RbrEjeJGDG4D9hbeTmmzgkgCIyTnxmm32Oik68XdeXRdjAueIQna0dEYsvgMVnr9/leEd59LYc06p7cvue9RjAeDPV8mR2MMYfzYV3EUBQspkh20uyaKzEhqxdER5yKcGjtP8dKcVUEQDIF1YnDsk2PYrSRRO0hSEJ1ZTl5Lwpuase3/hlIrrOk2VLGwHxjCRDs3jJiZvS17XU9/XfGVX72hi7jBkCPALkEuCz46dHQeJqpFROHyfcsTWEs6ObpQ8kToXE4ck6dcOLrAYo6lHDMDmbjjJ5/lI/mAAVRl79nCI0fZFQNbur1tnZ3rKgY52FXAbPgXp+rKVTwsTV28D12wi39y/ZWImthxqEK4+qEOJpIPuwVQXHmqEXQU4nZLeZdZYbDEF+2QWrVbGdIGoiv726rg+fWD19x6tXpRbOku6c78IpVIhlPESMHllapLFwOa/9ijGzaelKuRWio8c2D/PV1pyRsRF9CuLzXI9Z3iJTCplnJ+oklNSmc5Y54x4CY7xfN4u9JhnldfSPPTh6i+rAQY6Txj7G1NtBTIJS94iCUw2UmEl7ptpqsD8PAgunRK1CdmQ3kcLoy0nTaGvLL0U5epfv4UZm6Qvs5XLVDy8Xm7RNFkJgb+t5h68kLc6YDaE1EtvbB//Z5LH4s12Y7khVd7qQhopmV/5h5a7yXszfkVrTLGM3Lk7KZvZNgSXyqMd7r8vNUQPNbvTIphUalEL/PfuuOo9NMWEqQwI3Iymud1NuKtohSGujtVtNgvrw+CMWsFLLwLNomDM9wGPdL98QwP+4WnpLabTZ/gWWvNbe8KDSGhP5fyNdLTEN+Lej+Ehj1oN6475vesG5rjjg6tYhIOypvEpPfF/BqoAya5vbNudWZDQBIRa1Nm50CZx+yw1Amya225iE2JxRUk uZGjuJMT K90uZHr0s+0a7y+J5pzBP1UXSFUa5jsQGkL4ItFg/jRZXDY0SRDxvIfnZgqhwst6kONsbXKG19YDuQi86EzCnnG2guRzF7dUMrCTapzmUMEAcYyLiRTv7+dX+6lpfec4WADEjOq91lVP4GYenjuJ2h3I7k6lwyNxUNfm28hWDv93ds6vJ5ol3s5yE1aEkRvDIZiXhnsN0S8++nn3j1E3pwVvDNafFb11rG/ASODuN+nbwfFgvyGRoRXznDw7fhL5HjBa4lFp7oMaJuwwGGHkhCp6wBPXzNvJUR1QDHxiQR8FLBphWPskHSx1R+uvow5fBKPimYVVvq3JZClXawKv7jPjrK9snNB9gESEFw2vYTGqD7rss2DWWJq360fCqFUDqMBp4 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 Allocate folios with mapping_min_order order in page_cache_ra_unbounded(). Also adjust the accounting to take the folio_nr_pages in the loop. Signed-off-by: Pankaj Raghav --- mm/readahead.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index 5c4e7ee64dc1..2a9e9020b7cf 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -250,7 +250,8 @@ void page_cache_ra_unbounded(struct readahead_control *ractl, continue; } - folio = filemap_alloc_folio(gfp_mask, 0); + folio = filemap_alloc_folio(gfp_mask, + mapping_min_folio_order(mapping)); if (!folio) break; if (filemap_add_folio(mapping, folio, index + i, @@ -264,7 +265,8 @@ void page_cache_ra_unbounded(struct readahead_control *ractl, if (i == nr_to_read - lookahead_size) folio_set_readahead(folio); ractl->_workingset |= folio_test_workingset(folio); - ractl->_nr_pages++; + ractl->_nr_pages += folio_nr_pages(folio); + i += folio_nr_pages(folio) - 1; } /* From patchwork Fri Sep 15 18:38:40 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: 13387476 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 17AD6EED61F for ; Fri, 15 Sep 2023 18:39:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 13B3E6B03CA; Fri, 15 Sep 2023 14:39:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 09D1C6B03CB; Fri, 15 Sep 2023 14:39:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE2296B03CC; Fri, 15 Sep 2023 14:39:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C42FA6B03CA for ; Fri, 15 Sep 2023 14:39:38 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9258A12069D for ; Fri, 15 Sep 2023 18:39:38 +0000 (UTC) X-FDA: 81239695236.07.895AB00 Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [80.241.56.151]) by imf26.hostedemail.com (Postfix) with ESMTP id D01BF140010 for ; Fri, 15 Sep 2023 18:39:36 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b="fhFmL/xO"; spf=pass (imf26.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.151 as permitted sender) smtp.mailfrom=me@pankajraghav.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694803177; 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=yxVtlX4JC4EQtNnH6RIJ+6iaeftg/wvFMQDW4McP7fo=; b=5VP4FvIPFs9WJwzPMsscApKqjv/Fb0W5/9sL+PfYpRp9k5nfwqESsD3VUEWWBYBztZSstI Y7klF/S51KvwblIhHFr87i6M9WCHVoSnd8cmc8m3hXelWtc+B61g7/LkICR2gyo7Edt8qg cRjhc+N9qf3UuqyGmoa/HAmq3HfsIr4= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b="fhFmL/xO"; spf=pass (imf26.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.151 as permitted sender) smtp.mailfrom=me@pankajraghav.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694803177; a=rsa-sha256; cv=none; b=5VLxN8UHnuAVEzPi/QiLcJ9DbI3Lwr1NIkD2XgUWA9vfgp4m0cRA09KHBhXHtckToTeSKx 4ekRmLWRlNghHgagoCz07eQcTgJQZ0bnOgO8grBrWJV7zEzO4fW8Be50H1qoh51X/noHd6 weWgLZEj6vSQG+dj34k7mvE0P4BaCzQ= Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (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-101.mailbox.org (Postfix) with ESMTPS id 4RnNJj5YhYz9spC; Fri, 15 Sep 2023 20:39:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803173; 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=yxVtlX4JC4EQtNnH6RIJ+6iaeftg/wvFMQDW4McP7fo=; b=fhFmL/xOdq9mWLRpb+jiRZQGXQH+v9Jn5su2cxMbr34SSR2VWXkAgjIRsLKaW4gQu44flC ac99JAjExWoh/6PTq9AGdXvJTewS4mWWjcU8AwxzTqTqhvOnuPZcZ5HgczOylODoRurLAS dBOKCG5FBvoZxsnu9YkS7LcQp0YemfRvv5zpGUolR7hVqtYLEuI+LrAh7OmYZQmhFgbnSd cNe8R2/Kte9KfMu0Vz5bUpVjB4o6PFg6ddvgFTssdCPEm9woE0ZYBLMWscLd5hZFJV0luH kv6+9jNXZ5NWVNUcbSomGZ/kPoUmVQTyJIYr4I4QDmrpyENc7FzrWcm3inttmA== 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 15/23] readahead: align with mapping_min_order in force_page_cache_ra() Date: Fri, 15 Sep 2023 20:38:40 +0200 Message-Id: <20230915183848.1018717-16-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: D01BF140010 X-Rspam-User: X-Stat-Signature: es9sra4r7dq46orf16twek1s4g4ofrzq X-Rspamd-Server: rspam01 X-HE-Tag: 1694803176-317029 X-HE-Meta: U2FsdGVkX18GZrgxdVM7HWV2r2xoBafr72d/h7Onz2Hb+UJ/rRq1JNyrQ69D/PnfcQvjwYDPdoYbM+Gs1rx+E64OAVCrZY8RNn8fdyKmupMDGUZoimZny2p1QWxhVBfiwLVMjGOfG1it5XQhJBrssKEv+ZVzAc0DxLmNxnaHwUbRWHpmSr15WLHiPtMWoTD0dHPPbULXwBNcOP+Ai9TNl0HuqDWvkRZBE50qXOHnZZpSYVSWfnmVen7hDKDXLM+PjaMudW7Iop8odGs5geL1fIMETzdZzX8QI9eDsAFFBxHYcZzlVqdf48wuJJa47K4TAoRPNdEXYgT8L1gJMiRdUlGhxxBhMvnXeV+i76BEzu9RM6e1M6lwAhxeGximMgmYDRz3dCOrhD9gJxFktRpZwDj6Oh+JH700msWjjD6CcuWrC7dKEmS82IqGiNltHsdYBrz1cUVRqXS0w60pszYROO0Ppqg4XZ3AovCfpzipYhPAKsQbnvqBFpCklojsnZ1CNxhSyt/M89TS7BNu51G85w507JmIznpcVCVdflEl7a5RNN4WljNVqLzDSYCS3Qbhiu78FG/EtOP6EnJT0XCPo0q4s41FUIDISAb2FnNQFFvVa/qxqBvILdZwOYzH/6gh8cy8M0Ju7i2rPbzf5kuyxwxNzGEaIzJD54vfMrWMnu7IPy7Y7p5XfZLOF7HBaiajqqa4KWBoX1Nxo6vaVAOvEgzeMG7MP9SQdRJgkUUCTBUSidmYS3Wsk3AvEYOCMZayiHfHBzzBOWxiBolOlHVsYQb9Vsa10tkLeFzLROE4Mezb28mzdPww91kBJEPczs9QEChLHER3ERNJgTArqRAyvUMv1aoW+xX5XTn5x40IlrV4o9DfIRI4rWuXQvk4/5vh98ut0drfUp/YDmcH1zI9jlSQmx6aimu7GSDsQWYQsHg5XQc1P2fac3RAd1FdTMJuFY52LPUSfi0w4BbRtPp 5WolLGb/ iqYH7atzGBnz7Oyr3syIFIFf1OHSiOsEaqcjNOiNb23kPJdGnU9cpvm4DXdsuH3TDi7RacsxQ2JaQDz+pLBO0fQS6a++984TSsxXu8JzfCNAxQkZrMJV3EYSR8D5lKAbPiJ5SXwqPD2zzKVneiJrTX2cZrTiwSphTKddxkXi6BphbMh7sAXQ9iruyHf6d4eGiYvusHmdSp7S5HNwpB+cqv2XB2un/BsqH1cPqcJL1LYP6R7bkcPuHhKmi+nkd5X6d2KLMTBTlbX2c+VhM/SOJAV4hlpx4o4dtITVnOtp15Wzvru332Zh4ay1EB6dDKw6YK9KoW8KYOX3d4781LBrw4/xsZSZhuAv6TfuRUZAY4EA8TCbV7UejDvQRBUWeKfLqc2HZ 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 Align the index to mapping_min_order in force_page_cache_ra(). This will ensure that the folios allocated for readahead that are added to the page cache are aligned to mapping_min_order. Signed-off-by: Pankaj Raghav --- mm/readahead.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mm/readahead.c b/mm/readahead.c index 2a9e9020b7cf..838dd9ca8dad 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -318,6 +318,8 @@ void force_page_cache_ra(struct readahead_control *ractl, struct file_ra_state *ra = ractl->ra; struct backing_dev_info *bdi = inode_to_bdi(mapping->host); unsigned long max_pages, index; + unsigned int folio_order = mapping_min_folio_order(mapping); + unsigned int nr_of_pages = (1 << folio_order); if (unlikely(!mapping->a_ops->read_folio && !mapping->a_ops->readahead)) return; @@ -327,6 +329,13 @@ void force_page_cache_ra(struct readahead_control *ractl, * be up to the optimal hardware IO size */ index = readahead_index(ractl); + if (folio_order && (index & (nr_of_pages - 1))) { + unsigned long old_index = index; + + index = round_down(index, nr_of_pages); + nr_to_read += (old_index - index); + } + max_pages = max_t(unsigned long, bdi->io_pages, ra->ra_pages); nr_to_read = min_t(unsigned long, nr_to_read, max_pages); while (nr_to_read) { @@ -335,6 +344,7 @@ void force_page_cache_ra(struct readahead_control *ractl, if (this_chunk > nr_to_read) this_chunk = nr_to_read; ractl->_index = index; + VM_BUG_ON(index & (nr_of_pages - 1)); do_page_cache_ra(ractl, this_chunk, 0); index += this_chunk; From patchwork Fri Sep 15 18:38:41 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: 13387479 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 F405FEED61E for ; Fri, 15 Sep 2023 18:39:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C37FE6B03CC; Fri, 15 Sep 2023 14:39:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 72A606B03D2; Fri, 15 Sep 2023 14:39:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4DF3A6B03CD; Fri, 15 Sep 2023 14:39:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 93BE96B03CC for ; Fri, 15 Sep 2023 14:39:42 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 6C1B1C07C8 for ; Fri, 15 Sep 2023 18:39:42 +0000 (UTC) X-FDA: 81239695404.25.2FBC76A Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by imf24.hostedemail.com (Postfix) with ESMTP id AE8D618000D for ; Fri, 15 Sep 2023 18:39:40 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=flQNjUny; spf=pass (imf24.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.172 as permitted sender) smtp.mailfrom=me@pankajraghav.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694803180; a=rsa-sha256; cv=none; b=T+hgn3Yieeqso57uYAg4PXK1hciln4L29RRrU824j3wHEc4OfiwK0Bu31GU7ksyEGF6nPI kEbuiBqTj1tPkCIh7gT53ehNo7tFSIuUdGOg8DvaE6TSil0qC5tRTs8peX3ZF5kEBN1SL7 fA4skqU/CFlVc+luSrtffpq6EC9+07A= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=flQNjUny; spf=pass (imf24.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.172 as permitted sender) smtp.mailfrom=me@pankajraghav.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694803180; 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=iOYqPSu+oVCOd89+RaAtiuAgqa7oaErhDOx7o0+X38E=; b=dqy5wzFKzux89fsjMcS8ttmkPJqzhMQACqLS0UvgNZ6NBEx3yqVqSBDBxfEmj+5e5jhH2D ZVlbwSwoLL3tXfijmw9mvKFD4LMJW45OOLQvVczW9ljAhgj9SArfPxy1S1lhDicWQzBlg/ vv4KcokH1REq55mQVD3/rmglHrdPGdc= Received: from smtp1.mailbox.org (smtp1.mailbox.org [10.196.197.1]) (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-202.mailbox.org (Postfix) with ESMTPS id 4RnNJn36Rwz9sbW; Fri, 15 Sep 2023 20:39:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803177; 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=iOYqPSu+oVCOd89+RaAtiuAgqa7oaErhDOx7o0+X38E=; b=flQNjUnyU25W7ZGoZco4mDtUzalhwJdm/Bip/rbg2I7G+1AE2WK86hUhNm9re8XYQltTbW Q1UDpffAJOx5HxpxhTPWaT+BSJpH86ccESygaGzrHRoAl5a6HWVXDBTEyaXOGrB36BUlFJ UJidHKi+CEgQGEa5bx3L4Zay4lNQkQrS+WRXtZcwIJXqP8EAA8xyZ7WjuimYFHT6oowESq Fo+uCzgXisnLoV5PFAOd1As8LnA3i8F2vc9tZxxok3KJTKvhHophEy6lJ04F5KBoY0aNft 1ZXo8HQVFMQ3CahHpKra2M7qoAf4kdCWBLeQrGgqKkHiklzRWbTaCAql3Y6Xfw== 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 16/23] readahead: add folio with at least mapping_min_order in page_cache_ra_order Date: Fri, 15 Sep 2023 20:38:41 +0200 Message-Id: <20230915183848.1018717-17-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-Server: rspam08 X-Rspamd-Queue-Id: AE8D618000D X-Stat-Signature: rngo3owc8bduf7i1uipkwdjhh67516z9 X-Rspam-User: X-HE-Tag: 1694803180-914093 X-HE-Meta: U2FsdGVkX19G5IrPBf2b6liJQ4CoYNwPDs+o5WITqH5Ki05I8absHamXW4aeiEycaabW+p5FqLFGznX5x0kFDy1eewcImkWMF3fHekbRXY+qnvCD9lEUIQAxc/UUuvW4Q3CcPbxXHtv0qscwcYTMZ4lWXuxLLSvdcyUpU6dEfkmalmZGhIau6HcptNdmyUlpPELEk2gUYk4En3jMKdIw3qWTIgM632L3wii5NTrTuO58csoeq7Bhl/XuAxsN//WGKRnKP7e8bCJ5T1OKwgV30Trq+Gfrmh9/CmmpJ78EDdyH3OcuHGOikHDo3SkhCm7q/HnlRninjdwLjT2xw/t9lcA6mDeJCTbFCHOucGpMi1k2T1qTvZPGGfGhoIOLrTnbKxs+LW9C1xdSGl9Qv1SxtDQdqn0sXRpqwv7lVKjyFiOSzlkhVS5LM7/2HM45ynO51CNu++yMZ/a9NqxOigv+l7krhhROrgIDHZTx3JZUl+cfHtjvdyhtu5btRcCrrv+xvvsJAeib4FLB9MLl6Ky69+htAJy0L6fyDa2VIal6WsM995esoGXJ5SJ22oFi8tc3Q8UZgj+hKLJuEf6N0oUcscAB+Q1ImjmC2HrjNhQGT7+V5UvpFaNd7m1/atKeULux/4cBcAvCZEZg4RvDjdsZB87kawQAsiY8XIG4tj42HRlXM0Ffm3AM6e8ydj5PmWIPU9YcQJn+ERJj+dXMvEgJPtkU4Dlte3fSWZl1OsziqqtJJjhFZgDPYWQDdwDKIW/jsOxnyX3XEU3eYsm85W7EgnXRdxJrmfVulyAi5qtsgsre6/ImBrDtOpANyzpVNHryNcjcFa3SC7SZOB1Uio69sXTmE26S7qn5TQ3PLiC6hsBhVPeFJ+n/3XR8OiUlY3nAKqLymlI6ytZIM4m/Np740qHzQU4BS+T5loXZrh0amXUPQjpsrnDAc9fpqd+ocoz3LvfzH2qe0y1aPMLrRyk wrNJc+Cd GlYZz3cfzv83nOrDPjS8AnJ6wgIp8h1ZcfL2tu7r3aHUJV5ghHeO1ppNvilBk7BWBNJ1UAvGPlX9pRxX82YoSHyoDtLbakyvQygJ3Fzf1OrzPlqXq59AGEBtYIijP06DEQ8/QNAv+2/FHrHgj8MMjtVwPt7jKcRL6ZXQo6jAbKWTPub178rGKEIFwXAeVchy5wMtX488rX4p/QvqAmZGNjLBTPg0v7rtNZYXsmqStB4dFAAoDbEKBXgvckbdaeSgqpXOSzsF/lWOtTsidQT98ww6W503szQepOQ+O14KLqpKjKaZnRNuJy242vC7P0eXlaKeEPeMRr40FnUmNkyhjKAyFrCWQNMLTaWHAkB8Jfril1u5jRKKBEN9aI/Yn9CzENwDPDoGthzaDxMs= 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: Luis Chamberlain Set the folio order to at least mapping_min_order before calling ra_alloc_folio(). Signed-off-by: Luis Chamberlain --- mm/readahead.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mm/readahead.c b/mm/readahead.c index 838dd9ca8dad..fb5ff180c39e 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -506,6 +506,7 @@ void page_cache_ra_order(struct readahead_control *ractl, { struct address_space *mapping = ractl->mapping; pgoff_t index = readahead_index(ractl); + unsigned int min_order = mapping_min_folio_order(mapping); pgoff_t limit = (i_size_read(mapping->host) - 1) >> PAGE_SHIFT; pgoff_t mark = index + ra->size - ra->async_size; int err = 0; @@ -535,10 +536,16 @@ void page_cache_ra_order(struct readahead_control *ractl, order = 0; } /* Don't allocate pages past EOF */ - while (index + (1UL << order) - 1 > limit) { + while (order > min_order && index + (1UL << order) - 1 > limit) { if (--order == 1) order = 0; } + + if (order < min_order) + order = min_order; + + VM_BUG_ON(index & ((1UL << order) - 1)); + err = ra_alloc_folio(ractl, index, mark, order, gfp); if (err) break; From patchwork Fri Sep 15 18:38:42 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: 13387478 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 54379EED61A for ; Fri, 15 Sep 2023 18:39:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8F8056B03CD; Fri, 15 Sep 2023 14:39:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5AEDB6B03CC; Fri, 15 Sep 2023 14:39:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2BC706B03D1; Fri, 15 Sep 2023 14:39:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 2AD016B03CD for ; Fri, 15 Sep 2023 14:39:45 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 0F68EA0341 for ; Fri, 15 Sep 2023 18:39:45 +0000 (UTC) X-FDA: 81239695530.27.8F70855 Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by imf23.hostedemail.com (Postfix) with ESMTP id 67B57140002 for ; Fri, 15 Sep 2023 18:39:43 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=OSDk9FFx; dmarc=none; spf=pass (imf23.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.172 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=1694803183; 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=2MKZNT2C20PsiAht17s5oJnb138+SmsAPSOiRhddgUA=; b=eTcm1b6XO4NfWdVOthx0pPVkeh+zTswt/R2VWHqY4PtaCIKFOFg8Eu8o83tLxYV4tOXwSx Sn3Rv6Zsojw2+sXwyzRz7fl2LhFqdzJSfaMhYvPuqzZWZmyMadCMtkyI839KtRrez9pkVW 0340FlShoVGlB/n9SBs1c+8aPuicA2w= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=OSDk9FFx; dmarc=none; spf=pass (imf23.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.172 as permitted sender) smtp.mailfrom=me@pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694803183; a=rsa-sha256; cv=none; b=2rDGijcEob6oQAVzw0ShR4GiLkR2ypk+O/9bQw6waGdpnALCmnp6RNWTRMKRrlHwYqNLYr PExaRB9+lI4kWsbFtuaD3QKrCfqCDTc5DNUeMrr2tcXAwg02GMvtmcjPuhEtxW3MPAYpy7 2/yTxG3kl6d9Dh5+qy+Y9muCnQ5C/Ks= Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (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-202.mailbox.org (Postfix) with ESMTPS id 4RnNJr2x9Tz9sbr; Fri, 15 Sep 2023 20:39:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803180; 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=2MKZNT2C20PsiAht17s5oJnb138+SmsAPSOiRhddgUA=; b=OSDk9FFxIdRoXpbbJK7NtCBBEbBqbJXSbQ07rvOBw++aALFk+mh/xxdarUdNR4FVlQRF17 67UxVmkLS2OLxkjk+Ll9RummAEi7HciYPbO9Z2cBpMGtt24csMF9mj/Hk7zipaGkJ6uh32 Ct8c4gPXLiSnOw01drlPlIaLlnRBVRgWowE8ZQbP6rTJbkllrV9wlYlk84VeHiSctXNOjP abj4O3zIc0YGlB/1ZOy/IwN/jtsEoCNZu2tkZ/e4qSfNNxLpodXBEK3pvwM6c9CuxXqvzD UdDGI/JtrIJGBBxolWDhZOsfoPzAosRAcphz0UPvnj346nrxjmRCHSmp2JtQ2w== 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 17/23] readahead: set the minimum ra size in get_(init|next)_ra Date: Fri, 15 Sep 2023 20:38:42 +0200 Message-Id: <20230915183848.1018717-18-kernel@pankajraghav.com> In-Reply-To: <20230915183848.1018717-1-kernel@pankajraghav.com> References: <20230915183848.1018717-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 67B57140002 X-Stat-Signature: zg66tsxjzzforem8ke3mu1g91dzcnaho X-HE-Tag: 1694803183-539780 X-HE-Meta: U2FsdGVkX199kF+UQG8H3iy7JtQwwcj/+0bi2/JBHDmEcvnCwbKek9vmIMnpL8tmBZSth0UUtREK2LMZpySFOBibg+ftStJzq7D3zcuiPfN4fkjVxQCbLlkyqkQ11lUmq9uZaPm/MFL3jkFM78cELLzqoua+sE9Z3BJBdItEND/1ypTjUS33/+o93l3aNbbq98qMQ+ougundoMpaEQA4pQ/Kf+6Mpwb9Zke+UIxYNzo36sjXzP2uNIH7FzUXm81/Y2lTUxIrNjfTqqudm7Atm8tM6bEMC2YQAwk1hviZTXFIc12DQvkrWgxln+emcVuZvZp13ivKxfupXPef+QWpTVu0IMH4UiztuK3yo1bDzngW0wzBA53khYVRDjXt2ux073pSEmg2j1ChHqLGjh45Xilcy4v+WP+x89jpXSEH2uH4n8kKlHwRXAh75DIiilPjQx8toXgsm4meEDXNeoXmamFUqZNSJvK7Gu61mx2DyACNGADD85JlwlApvCULtD7O67XgnHUO2XsVF+gsQg9zSTZEOLbiTuTUPYaeuEf6s8gqlwVqry9OFaQ4Qyd+S7WLJzxjKT9gh9Q+XAjuIZmZwRj4Pt5651IyPOJjMh3spoWLhpyoECthUsmXl9ucWU3H/Lka5ocHDp36kpe1C7TZqPcNMIUhJmiKGitRTtD1RxX8L/Hvuk2qO/BC4fdo41qCoK5KoontIjH0BI8ffPMC2oai6WV0tSAaRPEY3qV/82MiDWqTqeTJ8aB3g8lqjiXg7PYJo1zjbe2y8v/Xc4xok3UUnMDf3F+Xi97VODy/+vbMDvtuEiQIOWGOsXYMrlQKEh46YLLWWtKy7UkPdbLC0zPI3Fz5qe0xE4TJ/y5TCmFUy9M41olu4sD/DD9sIEFtju74q1GPQcSrYIB2T07uQkgL33Fj/xj8VdTrWAVSCTuyz2HA6inQ2fttTmzheqAi3m9aRD6IqZpPF9F7ElG ztE8TN11 IOZodHD1K1vxXqAu/S0rSKMdCqirx7KkzpsUWo/0p21dwJIPrAfYao0CZRn4R9imyNqVPENYPUX4eOGPaAfdUz2F14ZCqV7Guumh/NYZb3TnWEOrszUhkRO5GnP3slD2gVKx/RdPtCRJZUWvm1x8nPYVqdqVjfpE2PtW5McxpvO0zL7PD9dQY5X3X6a9Hyx33kaFArX4E+L4I8J95SCJlU3GPkIDa0RYps4zeWzlyDBSMVTD2/5VFGh1VHER15Le6kN/WlawcHv/871Xfgu6GOOn3gfMvoI8/sXGx3/vxPI1A4Qxdvr1hL0bpfMu7PUXEEwHFnM7UE0qARH7cuAAo6doZYk/oeb5nZQjKejoUNeoUSflE45m2N2EIK1BDN1IpD6vB3gZzeUj0RxfXZhej06cnFDsEZGVm79vx 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: Luis Chamberlain Make sure the minimum ra size is based on mapping_min_order in get_init_ra() and get_next_ra(). If request ra size is greater than mapping_min_order of pages, align it to mapping_min_order of pages. Signed-off-by: Luis Chamberlain --- mm/readahead.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index fb5ff180c39e..7c2660815a01 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -357,9 +357,17 @@ void force_page_cache_ra(struct readahead_control *ractl, * for small size, x 4 for medium, and x 2 for large * for 128k (32 page) max ra * 1-2 page = 16k, 3-4 page 32k, 5-8 page = 64k, > 8 page = 128k initial + * + * For higher order address space requirements we ensure no initial reads + * are ever less than the min number of pages required. + * + * We *always* cap the max io size allowed by the device. */ -static unsigned long get_init_ra_size(unsigned long size, unsigned long max) +static unsigned long get_init_ra_size(unsigned long size, + unsigned int min_order, + unsigned long max) { + unsigned int min_nrpages = 1UL << min_order; unsigned long newsize = roundup_pow_of_two(size); if (newsize <= max / 32) @@ -369,6 +377,15 @@ static unsigned long get_init_ra_size(unsigned long size, unsigned long max) else newsize = max; + if (newsize < min_nrpages) { + if (min_nrpages <= max) + newsize = min_nrpages; + else + newsize = round_up(max, min_nrpages); + } + + VM_BUG_ON(newsize & (min_nrpages - 1)); + return newsize; } @@ -377,14 +394,19 @@ static unsigned long get_init_ra_size(unsigned long size, unsigned long max) * return it as the new window size. */ static unsigned long get_next_ra_size(struct file_ra_state *ra, + unsigned int min_order, unsigned long max) { - unsigned long cur = ra->size; + unsigned int min_nrpages = 1UL << min_order; + unsigned long cur = max(ra->size, min_nrpages); + + cur = round_down(cur, min_nrpages); if (cur < max / 16) return 4 * cur; if (cur <= max / 2) return 2 * cur; + return max; } From patchwork Fri Sep 15 18:38:43 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: 13387477 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 E22D2EED61E for ; Fri, 15 Sep 2023 18:39:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4ED546B03D4; Fri, 15 Sep 2023 14:39:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 381C46B03D0; Fri, 15 Sep 2023 14:39:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F9A26B03D2; Fri, 15 Sep 2023 14:39:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id B72BC6B03D0 for ; Fri, 15 Sep 2023 14:39:47 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 8E13980762 for ; Fri, 15 Sep 2023 18:39:47 +0000 (UTC) X-FDA: 81239695614.26.8B04829 Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by imf28.hostedemail.com (Postfix) with ESMTP id C0A88C0015 for ; Fri, 15 Sep 2023 18:39:45 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=sPBj7+lP; spf=pass (imf28.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.152 as permitted sender) smtp.mailfrom=me@pankajraghav.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694803186; 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=LywLEuPyM84LvnszU9bu3yYyFXSjfbQxmSaZo0Anuqo=; b=bwVAsO6HLLpVgoEWE4vdhhm5U+b7+7BNVuyEqK+BFcl6KG5F6PlpBO+jqpGNRN+8Fu25Vg zpFvBQfVS75zZDkl0gqNqszJWDB+eBhcwRMkZlqA1v8LuTjJRvPn1YeYCeqlPDInc5zmnV S85DEV32mcrD7Pmm5b1noFZKe7AWGEI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694803186; a=rsa-sha256; cv=none; b=cKV7Vu7e1xPVx88F+XXNQqxz4CtTZrIfkXGl+9xauoMGy6Q58ZFlm3siVC3GWygBeQzf/p CldJ0fAqi1KzRVX6LngjLcA9hmabG4siXOtHVu8xRP6o8kL/6wbXDWX3amUOWqyZ/+c8k0 pnVTlzd1kBuYvyUwmHUSITNhLXmcB8Y= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=sPBj7+lP; spf=pass (imf28.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.152 as permitted sender) smtp.mailfrom=me@pankajraghav.com; dmarc=none Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (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 4RnNJt60W1z9sTy; Fri, 15 Sep 2023 20:39:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803182; 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=LywLEuPyM84LvnszU9bu3yYyFXSjfbQxmSaZo0Anuqo=; b=sPBj7+lPJjN1O52TPN3bPIvCgfHWewlpa4lD2gPArpjJc42qjZjYB0ivxNzVoPtgWUV2X9 baXqoaVEy427TKtHRyh9CuvB1dGk4UoKPWdumhCVK/Zj7hjnyV/9B5lvcIJez7O/RYML7a 7BbpTXkSIEysivDSIn8uG2RYC8Ka8TO0B9P19XqbBg8Pj8JfaNqqdtPoeNMsD2lb4sD0eY cFRHPxdkrbiSJb37sUgM291kELuaAdt9gvlmR97ZVvHYeejas3FF4Zlhd05N2OYrwNWsrp 2xibhXY+ahHHlr/15+T/ltQEQlsnkfS5en8VhTucFA1GfYp0wjO7bbHAmSHM9Q== 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 18/23] readahead: align ra start and size to mapping_min_order in ondemand_ra() Date: Fri, 15 Sep 2023 20:38:43 +0200 Message-Id: <20230915183848.1018717-19-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: C0A88C0015 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: z5k13rjrps4ebbar54rzn1okpowj7hdf X-HE-Tag: 1694803185-510320 X-HE-Meta: U2FsdGVkX19yKALya4Ii925+8FSPtKP5tqpMoeeb/OBeU700wwyJVp6zcs6M+F8tl2yfscscDyS21h7cUjx15JpgwSM6CeYGx1AqRsBcTOcr+Ke6ZjjlGzREVEQacerLdHcfcBSx8A9uDWQqRluVe1/1uY4Ys+SBewJ5CUuBeoFXZ2hfN8KVUgI4dXV8HzTWhiaeZbhQUXuqzmmCVEFu9ijgDACHOWXyc3BtJiNwdR3xhV7YNcwKRdLNcDZc9VbuZwmqkgU1Rr4dD3sgSQgQ+IajL1xqPDj96B4KXigbp5ervkmyY1/1H1anyNxkZQPZabGuIlHAfFrUrXgYDLbIB4zo4noKbN+iLnkh1JEF7/yX2f2mXN0FhrfVfvQlOo/yvSLSQ0Hyy7jti4NmbiSPbl69O7hUEZiLvQqOQwaJHNi6OLOsL21nHIjFUzLBYRp/kk3DAecX3FKSfNa1NIbk7966A8SuR5Sfcg4rBC7O2aiWMQuxA+Mmty96ayt/kUC0OtKj601anhmgbAWKNmNBAQ9+inMgFv2qhOgX/AswhfxRFmp/3C4A8vD1uplAWWkpAMoXbqnoXZm55Q/MsfgOybMSM2TeQh70ccVedjooiENPcKqsYU07fcHcxZlTwuGDF5YR1uBnFmx+koG53eKpQTCJsnpYeC56fD8MJMYRHlaGcy+MA66c2ME952Gkxe5VhGRyGSzVMNvD6MJRZaC7Wjkm1WTbyT91SO1jZIqpVnewFxEXDXvZTUajzJbBppsyiQ/LvbH+OGVgkHJmlBKcKhhA3cyv+Kbh/tG8tBkRV/ZSAZ1w/0rNR35gH4bLsSZjmgyHzhsrRzM2Eg6TG03mth8cUvQTf7sPlWSe0aeSZqrtODA4OPAsYUoDnsIJbUPbLQGHTFEMKURhdpXULF2em6E9Jw6O4AGP52hdHOGGQ0y+MZsSu8XIo1+Dai6DHCCHdVp6ICpJUACZ0qvHjMU 54iKw1ze 5KfOWUOVptNBTKsCdcnP+iBeMuBqGoNiOgAf7SsiW0IrgFEsOOkxP/I88GJcFw68Dlv8Ldp7q6fkRaFZGe6jZ21u11u6OCUvjycKzAw199MaQoklK5s92h8s8hviAX8ORQuZa+lD1ipYElu8ZiscyuHQhbwhUx3+7fyQEPZAg4mv76ucSeSAShf3TyrLewD7DDFcclGIYPumeFwE2hjcEznJJkx5fDDmxnEjPmyfPafAExjpcM/iIwQy6f1bTjHyDpupf0V+PA/KAU/QGU6iE6+A/d6ORW4REavS/zu6lKsFCuE/meuIj8DlFppKqxRBaM/Y705Ka50BoZ7ZGZSCw9s9uh0V53zv67MOp+jr67/4fc93O0G+bWll8RnzCVcFuDecAL0iJ/0Z25u3BX0ogTkE1awl1uylgtK/Z 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: Luis Chamberlain Align the ra->start and ra->size to mapping_min_order in ondemand_readahead(). This will ensure the folios added to the page_cache will be aligned to mapping_min_order number of pages. Signed-off-by: Luis Chamberlain --- mm/readahead.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index 7c2660815a01..03fa6f6c8145 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -605,7 +605,11 @@ static void ondemand_readahead(struct readahead_control *ractl, unsigned long add_pages; pgoff_t index = readahead_index(ractl); pgoff_t expected, prev_index; - unsigned int order = folio ? folio_order(folio) : 0; + unsigned int min_order = mapping_min_folio_order(ractl->mapping); + unsigned int min_nrpages = 1UL << min_order; + unsigned int order = folio ? folio_order(folio) : min_order; + + VM_BUG_ON(ractl->_index & (min_nrpages - 1)); /* * If the request exceeds the readahead window, allow the read to @@ -627,9 +631,13 @@ static void ondemand_readahead(struct readahead_control *ractl, expected = round_up(ra->start + ra->size - ra->async_size, 1UL << order); if (index == expected || index == (ra->start + ra->size)) { - ra->start += ra->size; - ra->size = get_next_ra_size(ra, max_pages); + ra->start += round_down(ra->size, min_nrpages); + ra->size = get_next_ra_size(ra, min_order, max_pages); ra->async_size = ra->size; + + VM_BUG_ON(ra->size & ((1UL << min_order) - 1)); + VM_BUG_ON(ra->start & ((1UL << min_order) - 1)); + goto readit; } @@ -647,13 +655,19 @@ static void ondemand_readahead(struct readahead_control *ractl, max_pages); rcu_read_unlock(); + start = round_down(start, min_nrpages); + + VM_BUG_ON(start & (min_nrpages - 1)); + VM_BUG_ON(folio->index & (folio_nr_pages(folio) - 1)); + if (!start || start - index > max_pages) return; ra->start = start; ra->size = start - index; /* old async_size */ - ra->size += req_size; - ra->size = get_next_ra_size(ra, max_pages); + VM_BUG_ON(ra->size & (min_nrpages - 1)); + ra->size += round_up(req_size, min_nrpages); + ra->size = get_next_ra_size(ra, min_order, max_pages); ra->async_size = ra->size; goto readit; } @@ -690,7 +704,7 @@ static void ondemand_readahead(struct readahead_control *ractl, initial_readahead: ra->start = index; - ra->size = get_init_ra_size(req_size, max_pages); + ra->size = get_init_ra_size(req_size, min_order, max_pages); ra->async_size = ra->size > req_size ? ra->size - req_size : ra->size; readit: @@ -701,7 +715,7 @@ static void ondemand_readahead(struct readahead_control *ractl, * Take care of maximum IO pages as above. */ if (index == ra->start && ra->size == ra->async_size) { - add_pages = get_next_ra_size(ra, max_pages); + add_pages = get_next_ra_size(ra, min_order, max_pages); if (ra->size + add_pages <= max_pages) { ra->async_size = add_pages; ra->size += add_pages; @@ -712,6 +726,7 @@ static void ondemand_readahead(struct readahead_control *ractl, } ractl->_index = ra->start; + VM_BUG_ON(ractl->_index & (min_nrpages - 1)); page_cache_ra_order(ractl, ra, order); } From patchwork Fri Sep 15 18:38:44 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: 13387480 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 83F10EED61A for ; Fri, 15 Sep 2023 18:39:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B24D06B03D2; Fri, 15 Sep 2023 14:39:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AAF4C6B03D5; Fri, 15 Sep 2023 14:39:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8FF5B6B03D6; Fri, 15 Sep 2023 14:39:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 763056B03D2 for ; Fri, 15 Sep 2023 14:39:50 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 58C331CA0E0 for ; Fri, 15 Sep 2023 18:39:50 +0000 (UTC) X-FDA: 81239695740.27.6692D85 Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [80.241.56.151]) by imf18.hostedemail.com (Postfix) with ESMTP id 889DD1C0008 for ; Fri, 15 Sep 2023 18:39:48 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b="eI+gl/BN"; dmarc=none; spf=pass (imf18.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.151 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=1694803188; 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=rV9SUN768+vUSf43/qCLKk3hEIsfVKLWNcCU7V4zUtQ=; b=eOcEOJvCyrTKSXs6V6jzh9bMA4XHqtx2iAPEjGKnj5qZgv7KQUNBDCY9Df/pmftw2dhG0g W7PP46+Z7iuEijhILcNw8muHF0juPVx8KHEvRJW5ZhrwWDKEe0dy+tWnW9SgAca5GGRWmJ 76TM2nGnxDnrQ2A3EIi+ksIl+41ymJs= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b="eI+gl/BN"; dmarc=none; spf=pass (imf18.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.151 as permitted sender) smtp.mailfrom=me@pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694803188; a=rsa-sha256; cv=none; b=ViP4Mynlus4QGs1AoeFA1pyOpq/Q9ZRTbO0Sk1APk83P4B/Ru9Ta77bj3kJick1o6Zv5ng T7Tuiq30T6VIPNn44ISC1DW5+n5Wdb3CvTht/YlyqjJ6iJsb4jexqvR/EMSsRhFIAiPr+N HqvEPWywyY5aNJbBB+vwrQRps4TxHi0= Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (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-101.mailbox.org (Postfix) with ESMTPS id 4RnNJx3l54z9sTN; Fri, 15 Sep 2023 20:39:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803185; 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=rV9SUN768+vUSf43/qCLKk3hEIsfVKLWNcCU7V4zUtQ=; b=eI+gl/BNfS9Dhty41um4KR+wRrFDQO+mDTbD65wgK9zPsLejVpU804xRIAjk7oY4J+Azil IVzX5dngUXpyfVClHiUUCaBnCc+02/4pud5dgOX6JQnyg72eUcxNj6QU8Sc/dnYHpcWObe paf2iuxl+EBFXfzLebEiH8GmUnBXq2RbfhMZtDylytHzq6bcq/Gpwf9XOVdf78jI04ETB+ xT7AyyaXTYUNMDkeQe91i2XK/OSfmotxpNcOTnfyY/W3bQz1zAy50mXsvOq+rw1ZgADZ8w TPwbbIX4YN/46fNwwcoiCqVkUIJwiBKy2eunAvqT3IHljCII7Tbs1TqQdCUCGg== 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 19/23] truncate: align index to mapping_min_order Date: Fri, 15 Sep 2023 20:38:44 +0200 Message-Id: <20230915183848.1018717-20-kernel@pankajraghav.com> In-Reply-To: <20230915183848.1018717-1-kernel@pankajraghav.com> References: <20230915183848.1018717-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 889DD1C0008 X-Stat-Signature: 87xxbw33ncrdn5hcd4sau6wq5k1kprqx X-HE-Tag: 1694803188-638456 X-HE-Meta: U2FsdGVkX18crDJ72HNErUJmKssWSoM3b4L2ZvYg/kzZmkF/t4dY1BHfD0/99/JfrVh9sIHat4cY2xTKV6w7beeiN+U4W31Vm1yZn/eRFY10ANs0cPVPfiNqK4hzbQ3BJ4Dw2zlOVRTGZgBq310SfP0ZSHfRIShWD2SG7tfm7vDrxXMkE7MGXfwjzstXUUUGjP0Z9QQPpwsQHNdyaf7maq7SZp37a+/O/JagTEe4Bl2C7any3GhPI3bqxwYTbVtz7XMnFDsrDFWlxLI1LS4SrhjiyVbCrBizY8h/DNEeT1sqYg/wY4I9qJiUeRYtdtW+payEALnogBHORVyH3raWimduy8tXdV2IbtA6uEaG5UKAUjEKPRc+CDPDaIb36YmF2QxntR5y9M9WvaGWL/odVKyg87idywFAfC6Lo1nph08VGE1b00YxO4rAFk8cZTw/tBFCy/cbWiLA2sqd2EazX/Nny/XZbR43nTgqjGewsonQ1AJHirsxQqGpe7datzPqFXNy9yU4800skOLSkaGBB+j2W7UKWQNDTfMwJSMFGubZEj4NoXPfoUcR6MOGBLmvOiHh6zjGQENBtfAnXu4oGZyW9DUPziMkHWNw/2P3scpdDfevVyNJA1eNi4iKsWHbAaz1kqTM3zY/nz9EmPktYUzLKytBFyrxcWry8iJt1eiSjt1qh6p9JzHSXWOG3D6lDwU7Io3QPhFK6CQaMNbxo/eAj13d02i+XL/1I+all3tOwhDWu2iJPytcSnoQQjhxGr7WSY0IojLylKas5R7IWoDY6yzS4QnBMSxenII3M4rd2G+QRv/jIBhDWe7Ks6fgu+syChmyHiIYMx9CWS4YMS/DsNOht3P9+jFpIO+fzaOkOF0lQJ/WRAnU5MtY28/gJpX5ehdlCcKcxcunuzTp0qjSjyxMEk//1jT47iDkTNE/JNg1PWpF0MslL7bl/50QOPoqatblB9g6/Kq9VAs QEE3+MZp d+FAmKh75qO204Uc60u0NzcjyUXMEQhJ8Ymm08UVrbHEPN6uu4mPMMMd1fG30/QgtcD3udhMuAN4QxzpY+EWjzQr56aks4oQyGsZoNMaihT0PJrYtGDi5K0r0X4MaWNfa9YjqMWL1mA7R+jj8J+UQfcW8jxdFG/HsAr8GqL02l+8FssQB0EYQNFMR9rjkvKq8WKq0q7GO2UuzfzsZeKqNQkWrrfUsTmQpQv2x+a3mDOiIbBihR1VYfaeoWqsK3hrRV709ZV+CdJZ6HpzPE0PGxHX1uN3oc8esXAmwpsXqaGNy0AEtq+2iwNXsQC9Yd94yg5Yc7ThMn816KG9VCT/PjuUNaV8wvX217KIB7xLo6slKl2ZEZCjVnG0vhxSIj3OHMiSSmh1WenTj28X+O2WA66bZ0Jn3paPXJI/7ScmEEF2wLTRhKTdqEB6+tOwTbRxwOe7n 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: Luis Chamberlain Align indices to mapping_min_order in invalidate_inode_pages2_range(), mapping_try_invalidate() and truncate_inode_pages_range(). This is necessary to keep the folios added to the page cache aligned with mapping_min_order. Signed-off-by: Luis Chamberlain Signed-off-by: Pankaj Raghav --- mm/truncate.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/mm/truncate.c b/mm/truncate.c index 8e3aa9e8618e..d5ce8e30df70 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -337,6 +337,8 @@ void truncate_inode_pages_range(struct address_space *mapping, int i; struct folio *folio; bool same_folio; + unsigned int order = mapping_min_folio_order(mapping); + unsigned int nrpages = 1U << order; if (mapping_empty(mapping)) return; @@ -347,7 +349,9 @@ void truncate_inode_pages_range(struct address_space *mapping, * start of the range and 'partial_end' at the end of the range. * Note that 'end' is exclusive while 'lend' is inclusive. */ - start = (lstart + PAGE_SIZE - 1) >> PAGE_SHIFT; + start = (lstart + (nrpages * PAGE_SIZE) - 1) >> PAGE_SHIFT; + start = round_down(start, nrpages); + if (lend == -1) /* * lend == -1 indicates end-of-file so we have to set 'end' @@ -356,7 +360,7 @@ void truncate_inode_pages_range(struct address_space *mapping, */ end = -1; else - end = (lend + 1) >> PAGE_SHIFT; + end = round_down((lend + 1) >> PAGE_SHIFT, nrpages); folio_batch_init(&fbatch); index = start; @@ -372,8 +376,9 @@ void truncate_inode_pages_range(struct address_space *mapping, cond_resched(); } - same_folio = (lstart >> PAGE_SHIFT) == (lend >> PAGE_SHIFT); - folio = __filemap_get_folio(mapping, lstart >> PAGE_SHIFT, FGP_LOCK, 0); + same_folio = round_down(lstart >> PAGE_SHIFT, nrpages) == + round_down(lend >> PAGE_SHIFT, nrpages); + folio = __filemap_get_folio(mapping, start, FGP_LOCK, 0); if (!IS_ERR(folio)) { same_folio = lend < folio_pos(folio) + folio_size(folio); if (!truncate_inode_partial_folio(folio, lstart, lend)) { @@ -387,7 +392,8 @@ void truncate_inode_pages_range(struct address_space *mapping, } if (!same_folio) { - folio = __filemap_get_folio(mapping, lend >> PAGE_SHIFT, + folio = __filemap_get_folio(mapping, + round_down(lend >> PAGE_SHIFT, nrpages), FGP_LOCK, 0); if (!IS_ERR(folio)) { if (!truncate_inode_partial_folio(folio, lstart, lend)) @@ -497,15 +503,18 @@ EXPORT_SYMBOL(truncate_inode_pages_final); unsigned long mapping_try_invalidate(struct address_space *mapping, pgoff_t start, pgoff_t end, unsigned long *nr_failed) { + unsigned int min_order = mapping_min_folio_order(mapping); + unsigned int nrpages = 1UL << min_order; pgoff_t indices[PAGEVEC_SIZE]; struct folio_batch fbatch; - pgoff_t index = start; + pgoff_t index = round_up(start, nrpages); + pgoff_t end_idx = round_down(end, nrpages); unsigned long ret; unsigned long count = 0; int i; folio_batch_init(&fbatch); - while (find_lock_entries(mapping, &index, end, &fbatch, indices)) { + while (find_lock_entries(mapping, &index, end_idx, &fbatch, indices)) { for (i = 0; i < folio_batch_count(&fbatch); i++) { struct folio *folio = fbatch.folios[i]; @@ -618,9 +627,11 @@ static int folio_launder(struct address_space *mapping, struct folio *folio) int invalidate_inode_pages2_range(struct address_space *mapping, pgoff_t start, pgoff_t end) { + unsigned int min_order = mapping_min_folio_order(mapping); + unsigned int nrpages = 1UL << min_order; pgoff_t indices[PAGEVEC_SIZE]; struct folio_batch fbatch; - pgoff_t index; + pgoff_t index, end_idx; int i; int ret = 0; int ret2 = 0; @@ -630,8 +641,9 @@ int invalidate_inode_pages2_range(struct address_space *mapping, return 0; folio_batch_init(&fbatch); - index = start; - while (find_get_entries(mapping, &index, end, &fbatch, indices)) { + index = round_up(start, nrpages); + end_idx = round_down(end, nrpages); + while (find_get_entries(mapping, &index, end_idx, &fbatch, indices)) { for (i = 0; i < folio_batch_count(&fbatch); i++) { struct folio *folio = fbatch.folios[i]; @@ -660,6 +672,8 @@ int invalidate_inode_pages2_range(struct address_space *mapping, continue; } VM_BUG_ON_FOLIO(!folio_contains(folio, indices[i]), folio); + VM_BUG_ON_FOLIO(folio_order(folio) < min_order, folio); + VM_BUG_ON_FOLIO(folio->index & (nrpages - 1), folio); folio_wait_writeback(folio); if (folio_mapped(folio)) From patchwork Fri Sep 15 18:38:45 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: 13387481 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 5B63BEED61F for ; Fri, 15 Sep 2023 18:40:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D0886B03D5; Fri, 15 Sep 2023 14:39:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9030B6B03D7; Fri, 15 Sep 2023 14:39:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 779146B03D8; Fri, 15 Sep 2023 14:39:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 5C2556B03D5 for ; Fri, 15 Sep 2023 14:39:53 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2A0ABC07E4 for ; Fri, 15 Sep 2023 18:39:53 +0000 (UTC) X-FDA: 81239695866.25.9B4F52F Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by imf09.hostedemail.com (Postfix) with ESMTP id 6FB6F140014 for ; Fri, 15 Sep 2023 18:39:51 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=h0SxLgQv; dmarc=none; spf=pass (imf09.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.171 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=1694803191; 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=ZopmvSWX8ME3+zE0xLlLj6n28P2bDkBcY8o03Qh+UqI=; b=cCajq+i7XK8m5ucd9mzMxiWQA7eib6xwrrESNhfW8ZFxaShSH+MBUBgHt/Vb6Z8bsqKcDy buR0oNcHovyDrocmdTxcz0QPk5QxpyUzjNVXFg98JAOBHO6VHBsWCWrF5IJSQe94KE1ay+ IEpi22ZiVoUZAp0ZwDEqfV58Be00AkI= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=h0SxLgQv; dmarc=none; spf=pass (imf09.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.171 as permitted sender) smtp.mailfrom=me@pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694803191; a=rsa-sha256; cv=none; b=iEvW+YBSBoqNHV5QIbqqHJtudSKLzC3O8e+XNYW080msFamRVRZwNYhnHmgGSHe9KbeK9J RHf/f2uPfb8PhSNOzfEhs8M5im8PPqSCAyxgbq/W8wQuQTu1VMlq8EtqXmDCq9t5R8weTj I/abRSYE1qjRzyadGJXltJGinDIEqcs= Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (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-201.mailbox.org (Postfix) with ESMTPS id 4RnNK03XV2z9svg; Fri, 15 Sep 2023 20:39:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803188; 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=ZopmvSWX8ME3+zE0xLlLj6n28P2bDkBcY8o03Qh+UqI=; b=h0SxLgQv6vJA6JwNxNVopMuk8gFh3dpnTipX3yD3gI900/92roHKFWISKT5EJI3wjM9Naf H6yZ4HQEjxk5IdQCF6prjkl7lI5pXvtu9GxWSpa+Du9TtKgF+FqptplkTRnG+dhPZwnA8m Btc1TNZQOt5CE/68d1sxPOoODwEE9dFTEUkkoPr37EiTQ50/jRoHUZmNBHz1JHwYkE+OZE BPHSoI9PwJXlfPk9ZynUha6TZTNjWfrH4kJTDhHqX2Ktx+PHv9KPF8iwnD9wdArlP0aZmh jshWljg/ktY+MJi3EV7SfFTaY2P7wzKqkE3C2+QdFUD16Ip7mIXMcOKu/Exo3Q== 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 20/23] mm: round down folio split requirements Date: Fri, 15 Sep 2023 20:38:45 +0200 Message-Id: <20230915183848.1018717-21-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-Server: rspam09 X-Rspamd-Queue-Id: 6FB6F140014 X-Stat-Signature: 8ezxs6kyr7mfp3xuxpdjjmp8ouwpwhgb X-Rspam-User: X-HE-Tag: 1694803191-31503 X-HE-Meta: U2FsdGVkX19X5KbDSAEpJ+dg+lUlqAwOaKnRdBitM9nVogeHmdgeOY3850h7gIEE18oniwEl0xoE+bggbA7Ga836CpItYH8rH6SaM2ot+Z8HR/VJff7UZvzhwPv9hwPahRyR6IMi2E9vwpxKpe1lq0iIgNvOo5OW4bCDSvlUllWa6AUdQd04s6AxIPbZuAlr+SLjwmfYNCSJgSkSzRNK/T+Ukv77pDOVsZ9+AeRltUk64gb9u8Wn6JnXnmOCs4eqIOVnvxxkCQv6f7lXI1TYPRxi3POgXvdnWJcHFgLhE835RcqLUQtLgKTICfVgeO7eDqYy0h/ysyqv9kmgzpVTv4FKBzLUd5ezkAfuGkd+u1KeOqh56SRHqIvUgriHPcSXmFkaps0dVCuLpJhR9vPUB94fnXKz+MAxZtJJcbNXy1JY2cjtJmD1N4y2QICKJ9BP5r38nKGpomDSHkpyQ6PYlrYKtS3BC8cu7gTBTjrJnizZs6kml9AMH90MljnJryI76bEX0CpM8iStbkmMglD5reL6d0nTRlaW7NnI9Ph+8MropXBZskYGi7FIVr26wz3/tSQ0l+gwzpl3dcrj32d99U99uVjomuIyXm+KtuteN5K5QxVKXxSj7bvUAKCeJ2YGxlejuHLj7CA3ydOuVon7Ore88ZmTr7vdSVh/1Zfo1Cghwv80M8P31DxQuIoUlwLYGlj77qkAAHx5rCPU1dQwhjIDQAjAF/FYTbIDqEd9I6KjUfNAQE4rXwUUofMIuPckCdKcDa5gtXkP/Ipmx8nr+K+UYapt3l4zt+itHZAu7izc44Z0wN/K20U5EkS960APXb95r3HE02YGIZmCMGpmyMXlm5ceTgnKeWq5nsn/BNrCyaSYAfA5AH4JRSTeZXO5/GKPFww6iwqGEu4UOytM+70KBF+SYOiudpX2z+cDpKBwy0byv7fSDsfPcwzDl9NSYiwRNJoLbqkMtg6HKYH 68hixr8F ddMe+MSkRYxCqk/syd0UPGQTPENSQHElbWMgqCBWCqHc3rju09zUHNNbUfYANDNjvIhVbboz5cr1ZuShU5C8KcOv9foNh+DmZ7k9oEA6apI7p4dc0ehhc6ipkOYMpy3Hk1Ycmy/HparOTM/R4Reu7+4c7+cIoamIk+bLpl3U4SqVnLNah0I+NQK8VpIdHPIke7yyxwv/Xw+qUU2tmsivPRmMfLYTbHO0MVA66cxE/4bmXBulNiz/bbW7LoLtBfSJVPBTIKFwOojXZd4s9gC91lMRE1P9BfWyMEa2AMx/XqEDAMiOhqEjW9Psc/tQRz7MZQzHXmsmV5xNmiag4+1Xt0/1+wCbjvHx8PZAwVwgabcOjDQhVJJdwmkcjTw== 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: Luis Chamberlain When we truncate we always check if we can split a large folio, we do this by checking the userspace mapped pages match folio_nr_pages() - 1, but if we are using a filesystem or a block device which has a min order it must be respected and we should only split rounding down to the min order page requirements. Signed-off-by: Luis Chamberlain --- mm/huge_memory.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index f899b3500419..e608a805c79f 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2617,16 +2617,24 @@ static void __split_huge_page(struct page *page, struct list_head *list, bool can_split_folio(struct folio *folio, int *pextra_pins) { int extra_pins; + unsigned int min_order = 0; + unsigned int nrpages; /* Additional pins from page cache */ - if (folio_test_anon(folio)) + if (folio_test_anon(folio)) { extra_pins = folio_test_swapcache(folio) ? folio_nr_pages(folio) : 0; - else + } else { extra_pins = folio_nr_pages(folio); + if (folio->mapping) + min_order = mapping_min_folio_order(folio->mapping); + } + + nrpages = 1UL << min_order; + if (pextra_pins) *pextra_pins = extra_pins; - return folio_mapcount(folio) == folio_ref_count(folio) - extra_pins - 1; + return folio_mapcount(folio) == folio_ref_count(folio) - extra_pins - nrpages; } /* From patchwork Fri Sep 15 18:38:46 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: 13387482 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 358C4EED61E for ; Fri, 15 Sep 2023 18:40:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6B9D36B03D7; Fri, 15 Sep 2023 14:39:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 644276B03D9; Fri, 15 Sep 2023 14:39:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 46C796B03DA; Fri, 15 Sep 2023 14:39:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 292486B03D7 for ; Fri, 15 Sep 2023 14:39:56 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id EDB04140773 for ; Fri, 15 Sep 2023 18:39:55 +0000 (UTC) X-FDA: 81239695950.28.CCF048E Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by imf11.hostedemail.com (Postfix) with ESMTP id EB49840012 for ; Fri, 15 Sep 2023 18:39:53 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=mYMhQTCP; dmarc=none; spf=pass (imf11.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=1694803194; 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=yBandIomLcSEx0nPSvrcvRyAh/l4Pv1QDX49YB+LVO8=; b=vat8eZTDTODTLS5Navt9f04zrUUW7peoW67nyUnQd5dsp91lrB304cLpPSX52wZaJFz3Dp NHNO2+3GHMeAa8eQaZfR928FxVBPuhZJ/y1yst2VRBJp4F9UaVap/e2icxdrDB+fZyG4W3 K2hKOKthzO4z438KId89kVrR7t8D8F0= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=mYMhQTCP; dmarc=none; spf=pass (imf11.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=1694803194; a=rsa-sha256; cv=none; b=epAffl4YoqVcRItS3ok6X+z1JyYuZyVj0YvNSreTKCS6C5Zumbj6MDMr20Kvm4Z3aQN9ra /kL0MTBmDLc8LuRtWMKce1ItBRdUMO/IgCe8myD+5w9+Ust3MelmvttC1jFktLiX6u0m8j oAbk0AEprW/wFGEsK248viNJloMvkqQ= Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (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 4RnNK30KtMz9scy; Fri, 15 Sep 2023 20:39:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803191; 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=yBandIomLcSEx0nPSvrcvRyAh/l4Pv1QDX49YB+LVO8=; b=mYMhQTCPSuTWWpI2a7DZoXA2b4Z2aKNhpG6QuCtm6/2AiRPlUnh5ztr81m0prSgYeB5R2N Ubm+xxqIg8F/FN+j3+bmMvc3lFgXMlwoMTJVlrwlxDrqWuSm2qLZyxjNlwSHqn/pZs5Wqv 4Ex7wSgqjRITqAxHX5nWM2terZrh1tp/A7U7RddsO8AguL/6WxFiG+uPzAnJusn8ziCa9d SQjJDxzA7meuf23dlFCDvgDHn4S9+cb3doEld4C/rY7esq1tecmimNp0kyvrO1IowB0WOO pbte7nFfRvCr28HTfjEYrVOMsJlaYLN0vE+DazB0umhH//atGpqlgDbXCGO0mg== 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, Dave Chinner Subject: [RFC 21/23] xfs: expose block size in stat Date: Fri, 15 Sep 2023 20:38:46 +0200 Message-Id: <20230915183848.1018717-22-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: EB49840012 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: tndz9swpqwanp7d815ut61orcz8a3n84 X-HE-Tag: 1694803193-961418 X-HE-Meta: U2FsdGVkX1+CTfkNFascncd83cME8B4FtSKQNW5Mv785UeqlO00bu3Q+oWxTCmuJ0PZOIEmttEggJg1HODU56A7p+pFmgzyWDAAEiQW2rGm5RzqLy1Nynta/ehHe1ReXMMlG1X2ZdRasqTbReMLVnF8vDgWjkAMvDxOPtwLq71xW/X4P3E9xoMO8GtekGTQaDUYwbFYJDnMHh8x7EZK2uhMfPrQosAiVZiWvhMmpGKWgfI4PD7J+tlmNi836ZAgV5Ce7HXtSeF2fntIyJCvJobkulUr2QMKZiz1SVPzzY4p/AqU3Ny0krsfM0uX3M0Y6RPfRPZgaWTgSI1zfMIat9GquHpGNPahB0FOttg/k06AgPyF6KPp2zRVw7rZ7qx4EJ8NkkTTkquO6lWNqk34WW0RjXi4UxwfK4vO0n4haeWnSdwG8HZSZtQxDtYBU4kdR4cfbEcWPuMFNOcpY0SyrV+kGQqGJTkw2RYyb46V075/rjZ2Q1RUCZhg9jdvJqapBU0RDFt2Yoqf2FXez3zQ1MTynTUfak83EDhI6mYKzplOCfOwcYUOsttl8oMZdKnqp3G0zHraBzr1cc9Sgt39J8G1BLQygsmP2u1gskYDxlADYyn33sAAUlNdbP4QryMxIdQaeW9i+c3LtbgWAIqiQ6AjEEZ5hdM3GY8VuBKe5SlI/y0LB0ynHGO7H/6BUX/t/Hk12a4W95QuFjjW48+6mNlH5g1j4ZhBJqowLBpoXbJD91/URR4kAWlXWhHqZA/UhhjOQ1MPLIMZhvBtGGr507J6Ss18f4C0O1duHE7MW4pz6TBI3fMJrdfVo+RoV2i2QB7n6BEQSbRfx30JM6jxiVJJ820irrAYC+86jV507DpnuYt8dY8U6vmOwcPs/HtpSHOuqYFrMcimIhskqddYsf9oqNd9Y261Z5ei821IUXCfTzccWhH1lYO+d0SXbYKVMwaNDP4KpM0aHlgvYgeh TTeAzvXd SA1j2ZKnF09FTlCQuYCYdRqCmwVyOnuBRjUxQ7VFyUYKCAbMMqv2kgiEOMOI+7lXhE/QMH4LFfz3l/6HGF+gisvUHylRQdZNuDd/aDCcXFvXZskcENrzt2U0Q3kRlLUIMwXQpchqSj4eGFnhNICHPnNvlE+LhAmFxXcxWWYvsiJ1+GPPt1ZleEp6I9XViFsJ6IVczhzh4dkxNxPawFOMFSfMl3el9xPidn57UWE4X3SR8S8IHgYNiw8zYs5ITXF5bElNmylfAyJRkMTGufF6QJoQCbYLPJVi3wm/A/h+XjVDO5xvL22UV7Q8glS0rcYtJbktL6p4LavPbrKS+xJ1r0mTzrMtUp4IloeZVZFP462/BNkMwB3l2aXJZEA== 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: Dave Chinner For block size larger than page size, the unit of efficient IO is the block size, not the page size. Leaving stat() to report PAGE_SIZE as the block size causes test programs like fsx to issue illegal ranges for operations that require block size alignment (e.g. fallocate() insert range). Hence update the preferred IO size to reflect the block size in this case. Signed-off-by: Dave Chinner [mcgrof: forward rebase in consideration for commit dd2d535e3fb29d ("xfs: cleanup calculating the stat optimal I/O size")] Signed-off-by: Luis Chamberlain --- fs/xfs/xfs_iops.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 2ededd3f6b8c..080a79a81c46 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -515,6 +515,8 @@ xfs_stat_blksize( struct xfs_inode *ip) { struct xfs_mount *mp = ip->i_mount; + unsigned long default_size = max_t(unsigned long, PAGE_SIZE, + mp->m_sb.sb_blocksize); /* * If the file blocks are being allocated from a realtime volume, then @@ -543,7 +545,7 @@ xfs_stat_blksize( return 1U << mp->m_allocsize_log; } - return PAGE_SIZE; + return default_size; } STATIC int From patchwork Fri Sep 15 18:38:47 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: 13387483 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 D291EEED61E for ; Fri, 15 Sep 2023 18:40:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8DB916B03D9; Fri, 15 Sep 2023 14:39:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 862FE6B03DB; Fri, 15 Sep 2023 14:39:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6BA386B03DC; Fri, 15 Sep 2023 14:39:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 496CA6B03D9 for ; Fri, 15 Sep 2023 14:39:59 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 15C9C40697 for ; Fri, 15 Sep 2023 18:39:59 +0000 (UTC) X-FDA: 81239696118.22.C14CF0C Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by imf30.hostedemail.com (Postfix) with ESMTP id 624D280024 for ; Fri, 15 Sep 2023 18:39:57 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=nbK0ltBU; spf=pass (imf30.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.171 as permitted sender) smtp.mailfrom=me@pankajraghav.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694803197; 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=VZYs+58deJjiPO8x76TVvnJ/svOQYbXd85JbMK60DK4=; b=tqMf1mJlEe9MVyoJLKo38X+2zgDs/c1Y5vo2KpvfAztSXgKNDxxPNjlhOoCInK/4SeoMMY deefPamdzeiEl8x5FhP1+H3yI7JRNQTvoiXq5gN7K6vFzXvjmjbmDnsTls2BNhE7Sk/Fhc h+NIgfIuFWbEoSjAlW4GEHsZ8ajrSM0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694803197; a=rsa-sha256; cv=none; b=5pC+tEvYhocBi7GaTCxtIA3XhzFL2zx0XatS4KC8ICkPHWWigiyCn8EihiONSKgOXBLHgx k3p2A4l/xmERpILX2Gn+u4gENBcb3i0e13Ayg2uxo6rtIj7FrY1u+ic85/mm+p7tkUXd+z lgSN1rLxD127weXIlS6MqZlni62tvgc= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=nbK0ltBU; spf=pass (imf30.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.171 as permitted sender) smtp.mailfrom=me@pankajraghav.com; dmarc=none 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 ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4RnNK60pC9z9sW2; Fri, 15 Sep 2023 20:39:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803194; 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=VZYs+58deJjiPO8x76TVvnJ/svOQYbXd85JbMK60DK4=; b=nbK0ltBUmQsL56D0EhZ4txGadxEvVy4TubQU3sjKYn6rLPyAwbUdURHJ8b7n3zRdtyN/4Z ypn7d+WKBepAkrMqlYrcpEnjSMQaoXkHFqFzoi6xAKmqYIcE4d5nhd2NJIIkCltxDGFZqX aPiRGdlaOPgV/tMGFjiJ/rnPBUDvjHKssw/KzOPJoi2RRiMVQtr/SMPLsZ5ZmivBbieE89 tSpFP1+7JVhzls4KDO9r0MQkSh811k3tpn2w1NcQ02D8BjCZtKlrXgjf8qjYLwmyE0yjlD nMlVsGHg5BAV06syTuM4YAtZ4/po/zbqrO9EN8APt8gc76aXRTMNwttPDzWfeQ== 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 22/23] xfs: enable block size larger than page size support Date: Fri, 15 Sep 2023 20:38:47 +0200 Message-Id: <20230915183848.1018717-23-kernel@pankajraghav.com> In-Reply-To: <20230915183848.1018717-1-kernel@pankajraghav.com> References: <20230915183848.1018717-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Stat-Signature: d35swwz1pzw34goorz3iotjnotzzq1rz X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 624D280024 X-Rspam-User: X-HE-Tag: 1694803197-120833 X-HE-Meta: U2FsdGVkX19LJVcbhUJZo0f6Gw0N+gR1Fba++tufnu/9U6if0ATL5vuZ37RuAoGfR9z7SOkxBLSxhvC8EE+8B2tCTxkkaZvVI2+aGC8Mxw38Z0WebCAsn41MkMuULsmRH1hxz0MTHqa6H8yrnZQ5rADkaoEhMYpH6rpEjiY+2uC03q2CRDKwKp/qKD3KNp3XA0BxzJZSVGAFDdET3HG600mI/bQXTyAfEmz3ys69brWaGeiGoXJEPxOkt2uYYTx3AtyfQMr4I69mO+RuGh6aEQjhACs6Px0q4ylwZPBddDaeXAvpeTI9b8Tgwo9RfzCA+HuXWlQUDQw5LmJyJCHCz4hvK527WxlWcuUlxapndwcQEDESAocMcaxbr6BbwP77MOLK1odYhskWc52g2qnxOf19VryyPMSq/xoBbquzo//oJiQxiJyfMkF4Z9EDVhxzzLgkWvnfnXXl0zIlSWrKnfhqKinqQ/ZqQZeRh7ZrHa7DT9paYj6HX88JosLxHGm8xOVopZriQOvB+twyA0ZdeMoob1Nqj+YEiCq9XBYRESEyIXYQuv3ftpP7s4u0sNXPVxq6rlVRnI2gBwneFVKtQze3oC07E6vNBJwik0Wxg9yh0IlUJ2965SJHJHiMUUGa4TYgNRK20KUaH3sr/D3uwJetcsM5nyUDeThkDRyjcaFOr1WAXpZfRx5skjayRIbR9+KRuFhP+ldSMUBZo3mbqdOSdP2z2VQ3kh50DXAmV/RRl+QExpc5CXmFQ9S9r5Ybko2GWkz+/dk0wan4Pau3smlS74a80JCstYMKtBNTKS2K1+lImHmAyhFnZRKw458uh7QTSdYkaSqAeA2we+u2gEwNAwLV+mfiSWAAm81EiaBV9CvPE13HCRRfI+zSUYVJBFywK4+ibgOUzedhpc+RF1QXYsW9H1m8lYK0YrXIemGEg803SnA5fKOUG0ekkVKAAQrpPW6J6WsqZK7AmbI Ki6rsjjd 4qALHmxjg0bVGuE4spV02L9uVUZWb7DudY9WZeDclCqaOrF3ZkWHf5sf6EYXInq8Kg+P6J8MdcmTbEZ7CPul1BG+A+RtLpppM+pm/+OoqB85AJqqpZEvw7hzbs7WuVQcL8IfUoNNSOPcvbtDXbkv4nrhva5vi6P2PJCwZcn2KcsE7ic9ZGBsfcRddSJk/ldRc0qcXcqJoAlg8uSuX0CYQbc75ZX+m3epABpsKiBplAasS89HREQJgfQdDrvcFEFP1YN3DyzmoSErfEIzi3JUpjudj/gMD47MdR9gmroL8y4TC72Y1rZn9lvvlTaGJ9zkjgQQRlLx2z5ob8gWbQ6tFFh8OMsJfetjl3DvsEfoWArXEfOXdxtc1UwxMzKm67r0b/LjZveydoNjzl+HBSBJ5xfCGUN+ZmbqgoDZgn8ighfEEDHMkUIH77dRaHUXBmYpfU0CRAbvUToECLZg= 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 Currently we don't support blocksize that is twice the page size due to the limitation of having at least three pages in a large folio[1]. [1] https://lore.kernel.org/all/ZH0GvxAdw1RO2Shr@casper.infradead.org/ Signed-off-by: Luis Chamberlain Signed-off-by: Pankaj Raghav --- fs/xfs/xfs_mount.c | 9 +++++++-- fs/xfs/xfs_super.c | 7 ++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index aed5be5508fe..4272898c508a 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -131,11 +131,16 @@ xfs_sb_validate_fsb_count( xfs_sb_t *sbp, uint64_t nblocks) { - ASSERT(PAGE_SHIFT >= sbp->sb_blocklog); ASSERT(sbp->sb_blocklog >= BBSHIFT); + unsigned long mapping_count; + + if (sbp->sb_blocklog <= PAGE_SHIFT) + mapping_count = nblocks >> (PAGE_SHIFT - sbp->sb_blocklog); + else + mapping_count = nblocks << (sbp->sb_blocklog - PAGE_SHIFT); /* Limited by ULONG_MAX of page cache index */ - if (nblocks >> (PAGE_SHIFT - sbp->sb_blocklog) > ULONG_MAX) + if (mapping_count > ULONG_MAX) return -EFBIG; return 0; } diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 1f77014c6e1a..75bf4d23051c 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1651,13 +1651,10 @@ xfs_fs_fill_super( goto out_free_sb; } - /* - * Until this is fixed only page-sized or smaller data blocks work. - */ - if (mp->m_sb.sb_blocksize > PAGE_SIZE) { + if (mp->m_sb.sb_blocksize == (2 * PAGE_SIZE)) { xfs_warn(mp, "File system with blocksize %d bytes. " - "Only pagesize (%ld) or less will currently work.", + "Blocksize that is twice the pagesize %ld does not currently work.", mp->m_sb.sb_blocksize, PAGE_SIZE); error = -ENOSYS; goto out_free_sb; From patchwork Fri Sep 15 18:38:48 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: 13387484 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 3958DEED61A for ; Fri, 15 Sep 2023 18:40:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C5E226B03DB; Fri, 15 Sep 2023 14:40:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BE5846B03DD; Fri, 15 Sep 2023 14:40:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C5EC6B03DE; Fri, 15 Sep 2023 14:40:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 806B66B03DB for ; Fri, 15 Sep 2023 14:40:01 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 57E67C0769 for ; Fri, 15 Sep 2023 18:40:01 +0000 (UTC) X-FDA: 81239696202.28.6A1DB81 Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by imf18.hostedemail.com (Postfix) with ESMTP id A95A01C001C for ; Fri, 15 Sep 2023 18:39:59 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=YWBaYLR8; dmarc=none; spf=pass (imf18.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.172 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=1694803199; 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=rdyOm0E20W1O08Haq+wboPt6O9fnOeXgM7VNGHdT/wc=; b=r9YcsJOQqHSwrumzHIgFPEQPGIvtrDKiDOGGQHT8low2NTNTFipv2bdYPNSh6rIKIfxcC6 W5PEihTuzq1osg9ZdMYjw2s7185Ug5QH5tIdqo8FECt2OJzuFQV2HwfuNMZiaBtKq0+bY+ BU3lnxCXuFwW2ZDgcZ+EvnXh3SanUac= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=YWBaYLR8; dmarc=none; spf=pass (imf18.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.172 as permitted sender) smtp.mailfrom=me@pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694803199; a=rsa-sha256; cv=none; b=S8AxqTAz8ypF9bp+C64tj8DUXLNY2HsRm14MLIb7YKH0VGsPHNDwmMAkkeQlIhBhHW+Pxi 7JhtsqdrGkQoChl07xQk8KR+k/XPTB+8taA9D4j7LiUbJgTZdL7hL6DPGRoTe6urZ4hoab pLN1VEncNIxljbDHIFqjXFWzT4S1T2Y= Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (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-202.mailbox.org (Postfix) with ESMTPS id 4RnNK84kWKz9sWQ; Fri, 15 Sep 2023 20:39:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803196; 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=rdyOm0E20W1O08Haq+wboPt6O9fnOeXgM7VNGHdT/wc=; b=YWBaYLR8wP7FiydPN5L35PApcVVJVdWdr9JQ0wve5greLck+YNw4kh4nrPZG0I3Irb8ki0 iuokOs97BSQFNTgm6YhdORbefrutGfT1KELpkS/3XMgdCJ9oOH4CtnvKt/LPo0PALntzFv p3aHYP5rCYGypOCX8eQG6C8LNjayrhZbhVYUtmATnzcj1I2hW2uQpwW6y/BQVis0Zw0/VG 5DwtrDMNHLI60IzV77LR+S96bZ65EDdStUam1CBD+ng7P3QZexi7+Gw76NWeAcNZn30u4d ZF4HNoSpiJ8j4mP9R3KSBmGwbUH3gqxJZAlgZODdsgOKSUDIhWjurPKl2hsTaw== 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 23/23] xfs: set minimum order folio for page cache based on blocksize Date: Fri, 15 Sep 2023 20:38:48 +0200 Message-Id: <20230915183848.1018717-24-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-Server: rspam09 X-Rspamd-Queue-Id: A95A01C001C X-Stat-Signature: fiqdzep94shju1ckmnsw9w3wi75pdtu3 X-Rspam-User: X-HE-Tag: 1694803199-209438 X-HE-Meta: U2FsdGVkX1/ncE0CDfOyPoqvcJimVYyiwi4EfCC/V0is+92My/ZnASsGsapMRQgnbcciyFq1EEAhrOj2Yx7PwAreI8EdTH/Y0QPdnxKnEx4UeCSqcI7iifLNfGNfCrNHp4Nug0Y+eWcvS240vM0OXBJ4GFxsZVS+UFdxaGqnQd1LYkZ4+62wmtaybdna2fp5aFwpoXQGj67MgOPHsEx4ciXljn+uo5DUzLqWtz0MqgW51uu5WeeB0JNCwKZiPSSZxA3Za85mPlx+g3IQ/RJo6g8/8o3XIbGT/aAw6MIidbZ8ujSZGHwOwR+cb+ud72PSqp0fD3ex/qJHQnv0zjzoOTRqtWWzDYAL7xLVAhAW3VR5lKWOPLWOHPR2UP+VDI3Azh+1eW4purkNSYFyQytSrtyiUN7VM7n+xi5XHR3Cb2Ov+lnUOG5WvJU+K+zfPVbiHIXMR6vl3D62oQIHOT0Ca6HXb4inGIueEk113fHXkLAs5XHqEyy4iirPKOy4gjaaYN50yxhyLBR/7rCm7fEF0wsDwbeLseQQvmkA8eaeDc70JVhp5IJ8XTkll6RNVoxP4HrrAjfNNKOuOQEaSYPh2goQyEcU/O6J4AcFQ5x8ijqxNt4t8NhXhQswO5KLJKq/6iZk+nMHrfpnt2S9PAjnZanMXvd1fH7zO9yYm3OfFuY6VdozZDEzRy2jtjyN3kiY0toG6zl3f+PgMm66tFn4gq9l0UNEGggiTGtX9ISVY3Pm6Wrs3cxowPcTpVN8w8HPW9bK0S5rCGQUddvERqIzeYiDR8ylmJYrsXjeVVo6qZOVE8Xc+VOIwUe7ybS1lbtsZpvHIF7QgsbrcEFV3jALsLnIOjxeQ9C0HDIISD92Ym9pbWPVGwmIu9XvIBIXxDdJc8WZNvJijq4uXW1v7M6jUR/wqKiStlhrzyfYt2DI3JqOtYWRfUH4q9c3S22q9J8N7Njro7hy5VB815wmB50 fTQs+uYt DZjAdy90CSGU8D4u0ekDt9vjf1XBtSzSlA58UUhvFs8Bl2Wdj3gB+Em5QaNsUs58f7oiBBMp+QUnPEKIaLpkcH0ibZbopmzEGKP8+c4DFw2fzzATKj+warnCkB5qvMzvJ4DxGBipk+uhMY6RBek3GkuH8hO1kogf8C/WczXn9FvRI2kBrFLfaooTv3rQjW20Uhz9eJcpHNGgJgbWvSexu57IJWBASBa3Il6s4E7aWg/YLbIpq50bzYIMjqT8sr+3XgPp7GrJhUEuEnQH8Bm2nJJXwaY7u8CslfGF825D+Q889s1dYsR6Uhad+bVl2TJGzqRvdOmVWy2kGNcaswXbcmRBmNfvAi/T+BlIbQ/ODqcwiULhmoXFxuJipzQ== 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 Enabling a block size > PAGE_SIZE is only possible if we can ensure that the filesystem allocations for the block size is treated atomically and we do this with the min order folio requirement for the inode. This allows the page cache to treat this inode atomically even if on the block layer we may treat it separately. For instance, on x86 this enables eventual usage of block size > 4k so long as you use a sector size set of 4k. Signed-off-by: Pankaj Raghav Signed-off-by: Luis Chamberlain --- fs/xfs/xfs_icache.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c index aacc7eec2497..81f07503f5ca 100644 --- a/fs/xfs/xfs_icache.c +++ b/fs/xfs/xfs_icache.c @@ -73,6 +73,7 @@ xfs_inode_alloc( xfs_ino_t ino) { struct xfs_inode *ip; + int min_order = 0; /* * XXX: If this didn't occur in transactions, we could drop GFP_NOFAIL @@ -88,7 +89,8 @@ xfs_inode_alloc( /* VFS doesn't initialise i_mode or i_state! */ VFS_I(ip)->i_mode = 0; VFS_I(ip)->i_state = 0; - mapping_set_large_folios(VFS_I(ip)->i_mapping); + min_order = max(min_order, ilog2(mp->m_sb.sb_blocksize) - PAGE_SHIFT); + mapping_set_folio_orders(VFS_I(ip)->i_mapping, min_order, MAX_PAGECACHE_ORDER); XFS_STATS_INC(mp, vn_active); ASSERT(atomic_read(&ip->i_pincount) == 0); @@ -313,6 +315,7 @@ xfs_reinit_inode( dev_t dev = inode->i_rdev; kuid_t uid = inode->i_uid; kgid_t gid = inode->i_gid; + int min_order = 0; error = inode_init_always(mp->m_super, inode); @@ -323,7 +326,8 @@ xfs_reinit_inode( inode->i_rdev = dev; inode->i_uid = uid; inode->i_gid = gid; - mapping_set_large_folios(inode->i_mapping); + min_order = max(min_order, ilog2(mp->m_sb.sb_blocksize) - PAGE_SHIFT); + mapping_set_folio_orders(inode->i_mapping, min_order, MAX_PAGECACHE_ORDER); return error; }