From: Lance Yang <lance.yang@linux.dev>
To: Muchun Song <muchun.song@linux.dev>
Cc: songmuchun@bytedance.com, osalvador@suse.de, rppt@kernel.org,
david@kernel.org, akpm@linux-foundation.org, qi.zheng@linux.dev,
linux-mm@kvack.org
Subject: Re: [PATCH 4/6] mm/hugetlb_vmemmap: open-code free_vmemmap_page()
Date: Tue, 1 Dec 2026 15:06:19 +0800 [thread overview]
Message-ID: <abb4c10f-1b7d-4d83-a521-8ba4c927409d@linux.dev> (raw)
In-Reply-To: <FBFB20BF-3687-4883-AC6A-29F7DF1B504E@linux.dev>
On 2026/12/1 14:14, Muchun Song wrote:
>
>
>> On Dec 1, 2026, at 12:35, Lance Yang <lance.yang@linux.dev> wrote:
>>
>>
>> On Tue, Nov 24, 2026 at 07:05:28PM +0800, Muchun Song wrote:
>>> free_vmemmap_page() has a single caller. Open-code it in
>>> free_vmemmap_page_list() and remove the helper.
>>>
>>> No functional change.
>>>
>>> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
>>> ---
>>> mm/hugetlb_vmemmap.c | 29 +++++++++--------------------
>>> 1 file changed, 9 insertions(+), 20 deletions(-)
>>>
>>> diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
>>> index 4ed2db189f59..7ede6b6fb4eb 100644
>>> --- a/mm/hugetlb_vmemmap.c
>>> +++ b/mm/hugetlb_vmemmap.c
>>> @@ -172,30 +172,19 @@ static int vmemmap_remap_range(unsigned long start, unsigned long end,
>>> return 0;
>>> }
>>>
>>> -/*
>>> - * Free a vmemmap page. A vmemmap page can be allocated from the memblock
>>> - * allocator or buddy allocator. If the PG_reserved flag is set, it means
>>> - * that it allocated from the memblock allocator, just free it via the
>>> - * free_reserved_page(). Otherwise, use __free_page().
>>> - */
>>> -static inline void free_vmemmap_page(struct page *page)
>>> -{
>>> - if (PageReserved(page)) {
>>> - memmap_boot_pages_add(-1);
>>> - free_reserved_page(page);
>>> - } else {
>>> - memmap_pages_add(-1);
>>> - __free_page(page);
>>> - }
>>> -}
>>> -
>>> -/* Free a list of the vmemmap pages */
>>> static void free_vmemmap_page_list(struct list_head *list)
>>> {
>>> struct page *page, *next;
>>>
>>> - list_for_each_entry_safe(page, next, list, lru)
>>> - free_vmemmap_page(page);
>>> + list_for_each_entry_safe(page, next, list, lru) {
>>> + if (PageReserved(page)) {
>>> + memmap_boot_pages_add(-1);
>>> + free_reserved_page(page);
>>
>> Might be worth keeping a short comment explaining that the reserved
>> vmemmap pages here came from muemblock. That's why we free them with
>> free_reserved_page() ;)
>
> I dropped the comment since it mostly restates what the code is already
> doing. Given that a reserved vmemmap page implicitly comes from a memblock
Ah, I see.
> allocation, the intent seemed clear enough from the code itself—happy
> to keep a brief note if you think it's still helpful for clarity, though.
Thanks, either way works for me. No strong feelings about it :D
next prev parent reply other threads:[~2026-12-01 7:06 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 11:05 [PATCH 0/6] mm: Simplify HugeTLB vmemmap optimization code Muchun Song
2026-11-24 11:05 ` [PATCH 1/6] mm/hugetlb_vmemmap: remove the vmemmap savings boot message Muchun Song
2026-11-24 11:16 ` sashiko-bot
2026-11-24 11:18 ` Muchun Song
2026-11-30 13:13 ` nobody
2026-11-30 13:15 ` Lance
2026-11-30 13:19 ` Lance Yang
2026-12-01 3:17 ` Muchun Song
2026-11-24 11:05 ` [PATCH 2/6] mm/hugetlb_vmemmap: fold vmemmap_should_optimize() into its callers Muchun Song
2026-12-01 2:51 ` Lance Yang
2026-12-01 3:11 ` Muchun Song
2026-11-24 11:05 ` [PATCH 3/6] mm/hugetlb_vmemmap: drop the redundant hstate argument Muchun Song
2026-12-01 4:25 ` Lance Yang
2026-11-24 11:05 ` [PATCH 4/6] mm/hugetlb_vmemmap: open-code free_vmemmap_page() Muchun Song
2026-12-01 4:35 ` Lance Yang
2026-12-01 6:14 ` Muchun Song
2026-12-01 7:06 ` Lance Yang [this message]
2026-11-24 11:05 ` [PATCH 5/6] mm/hugetlb_vmemmap: drop obsolete restore refcount warning Muchun Song
2026-12-01 4:57 ` Lance Yang
2026-12-01 6:28 ` Muchun Song
2026-11-24 11:05 ` [PATCH 6/6] mm/vmemmap-optimization: centralize the vmemmap optimization support check Muchun Song
2026-12-01 5:42 ` Lance Yang
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=abb4c10f-1b7d-4d83-a521-8ba4c927409d@linux.dev \
--to=lance.yang@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=linux-mm@kvack.org \
--cc=muchun.song@linux.dev \
--cc=osalvador@suse.de \
--cc=qi.zheng@linux.dev \
--cc=rppt@kernel.org \
--cc=songmuchun@bytedance.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