From: Kefeng Wang <wangkefeng.wang@huawei.com>
To: Zi Yan <ziy@nvidia.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@redhat.com>,
Oscar Salvador <osalvador@suse.de>,
Muchun Song <muchun.song@linux.dev>, <linux-mm@kvack.org>,
<sidhartha.kumar@oracle.com>, <jane.chu@oracle.com>,
Vlastimil Babka <vbabka@suse.cz>,
Brendan Jackman <jackmanb@google.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Matthew Wilcox <willy@infradead.org>,
David Hildenbrand <david@kernel.org>
Subject: Re: [PATCH v4 6/6] mm: hugetlb: allocate frozen pages in alloc_gigantic_folio()
Date: Wed, 17 Dec 2025 16:09:24 +0800 [thread overview]
Message-ID: <de2e93ca-830a-4bc0-841a-1ed70ab1a61f@huawei.com> (raw)
In-Reply-To: <EA31F2A7-D0BF-4A49-8F05-C2E7B73A3556@nvidia.com>
On 2025/12/17 2:44, Zi Yan wrote:
> On 16 Dec 2025, at 6:48, Kefeng Wang wrote:
>
>> The alloc_gigantic_folio() allocates a folio with refcount increated
>> and then freeze it, convert to allocate a frozen folio to remove the
>> atomic operation about folio refcount, and saving atomic operation
>> during __update_and_free_hugetlb_folio() too.
>>
>> Besides, rename hugetlb_cma_{alloc,free}_folio() with frozen which
>> make them more self-explanatory.
>>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
>> ---
>> mm/hugetlb.c | 63 +++++++++++-------------------------------------
>> mm/hugetlb_cma.c | 9 +++----
>> mm/hugetlb_cma.h | 10 ++++----
>> 3 files changed, 22 insertions(+), 60 deletions(-)
>>
>> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
>> index ed185bbca419..7779ec838da0 100644
>> --- a/mm/hugetlb.c
>> +++ b/mm/hugetlb.c
>> @@ -121,16 +121,6 @@ static void hugetlb_unshare_pmds(struct vm_area_struct *vma,
>> unsigned long start, unsigned long end, bool take_locks);
>> static struct resv_map *vma_resv_map(struct vm_area_struct *vma);
>>
>> -static void hugetlb_free_folio(struct folio *folio)
>> -{
>> - if (folio_test_hugetlb_cma(folio)) {
>> - hugetlb_cma_free_folio(folio);
>> - return;
>> - }
>> -
>> - folio_put(folio);
>> -}
>> -
>> static inline bool subpool_is_free(struct hugepage_subpool *spool)
>> {
>> if (spool->count)
>> @@ -1417,51 +1407,24 @@ static struct folio *dequeue_hugetlb_folio_vma(struct hstate *h,
>> return NULL;
>> }
>>
>> -#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE
>> -#ifdef CONFIG_CONTIG_ALLOC
>> +#if defined(CONFIG_ARCH_HAS_GIGANTIC_PAGE) && defined(CONFIG_CONTIG_ALLOC)
>> static struct folio *alloc_gigantic_folio(int order, gfp_t gfp_mask,
>> int nid, nodemask_t *nodemask)
>> {
>> struct folio *folio;
>> - bool retried = false;
>>
>> -retry:
>> - folio = hugetlb_cma_alloc_folio(order, gfp_mask, nid, nodemask);
>> - if (!folio) {
>> - struct page *page;
>> -
>> - if (hugetlb_cma_exclusive_alloc())
>> - return NULL;
>> -
>> - page = alloc_contig_frozen_pages(1 << order, gfp_mask, nid, nodemask);
>> - if (!page)
>> - return NULL;
>> -
>> - set_page_refcounted(page);
>> - folio = page_folio(page);
>> - }
>> -
>> - if (folio_ref_freeze(folio, 1))
>> + folio = hugetlb_cma_alloc_frozen_folio(order, gfp_mask, nid, nodemask);
>> + if (folio)
>> return folio;
>
> alloc_gigantic_folio() actually returns a frozen folio. Should it be renamed
> to alloc_frozen_gigantic_folio()?
I don't change it as alloc_buddy_hugetlb_folio is not with frozen, we
could change both of them if you prefer with frozen :)
>
>
> Best Regards,
> Yan, Zi
>
next prev parent reply other threads:[~2025-12-17 8:09 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-16 11:48 [PATCH v4 RESEND 0/6] mm: hugetlb: allocate frozen gigantic folio Kefeng Wang
2025-12-16 11:48 ` [PATCH v4 1/6] mm: debug_vm_pgtable: add debug_vm_pgtable_free_huge_page() Kefeng Wang
2025-12-16 16:08 ` Zi Yan
2025-12-17 2:40 ` Muchun Song
2025-12-16 11:48 ` [PATCH v4 2/6] mm: page_alloc: add __split_page() Kefeng Wang
2025-12-16 16:21 ` Zi Yan
2025-12-17 7:01 ` Kefeng Wang
2025-12-17 2:45 ` Muchun Song
2025-12-16 11:48 ` [PATCH v4 3/6] mm: cma: add __cma_release() Kefeng Wang
2025-12-16 16:39 ` Zi Yan
2025-12-17 2:46 ` Muchun Song
2025-12-16 11:48 ` [PATCH v4 4/6] mm: page_alloc: add alloc_contig_frozen_{range,pages}() Kefeng Wang
2025-12-16 17:20 ` Zi Yan
2025-12-17 7:17 ` Kefeng Wang
2025-12-17 19:20 ` Zi Yan
2025-12-18 12:00 ` Kefeng Wang
2025-12-16 11:48 ` [PATCH v4 5/6] mm: cma: add cma_alloc_frozen{_compound}() Kefeng Wang
2025-12-16 18:40 ` Zi Yan
2025-12-17 8:02 ` Kefeng Wang
2025-12-17 19:38 ` Zi Yan
2025-12-18 12:54 ` Kefeng Wang
2025-12-18 15:52 ` Zi Yan
2025-12-19 4:09 ` Kefeng Wang
2025-12-22 2:30 ` Zi Yan
2025-12-22 13:03 ` Kefeng Wang
2025-12-20 14:34 ` kernel test robot
2025-12-22 1:46 ` Kefeng Wang
2025-12-16 11:48 ` [PATCH v4 6/6] mm: hugetlb: allocate frozen pages in alloc_gigantic_folio() Kefeng Wang
2025-12-16 18:44 ` Zi Yan
2025-12-17 8:09 ` Kefeng Wang [this message]
2025-12-17 19:40 ` Zi Yan
2025-12-18 12:56 ` Kefeng Wang
-- strict thread matches above, loose matches on Subject: below --
2025-10-23 11:59 [PATCH v4 0/6] mm: hugetlb: allocate frozen gigantic folio Kefeng Wang
2025-10-23 11:59 ` [PATCH v4 6/6] mm: hugetlb: allocate frozen pages in alloc_gigantic_folio() Kefeng Wang
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=de2e93ca-830a-4bc0-841a-1ed70ab1a61f@huawei.com \
--to=wangkefeng.wang@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=david@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=jackmanb@google.com \
--cc=jane.chu@oracle.com \
--cc=linux-mm@kvack.org \
--cc=muchun.song@linux.dev \
--cc=osalvador@suse.de \
--cc=sidhartha.kumar@oracle.com \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
--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