mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Muchun Song <muchun.song@linux.dev>
To: Qi Zheng <qi.zheng@linux.dev>
Cc: osalvador@suse.de, David Hildenbrand <david@kernel.org>,
	akpm@linux-foundation.org, azpijr@gmail.com,
	Lance Yang <lance.yang@linux.dev>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	stable@vger.kernel.org, Qi Zheng <zhengqi.arch@bytedance.com>
Subject: Re: [PATCH v2 2/4] mm: gup: allow long-term pins of CMA-allocated HugeTLB folios
Date: Fri, 6 Nov 2026 10:54:10 +0800	[thread overview]
Message-ID: <ED3C9A78-9823-4F37-BF2B-0A8873001BF5@linux.dev> (raw)
In-Reply-To: <39b7ecd4-e5a1-48d9-8d34-4bf8f8ad4ca2@linux.dev>



> On Nov 6, 2026, at 10:48, Qi Zheng <qi.zheng@linux.dev> wrote:
> 
> 
> 
> On 11/5/26 1:13 PM, Muchun Song wrote:
>>> On Nov 5, 2026, at 12:07, Qi Zheng <qi.zheng@linux.dev> wrote:
>>> 
>>> From: Qi Zheng <zhengqi.arch@bytedance.com>
>>> 
>>> Long-term pinning treats explicitly CMA-allocated HugeTLB folios as
>>> unpinnable, causing unnecessary migration or pinning failures.
>>> 
>>> These folios already own their CMA bitmap ranges, and memory blocks
>>> overlapping CMA areas cannot be offlined. Allow HugeTLB folios with
>>> HPG_cma to be pinned directly, including in ZONE_MOVABLE.
>>> 
>>> Fixes: cf11e85fc08c ("mm: hugetlb: optionally allocate gigantic hugepages using cma")
>>> Cc: stable@vger.kernel.org
>>> Suggested-by: Muchun Song <muchun.song@linux.dev>
>>> Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
>> Acked-by: Muchun Song <muchun.song@linux.dev>
> 
> Thanks.
> 
>> But a nit bellow.
>>> ---
>>> include/linux/mm.h | 29 +----------------------------
>>> mm/gup.c           | 31 +++++++++++++++++++++++++++++++
>>> 2 files changed, 32 insertions(+), 28 deletions(-)
>>> 
>>> diff --git a/include/linux/mm.h b/include/linux/mm.h
>>> index 2d0b8a4c9974f..75dd40265d3f4 100644
>>> --- a/include/linux/mm.h
>>> +++ b/include/linux/mm.h
>>> @@ -2975,35 +2975,8 @@ static inline bool is_zero_folio(const struct folio *folio)
>>> return is_zero_page(&folio->page);
>>> }
>>> 
>>> -/* MIGRATE_CMA and ZONE_MOVABLE do not allow pin folios */
>>> #ifdef CONFIG_MIGRATION
>>> -static inline bool folio_is_longterm_pinnable(struct folio *folio)
>>> -{
>>> -#ifdef CONFIG_CMA
>>> - 	int mt = folio_migratetype(folio);
>>> -
>>> - 	if (mt == MIGRATE_CMA || mt == MIGRATE_ISOLATE)
>>> - 		return false;
>>> -#endif
>>> - 	/* The zero page can be "pinned" but gets special handling. */
>>> - 	if (is_zero_folio(folio))
>>> - 		return true;
>>> -
>>> - 	/* Coherent device memory must always allow eviction. */
>>> - 	if (folio_is_device_coherent(folio))
>>> - 		return false;
>>> -
>>> - 	/*
>>> - 	 * Filesystems can only tolerate transient delays to truncate and
>>> - 	 * hole-punch operations
>>> - 	 */
>>> - 	if (folio_is_fsdax(folio))
>>> - 		return false;
>>> -
>>> - 	/* Otherwise, non-movable zone folios can be pinned. */
>>> - 	return !folio_is_zone_movable(folio);
>>> -
>>> -}
>>> +bool folio_is_longterm_pinnable(struct folio *folio);
>>> #else
>>> static inline bool folio_is_longterm_pinnable(struct folio *folio)
>>> {
>>> diff --git a/mm/gup.c b/mm/gup.c
>>> index 2b405cce2ca5c..e8503141bb275 100644
>>> --- a/mm/gup.c
>>> +++ b/mm/gup.c
>>> @@ -2216,6 +2216,37 @@ struct page *get_dump_page(unsigned long addr, int *locked)
>>> 
>>> #ifdef CONFIG_MIGRATION
>>> 
>>> +bool folio_is_longterm_pinnable(struct folio *folio)
>>> +{
>>> +#ifdef CONFIG_CMA
>>> + 	int mt = folio_migratetype(folio);
>>> +
>>> + 	/* Explicit HugeTLB CMA allocations own their bitmap ranges. */
>> The description of "bitmap ranges" is weird, making me think what's the meaning of
>> bitmap. Please use more generic description here.
> 
> How about this:
> 
> /* These HugeTLB folios own the CMA memory, so they can be long-term pinned. */
> 

At least better than original.

Thanks,
Muchun

> Thanks,
> Qi



  reply	other threads:[~2026-11-06  2:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05  4:07 [PATCH v2 0/4] mm: hugetlb: fix CMA-related issues Qi Zheng
2026-11-05  4:07 ` [PATCH v2 1/4] x86: hugetlb: disable default CMA reservations on 32-bit kernel Qi Zheng
2026-11-05  9:29   ` Oscar Salvador (SUSE)
2026-11-05  4:07 ` [PATCH v2 2/4] mm: gup: allow long-term pins of CMA-allocated HugeTLB folios Qi Zheng
2026-11-05  5:13   ` Muchun Song
2026-11-06  2:48     ` Qi Zheng
2026-11-06  2:54       ` Muchun Song [this message]
2026-11-05  9:33   ` Oscar Salvador (SUSE)
2026-11-05 11:28   ` Jose A. Perez de Azpillaga
2026-11-05  4:07 ` [PATCH v2 3/4] mm: hugetlb: fix GFP mask propagation to CMA Qi Zheng
2026-11-05  5:17   ` Muchun Song
2026-11-05 10:00   ` Oscar Salvador (SUSE)
2026-11-06  2:43     ` Qi Zheng
2026-11-06  5:50       ` Oscar Salvador (SUSE)
2026-11-06  6:12         ` Qi Zheng
2026-11-05 11:28   ` Jose A. Perez de Azpillaga
2026-11-05  4:07 ` [PATCH v2 4/4] mm: hugetlb: fix cpuset violations in gigantic surplus allocations Qi Zheng

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=ED3C9A78-9823-4F37-BF2B-0A8873001BF5@linux.dev \
    --to=muchun.song@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=azpijr@gmail.com \
    --cc=david@kernel.org \
    --cc=lance.yang@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=osalvador@suse.de \
    --cc=qi.zheng@linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=zhengqi.arch@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

all inboxes | Powered by JetHome®