Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F5EA47143E for ; Thu, 23 Jul 2026 14:31:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784817067; cv=none; b=nhhp5Xk3JxKupXxcfYf58FoIwYuZuwW/T6rhXQcf/RqTfXcXxZ8vxceiExNy+PRQOq8Od9e3YacZ/UZNNyzrp+KBqkMMrKYuB/HlHdGQsPWmbD1jZgxiPjA0gTs84ii1evW6vVIuArd8i2HdyqNIj3lASp6nYOqPpqZlBf4s6FQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784817067; c=relaxed/simple; bh=mKzkYaffbQsxfoOf+ZHYmzkIfLTg6uyJQOjQwN60sSo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ngn5vW6DtFFD0/VRTrEmaHtCMzMENKhBY6DPrKoRg12bX+Dqfbhy6DeXurmc4M9ueqpAxFfHBDTZ4ezhh8EFJ1cw4Uz8YhjJ8l6noSlBkXx/g4QQmgDWLKY2G8yXIKi+GDeQJGPNkWtq4dAyEr4VWxW5HY/HPPShGopDzKXcWAU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=pass smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=Ry6u6IeF; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Ry6u6IeF" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=H+0pTh0RBBzp29dclQVhPImRa45jGpqQ8sF2JtQbo/4=; b=Ry6u6IeFS2Y46r4OEm2zrFMEG0 x5KmKX8KHBRzr086fM7HpbrI2pJtmQAgZHu5zsVB4LQHKwgWxUaXe7yCUBufnbOgYMA2MwIAYhLr0 edfNBymxBvN7G6MBSQ5zd4toOnJVtyt6K5jGHFCsHDRAzJ9uXOuGfAzugb3q/glE7RwUyg9TPeEmi /cKFvrrw1KtcKr6t+aTzwXk21n7159wMvyYO07Li3AjGK2Tvy5plEE1eYvjrFgdYPj8wJFrlwDvYp Vh//wUkBLPWGONawRazFJ7cCDHhk2y/nQp8ThqaamW1kPm3wL6/f6zRxUxlSYO5jIsrF3Fm896eDj 4KjBfymA==; Received: from willy by casper.infradead.org with local (Exim 4.99.1 #2 (Red Hat Linux)) id 1wmuRZ-00000000ji9-2Qmb; Thu, 23 Jul 2026 14:30:37 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton , Jane Chu , linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Muchun Song , Oscar Salvador , David Hildenbrand , Miaohe Lin , Naoya Horiguchi , Jan Kara , linux-fsdevel@vger.kernel.org, Christian Brauner , Jiaqi Yan Subject: [PATCH v4 11/14] filemap: Remove checks in mapping_set_folio_order_range() Date: Thu, 23 Jul 2026 15:30:28 +0100 Message-ID: <20260723143034.175661-12-willy@infradead.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260723143034.175661-1-willy@infradead.org> References: <20260723143034.175661-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit These checks make it impossible to use mapping_set_folio_order_range() in hugetlb. They add very little value and can simply be removed. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/pagemap.h | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 2c3718d592d6..436987f47aed 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -373,7 +373,7 @@ static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask) * 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 +#ifdef CONFIG_FILEMAP_LARGE_FOLIO #define PREFERRED_MAX_PAGECACHE_ORDER HPAGE_PMD_ORDER #else #define PREFERRED_MAX_PAGECACHE_ORDER 8 @@ -394,7 +394,7 @@ static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask) */ static inline size_t mapping_max_folio_size_supported(void) { - if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) + if (IS_ENABLED(CONFIG_FILEMAP_LARGE_FOLIO)) return 1U << (PAGE_SHIFT + MAX_PAGECACHE_ORDER); return PAGE_SIZE; } @@ -405,29 +405,23 @@ static inline size_t mapping_max_folio_size_supported(void) * @min: Minimum folio order (between 0-MAX_PAGECACHE_ORDER inclusive). * @max: Maximum folio order (between @min-MAX_PAGECACHE_ORDER inclusive). * - * The filesystem should call this function in its inode constructor to - * indicate which base size (min) and maximum size (max) 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). + * The filesystem should call this function in its inode constructor + * to indicate which size folios can be used to cache the contents of + * the inode. 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. * + * hugetlb calls this with orders larger than MAX_PAGECACHE_ORDER. + * Normal filesystems should not do this. + * * Context: This should not be called while the inode is active as it * is non-atomic. */ static inline void mapping_set_folio_order_range(struct address_space *mapping, - unsigned int min, - unsigned int max) + unsigned int min, unsigned int max) { - if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) + if (!IS_ENABLED(CONFIG_FILEMAP_LARGE_FOLIO)) return; - - if (min > MAX_PAGECACHE_ORDER) - min = MAX_PAGECACHE_ORDER; - - if (max > MAX_PAGECACHE_ORDER) - max = MAX_PAGECACHE_ORDER; - if (max < min) max = min; @@ -460,7 +454,7 @@ static inline void mapping_set_large_folios(struct address_space *mapping) static inline unsigned int mapping_max_folio_order(const struct address_space *mapping) { - if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) + if (!IS_ENABLED(CONFIG_FILEMAP_LARGE_FOLIO)) return 0; return (mapping->flags & AS_FOLIO_ORDER_MAX_MASK) >> AS_FOLIO_ORDER_MAX; } @@ -468,7 +462,7 @@ mapping_max_folio_order(const struct address_space *mapping) static inline unsigned int mapping_min_folio_order(const struct address_space *mapping) { - if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) + if (!IS_ENABLED(CONFIG_FILEMAP_LARGE_FOLIO)) return 0; return (mapping->flags & AS_FOLIO_ORDER_MIN_MASK) >> AS_FOLIO_ORDER_MIN; } @@ -524,7 +518,7 @@ static inline bool mapping_large_folio_support(const struct address_space *mappi * * Return: True if PMD-sized folios are supported, otherwise false. */ -#ifdef CONFIG_TRANSPARENT_HUGEPAGE +#ifdef CONFIG_FILEMAP_LARGE_FOLIO static inline bool mapping_pmd_folio_support(const struct address_space *mapping) { /* AS_FOLIO_ORDER is only reasonable for pagecache folios */ -- 2.47.3