From: Muchun Song <songmuchun@bytedance.com>
To: Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@kernel.org>,
Oscar Salvador <osalvador@suse.de>,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Jonathan Corbet <corbet@lwn.net>
Cc: Muchun Song <muchun.song@linux.dev>,
Lance Yang <lance.yang@linux.dev>,
Lorenzo Stoakes <ljs@kernel.org>,
"Liam R . Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
Christophe Leroy <chleroy@kernel.org>,
Ritesh Harjani <ritesh.list@gmail.com>,
Shrikanth Hegde <sshegde@linux.ibm.com>,
Shuah Khan <skhan@linuxfoundation.org>,
Randy Dunlap <rdunlap@infradead.org>,
Qi Zheng <qi.zheng@linux.dev>,
linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
Muchun Song <songmuchun@bytedance.com>
Subject: [PATCH 4/4] mm/hugetlb_vmemmap: remove hugetlb_vmemmap_optimize_bootmem_folios()
Date: Mon, 19 Oct 2026 17:08:30 +0800 [thread overview]
Message-ID: <20261019090830.1917657-5-songmuchun@bytedance.com> (raw)
In-Reply-To: <20261019090830.1917657-1-songmuchun@bytedance.com>
With vmemmap_wrprotect_hvo() removed, the bootmem wrapper no longer
performs any bootmem-specific work.
Call hugetlb_vmemmap_optimize_folios() directly for bootmem folios and
remove the redundant wrapper.
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
---
mm/hugetlb.c | 2 +-
mm/hugetlb_vmemmap.c | 29 ++++-------------------------
mm/hugetlb_vmemmap.h | 6 ------
3 files changed, 5 insertions(+), 32 deletions(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index b37d7d0db7fc..64a21b7e820f 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3297,7 +3297,7 @@ static void __init prep_and_add_bootmem_folios(struct hstate *h,
struct folio *folio, *tmp_f;
/* Send list for bulk vmemmap optimization processing */
- hugetlb_vmemmap_optimize_bootmem_folios(h, folio_list);
+ hugetlb_vmemmap_optimize_folios(h, folio_list);
list_for_each_entry_safe(folio, tmp_f, folio_list, lru) {
if (!folio_test_hugetlb_vmemmap_optimized(folio)) {
diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
index 3d72346c2ca2..236e1db9517b 100644
--- a/mm/hugetlb_vmemmap.c
+++ b/mm/hugetlb_vmemmap.c
@@ -588,19 +588,16 @@ static int hugetlb_vmemmap_split_folio(const struct hstate *h, struct folio *fol
return vmemmap_remap_split(vmemmap_start, vmemmap_end);
}
-static void __hugetlb_vmemmap_optimize_folios(struct hstate *h,
- struct list_head *folio_list,
- bool boot)
+void hugetlb_vmemmap_optimize_folios(struct hstate *h, struct list_head *folio_list)
{
struct folio *folio;
- int nr_to_optimize;
+ unsigned long nr_to_optimize = 0;
LIST_HEAD(vmemmap_pages);
unsigned long flags = VMEMMAP_REMAP_NO_TLB_FLUSH;
if (list_empty(folio_list))
return;
- nr_to_optimize = 0;
list_for_each_entry(folio, folio_list, lru) {
int ret;
@@ -608,7 +605,7 @@ static void __hugetlb_vmemmap_optimize_folios(struct hstate *h,
* Bootmem gigantic folios may already be marked optimized when
* their vmemmap layout was prepared earlier, so skip them here.
*/
- if (boot && folio_test_hugetlb_vmemmap_optimized(folio))
+ if (folio_test_hugetlb_vmemmap_optimized(folio))
continue;
nr_to_optimize++;
@@ -626,14 +623,7 @@ static void __hugetlb_vmemmap_optimize_folios(struct hstate *h,
}
if (!nr_to_optimize)
- /*
- * All pre-HVO folios, nothing left to do. It's ok if
- * there is a mix of pre-HVO and not yet HVO-ed folios
- * here, as __hugetlb_vmemmap_optimize_folio() will
- * skip any folios that already have the optimized flag
- * set, see vmemmap_should_optimize_folio().
- */
- goto out;
+ return;
flush_tlb_all();
@@ -658,21 +648,10 @@ static void __hugetlb_vmemmap_optimize_folios(struct hstate *h,
}
}
-out:
flush_tlb_all();
free_vmemmap_page_list(&vmemmap_pages);
}
-void hugetlb_vmemmap_optimize_folios(struct hstate *h, struct list_head *folio_list)
-{
- __hugetlb_vmemmap_optimize_folios(h, folio_list, false);
-}
-
-void hugetlb_vmemmap_optimize_bootmem_folios(struct hstate *h, struct list_head *folio_list)
-{
- __hugetlb_vmemmap_optimize_folios(h, folio_list, true);
-}
-
void __init hugetlb_vmemmap_optimize_bootmem_page(unsigned long pfn, unsigned int order)
{
if (!READ_ONCE(vmemmap_optimize_enabled))
diff --git a/mm/hugetlb_vmemmap.h b/mm/hugetlb_vmemmap.h
index 464192e32dec..d717d0d10960 100644
--- a/mm/hugetlb_vmemmap.h
+++ b/mm/hugetlb_vmemmap.h
@@ -24,7 +24,6 @@ long hugetlb_vmemmap_restore_folios(const struct hstate *h,
struct list_head *non_hvo_folios);
void hugetlb_vmemmap_optimize_folio(const struct hstate *h, struct folio *folio);
void hugetlb_vmemmap_optimize_folios(struct hstate *h, struct list_head *folio_list);
-void hugetlb_vmemmap_optimize_bootmem_folios(struct hstate *h, struct list_head *folio_list);
void hugetlb_vmemmap_optimize_bootmem_page(unsigned long pfn, unsigned int order);
static inline unsigned int hugetlb_vmemmap_size(const struct hstate *h)
@@ -66,11 +65,6 @@ static inline void hugetlb_vmemmap_optimize_folios(struct hstate *h, struct list
{
}
-static inline void hugetlb_vmemmap_optimize_bootmem_folios(struct hstate *h,
- struct list_head *folio_list)
-{
-}
-
static inline unsigned int hugetlb_vmemmap_optimizable_size(const struct hstate *h)
{
return 0;
--
2.54.0
next prev parent reply other threads:[~2026-10-19 9:09 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-19 9:08 [PATCH 0/4] mm: Enforce read-only shared vmemmap tail mappings Muchun Song
2026-10-19 9:08 ` [PATCH 1/4] mm/sparse-vmemmap: map shared vmemmap tail pages as read-only Muchun Song
2026-10-21 4:57 ` Lance Yang
2026-10-21 5:36 ` Muchun Song
2026-10-19 9:08 ` [PATCH 2/4] powerpc/mm: " Muchun Song
2026-10-21 5:40 ` Lance Yang
2026-10-30 0:26 ` Ritesh Harjani
2026-10-19 9:08 ` [PATCH 3/4] mm/hugetlb_vmemmap: remove vmemmap_wrprotect_hvo() Muchun Song
2026-10-21 6:07 ` Lance Yang
2026-10-19 9:08 ` Muchun Song [this message]
2026-10-21 6:18 ` [PATCH 4/4] mm/hugetlb_vmemmap: remove hugetlb_vmemmap_optimize_bootmem_folios() Lance Yang
2026-10-30 10:44 ` [PATCH 0/4] mm: Enforce read-only shared vmemmap tail mappings Pavithra
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=20261019090830.1917657-5-songmuchun@bytedance.com \
--to=songmuchun@bytedance.com \
--cc=akpm@linux-foundation.org \
--cc=chleroy@kernel.org \
--cc=corbet@lwn.net \
--cc=david@kernel.org \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=ljs@kernel.org \
--cc=maddy@linux.ibm.com \
--cc=mhocko@suse.com \
--cc=mpe@ellerman.id.au \
--cc=muchun.song@linux.dev \
--cc=npiggin@gmail.com \
--cc=osalvador@suse.de \
--cc=qi.zheng@linux.dev \
--cc=rdunlap@infradead.org \
--cc=ritesh.list@gmail.com \
--cc=rppt@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=sshegde@linux.ibm.com \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
/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