linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Kefeng Wang <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 20:07:02 +0200	[thread overview]
Message-ID: <5ede233c-c8c6-4067-afb3-df94b4222cda@redhat.com> (raw)
In-Reply-To: <8a524eda-c3fe-4e28-a24b-4050484e472f@huawei.com>


>>>
>>> Would be interesting trying to see how much overhead would remain when
>>> just dealing
> 
> Patch2 skip atomic update in split_page() with alloc_contig_frozen_pages(),
> I could test performance about old alloc_contig_pages() with/without
> GFP_COMP and new alloc_contig_frozen_pages() when allocate same size.

Yes, that would be very interesting.

> 
>>>
>>> OTOH, maybe we can leave GFP_COMPOUND support in but make the function
>>> more generic, not limited to folios (I suspect many users will not want
>>> folios, except hugetlb).
>>>
> 
> Maybe just only add cma_alloc_frozen(), and
> cma_alloc()/hugetlb_cma_alloc_folio()
> is the wrapper that calls it and set page refcount, like what we did in
> other frozen allocation.
> 
> struct page *cma_alloc_frozen(struct cma *cma, unsigned long count,
> 				unsigned int align, gfp_t gfp);

I think it's weird that cma_alloc_frozen() consumes gfp_t when 
cma_alloc() doesn't. So I would wish that we can clean that up (-> 
remove gfp if possible).

So maybe we really want a

cma_alloc_frozen

and

cma_alloc_frozen_compound

whereby the latter consumes an "order" instead of "count + align".

> 
>>> Maybe just a
>>>
>>> struct page * cma_alloc_compound(struct cma *cma, unsigned int order,
>>> unsigned int align, bool no_warn);
>>
>> ^ no need for the align as I realized, just like
>> cma_alloc_folio() doesn't have.
> 
> since cma_alloc_frozen is more generic, we need keep align,
> 
>>
>> I do wonder why we decided to allow cma_alloc_folio() to consume gfp_t
>> flags when we don't do the same for cma_alloc().
>>
> 
> cma_alloc_folio() now is called by hugetlb allocation, the gfp could be
> htlb_alloc_mask(), with/without __GFP_THISNODE/__GFP_RETRY_MAYFAIL...
> and this could be used in alloc_contig_frozen_pages(),(eg,
> gfp_zone).

Take a look at alloc_contig_range_noprof() where I added

	__alloc_contig_verify_gfp_mask()

Essentially, we ignore

	GFP_ZONEMASK | __GFP_RECLAIMABLE | __GFP_WRITE | __GFP_HARDWALL
        | __GFP_THISNODE | __GFP_MOVABLE

And we *always* set __GFP_RETRY_MAYFAIL

I'd argue that hugetlb passing in random parameters that don't really 
make sense for contig allcoations is rather an issue and makes you 
believe that they would have any effect.

If cma_alloc doesn't provide them a cma_alloc_frozen or cma_alloc_folio 
shouldn't provide them.

> 
> For cma_alloc() unconditional use GFP_KERNEL from commit
> 6518202970c1 "mm/cma: remove unsupported gfp_mask parameter from
> cma_alloc()", but this is another story.
> 
> Back to this patchset, just add a new cma_alloc_frozen() shown
> above and directly call it in cma_alloc()/hugetlb_cma_alloc_folio(),
> get rid of folio_alloc_frozen_gigantic() and cma_alloc_folio(), and
> we could do more optimization in the next step.

Yeah, that's probably a good first step, but while at it I would hope we 
could just cleanup the gfp stuff and provide a more consistent interface.

-- 
Cheers

David / dhildenb



  reply	other threads:[~2025-09-12 18:07 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
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 [this message]
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=5ede233c-c8c6-4067-afb3-df94b4222cda@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --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=wangkefeng.wang@huawei.com \
    --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