From: Pankaj Raghav <p.raghav@samsung.com>
To: Suren Baghdasaryan <surenb@google.com>,
Mike Rapoport <rppt@kernel.org>,
David Hildenbrand <david@redhat.com>,
Ryan Roberts <ryan.roberts@arm.com>,
Michal Hocko <mhocko@suse.com>, Lance Yang <lance.yang@linux.dev>,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Dev Jain <dev.jain@arm.com>, Barry Song <baohua@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Nico Pache <npache@redhat.com>, Zi Yan <ziy@nvidia.com>,
Vlastimil Babka <vbabka@suse.cz>,
"Liam R . Howlett" <Liam.Howlett@oracle.com>,
Jens Axboe <axboe@kernel.dk>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org,
mcgrof@kernel.org, gost.dev@samsung.com, kernel@pankajraghav.com,
tytso@mit.edu, Pankaj Raghav <p.raghav@samsung.com>
Subject: [RFC v2 2/3] huge_memory: skip warning if min order and folio order are same in split
Date: Sat, 6 Dec 2025 04:08:57 +0100 [thread overview]
Message-ID: <20251206030858.1418814-3-p.raghav@samsung.com> (raw)
In-Reply-To: <20251206030858.1418814-1-p.raghav@samsung.com>
When THP is disabled, file-backed large folios max order is capped to the
min order to avoid using the splitting infrastructure.
Currently, splitting calls will create a warning when called with THP
disabled. But splitting call does not have to do anything when min order
is same as the folio order.
So skip the warning in folio split functions if the min order is same as
the folio order for file backed folios.
Due to issues with circular dependency, move the definition of split
function for !CONFIG_TRANSPARENT_HUGEPAGES to mm/memory.c
Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
---
include/linux/huge_mm.h | 40 ++++++++--------------------------------
mm/memory.c | 41 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+), 32 deletions(-)
diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
index 21162493a0a0..71e309f2d26a 100644
--- a/include/linux/huge_mm.h
+++ b/include/linux/huge_mm.h
@@ -612,42 +612,18 @@ can_split_folio(struct folio *folio, int caller_pins, int *pextra_pins)
{
return false;
}
-static inline int
-split_huge_page_to_list_to_order(struct page *page, struct list_head *list,
- unsigned int new_order)
-{
- VM_WARN_ON_ONCE_PAGE(1, page);
- return -EINVAL;
-}
-static inline int split_huge_page_to_order(struct page *page, unsigned int new_order)
-{
- VM_WARN_ON_ONCE_PAGE(1, page);
- return -EINVAL;
-}
+int split_huge_page_to_list_to_order(struct page *page, struct list_head *list,
+ unsigned int new_order);
+int split_huge_page_to_order(struct page *page, unsigned int new_order);
static inline int split_huge_page(struct page *page)
{
- VM_WARN_ON_ONCE_PAGE(1, page);
- return -EINVAL;
-}
-
-static inline unsigned int min_order_for_split(struct folio *folio)
-{
- VM_WARN_ON_ONCE_FOLIO(1, folio);
- return 0;
-}
-
-static inline int split_folio_to_list(struct folio *folio, struct list_head *list)
-{
- VM_WARN_ON_ONCE_FOLIO(1, folio);
- return -EINVAL;
+ return split_huge_page_to_list_to_order(page, NULL, 0);
}
-static inline int try_folio_split_to_order(struct folio *folio,
- struct page *page, unsigned int new_order)
-{
- VM_WARN_ON_ONCE_FOLIO(1, folio);
- return -EINVAL;
-}
+unsigned int min_order_for_split(struct folio *folio);
+int split_folio_to_list(struct folio *folio, struct list_head *list);
+int try_folio_split_to_order(struct folio *folio,
+ struct page *page, unsigned int new_order);
static inline void deferred_split_folio(struct folio *folio, bool partially_mapped) {}
static inline void reparent_deferred_split_queue(struct mem_cgroup *memcg) {}
diff --git a/mm/memory.c b/mm/memory.c
index 6675e87eb7dd..4eccdf72a46e 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -4020,6 +4020,47 @@ static bool __wp_can_reuse_large_anon_folio(struct folio *folio,
{
BUILD_BUG();
}
+
+int split_huge_page_to_list_to_order(struct page *page, struct list_head *list,
+ unsigned int new_order)
+{
+ struct folio *folio = page_folio(page);
+ unsigned int order = mapping_min_folio_order(folio->mapping);
+
+ if (!folio_test_anon(folio) && order == folio_order(folio))
+ return -EINVAL;
+
+ VM_WARN_ON_ONCE_PAGE(1, page);
+ return -EINVAL;
+}
+
+int split_huge_page_to_order(struct page *page, unsigned int new_order)
+{
+ return split_huge_page_to_list_to_order(page, NULL, new_order);
+}
+
+int split_folio_to_list(struct folio *folio, struct list_head *list)
+{
+ unsigned int order = mapping_min_folio_order(folio->mapping);
+
+ if (!folio_test_anon(folio) && order == folio_order(folio))
+ return -EINVAL;
+
+ VM_WARN_ON_ONCE_FOLIO(1, folio);
+ return -EINVAL;
+}
+
+unsigned int min_order_for_split(struct folio *folio)
+{
+ return split_folio_to_list(folio, NULL);
+}
+
+
+int try_folio_split_to_order(struct folio *folio, struct page *page,
+ unsigned int new_order)
+{
+ return split_folio_to_list(folio, NULL);
+}
#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
static bool wp_can_reuse_anon_folio(struct folio *folio,
--
2.50.1
next prev parent reply other threads:[~2025-12-06 3:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-06 3:08 [RFC v2 0/3] Decoupling large folios dependency on THP Pankaj Raghav
2025-12-06 3:08 ` [RFC v2 1/3] filemap: set max order to be min order if THP is disabled Pankaj Raghav
2025-12-06 3:08 ` Pankaj Raghav [this message]
2025-12-06 3:08 ` [RFC v2 3/3] blkdev: remove CONFIG_TRANSPARENT_HUGEPAGES dependency for LBS devices Pankaj Raghav
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251206030858.1418814-3-p.raghav@samsung.com \
--to=p.raghav@samsung.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@redhat.com \
--cc=dev.jain@arm.com \
--cc=gost.dev@samsung.com \
--cc=kernel@pankajraghav.com \
--cc=lance.yang@linux.dev \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mcgrof@kernel.org \
--cc=mhocko@suse.com \
--cc=npache@redhat.com \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=surenb@google.com \
--cc=tytso@mit.edu \
--cc=vbabka@suse.cz \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox