All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kefeng Wang <wangkefeng.wang@huawei.com>
To: David Hildenbrand <david@redhat.com>,
	<20250910133958.301467-1-wangkefeng.wang@huawei.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Oscar Salvador <osalvador@suse.de>,
	Muchun Song <muchun.song@linux.dev>, Zi Yan <ziy@nvidia.com>,
	Matthew Wilcox <willy@infradead.org>
Cc: <sidhartha.kumar@oracle.com>, <jane.chu@oracle.com>,
	Vlastimil Babka <vbabka@suse.cz>,
	Brendan Jackman <jackmanb@google.com>,
	Johannes Weiner <hannes@cmpxchg.org>, <linux-mm@kvack.org>
Subject: Re: [PATCH 4/4] mm: hugetlb: allocate frozen pages in alloc_gigantic_folio()
Date: Fri, 12 Sep 2025 14:57:41 +0800	[thread overview]
Message-ID: <d63e7e02-b2ab-46fb-b981-ad4f4f28d634@huawei.com> (raw)
In-Reply-To: <667133bd-0021-4d4e-9cde-fc8c1324522a@redhat.com>



On 2025/9/12 2:56, David Hildenbrand wrote:
> On 11.09.25 11:11, Kefeng Wang wrote:
>>
>>
>> On 2025/9/11 16:25, David Hildenbrand wrote:
>>> On 11.09.25 08:56, Kefeng Wang wrote:
>>>> The alloc_gigantic_folio() allocates a folio by alloc_contig_range()
>>>> with refcount increated and then freeze it, convert to allocate a 
>>>> frozen
>>>> folio directly to remove the atomic operation about folio refcount, 
>>>> also
>>>> saving atomic operation during __update_and_free_hugetlb_folio too.
>>>>
>>>> Rename some functions to make them more self-explanatory,
>>>>
>>>>     folio_alloc_gigantic            -> folio_alloc_frozen_gigantic
>>>>     cma_{alloc,free}_folio          -> cma_{alloc,free}_frozen_folio
>>>>     hugetlb_cma_{alloc,free}_folio  -> hugetlb_cma_{alloc,free}
>>>> _frozen_folio
>>>
>>> Can we just get rid of folio_alloc_frozen_gigantic?
>>>
>>
>> OK, we could kill it.
>>
>>> Further, can we just get rid of cma_{alloc,free}_frozen_folio() as well
>>> and just let hugetlb use alloc_contig_range_frozen() etc?
>>
>> HugeTLB can allocate folio by alloc_contig_frozen_pages() directly, but
>> it could allocate from hugetlb_cma, cma_alloc_folio() need change some
>> cma metadata, so we need to keep it.
> 
> Hm. Assuming we just have cma_alloc_frozen() -- again, probably what 
> cma_alloc() would look like in the future, hugetlb can just construct a 
> folio out of that.

I get your point,firstly, we could convert to use cma_alloc_frozen()
instead of cma_alloc_folio() in hugetlb_cma_alloc_folio().

> 
> Maybe we just want a helper to create a folio out of a given page range?
> 
> And that page range is either obtained through cma_alloc_frozen() or 
> alloc_contig_frozen_pages().
> 
> Just a thought, keeping in mind that these things should probably just 
> work with frozen pages and let allcoating of a memdesc etc. be taken 
> care of someone else.
> 
> I'd be happy if we can remove the GFP_COMPOUND parameter from 
> alloc_contig*.

But not sure about this part,  GFP_COMPOUND for alloc_contig* is
introduced by commit e98337d11bbd "mm/contig_alloc: support __GFP_COMP",
if we still allocate a range of order-0 pages and create a folio
outside, it will slow the large folio allocation.


> 
> @Willy, what's your take?
> 



  reply	other threads:[~2025-09-12  6:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-11  6:56 [PATCH 0/4] mm: hugetlb: allocate frozen gigantic folio Kefeng Wang
2025-09-11  6:56 ` [PATCH 1/4] mm: debug_vm_pgtable: add debug_vm_pgtable_free_huge_page() Kefeng Wang
2025-09-12  6:58   ` Kefeng Wang
2025-09-11  6:56 ` [PATCH 2/4] mm: page_alloc: add alloc_contig_{range_frozen,frozen_pages}() Kefeng Wang
2025-09-11  6:56 ` [PATCH 3/4] mm: cma: add __cma_release() Kefeng Wang
2025-09-11  6:56 ` [PATCH 4/4] mm: hugetlb: allocate frozen pages in alloc_gigantic_folio() Kefeng Wang
2025-09-11  8:25   ` David Hildenbrand
2025-09-11  9:11     ` Kefeng Wang
2025-09-11 18:56       ` David Hildenbrand
2025-09-12  6:57         ` Kefeng Wang [this message]
2025-09-12  7:18           ` David Hildenbrand
2025-09-12  7:23             ` David Hildenbrand
2025-09-12  9:12               ` Kefeng Wang
2025-09-12 18:07                 ` David Hildenbrand
2025-09-13  4:13                   ` 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=d63e7e02-b2ab-46fb-b981-ad4f4f28d634@huawei.com \
    --to=wangkefeng.wang@huawei.com \
    --cc=20250910133958.301467-1-wangkefeng.wang@huawei.com \
    --cc=akpm@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.