mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lance Yang <lance.yang@linux.dev>
To: yintirui@gmail.com
Cc: akpm@linux-foundation.org, linux-mm@kvack.org, david@kernel.org,
	ljs@kernel.org, dev.jain@arm.com, ziy@nvidia.com,
	baolin.wang@linux.alibaba.com, baohua@kernel.org,
	ryan.roberts@arm.com, nico.pache@linux.dev, usama.arif@linux.dev,
	liam@infradead.org, wangkefeng.wang@huawei.com,
	chenjun102@huawei.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC 4/9] mm/huge_memory: use normal_or_softleaf_folio_pmd() in the PMD split path
Date: Sun, 13 Sep 2026 13:21:29 +0800	[thread overview]
Message-ID: <afafcdd7-3854-4860-a12d-35498a007106@linux.dev> (raw)
In-Reply-To: <20260912073755.8403-1-lance.yang@linux.dev>



On 2026/9/12 15:37, Lance Yang wrote:
> 
> On Sat, Aug 29, 2026 at 02:33:14AM +0800, Yin Tirui wrote:
>> Get the folio once with normal_or_softleaf_folio_pmd() and decide the
>> deposit once with has_deposited_pgtable(), as zap_huge_pmd() does. That
>> makes split and zap classify an entry the same way, and drops
>> vma_is_special_huge() from this path.
>>
>> Behaviour changes only where the entry and the VMA flags disagree, which no
>> in-tree path produces.
>>
>> Signed-off-by: Yin Tirui <yintirui@gmail.com>
>> ---
>> mm/huge_memory.c | 21 ++++++++++++---------
>> 1 file changed, 12 insertions(+), 9 deletions(-)
>>
>> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
>> index aefd62827139..b2ede9a6ae5d 100644
>> --- a/mm/huge_memory.c
>> +++ b/mm/huge_memory.c
>> @@ -3172,7 +3172,7 @@ static void unmap_huge_pmd_entry(struct vm_area_struct *vma,
>> 	 * We are going to unmap this huge page. So
>> 	 * just go ahead and zap it
>> 	 */
>> -	if (arch_needs_pgtable_deposit())
>> +	if (has_deposited_pgtable(vma, old_pmd, folio))
>> 		zap_deposited_table(mm, pmd);
> 
> Staring at this ... I think we're missing raw PFN mappings of the huge
> zero folio ...
> 
> static bool has_deposited_pgtable(struct vm_area_struct *vma, pmd_t pmdval,
> 		struct folio *folio)
> {
> 	/* Some architectures require unconditional depositing. */
> 	if (arch_needs_pgtable_deposit())
> 		return true;
> 
> ...
> 	if (is_huge_zero_pmd(pmdval))
> 		return !vma_is_dax(vma);
> 
> ...
> 	return folio && folio_test_anon(folio);
> }
> 
> If a non-DAX raw PFN mapping on x86 (say, via mshv_vtl_low) matches
> huge_zero_pfn, vmf_insert_pfn_pmd() won't deposit a page table, but
> has_deposited_pgtable() will return true ...
> 
> Before this patch, arch_needs_pgtable_deposit() skips withdrawal when
> splitting this mapping on x86. The new check would instead reach
> pgtable_trans_huge_withdraw() and dereference NULL through pgtable->lru
> if pmd_huge_pte(mm, pmd) is NULL.
> 
> The helper already causes the same bug in zap_huge_pmd(), but extending
> it to split is a regression introduced by this patch. I'll send a separate
> fix, and we need it landed first :D

https://lore.kernel.org/linux-mm/20260913051942.40889-1-lance.yang@linux.dev/T/#u


  reply	other threads:[~2026-09-13  5:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-28 18:33 [PATCH RFC 0/9] mm/huge_memory: refactor __split_huge_pmd_locked() Yin Tirui
2026-08-28 18:33 ` [PATCH RFC 1/9] mm/huge_memory: read the huge PMD entry once when splitting it Yin Tirui
2026-08-28 18:33 ` [PATCH RFC 2/9] mm/huge_memory: add and use huge_zero_pmd_can_split() Yin Tirui
2026-08-28 18:33 ` [PATCH RFC 3/9] mm/huge_memory: add and use unmap_huge_pmd_entry() Yin Tirui
2026-08-28 18:33 ` [PATCH RFC 4/9] mm/huge_memory: use normal_or_softleaf_folio_pmd() in the PMD split path Yin Tirui
2026-09-12  7:37   ` Lance Yang
2026-09-13  5:21     ` Lance Yang [this message]
2026-08-28 18:33 ` [PATCH RFC 5/9] mm/huge_memory: dispatch on the folio when splitting a huge PMD Yin Tirui
2026-08-28 18:33 ` [PATCH RFC 6/9] mm/huge_memory: add and use split_huge_pmd_anon_rmap() Yin Tirui
2026-08-28 18:33 ` [PATCH RFC 7/9] mm/huge_memory: add struct split_pmd_state Yin Tirui
2026-08-28 18:33 ` [PATCH RFC 8/9] mm/huge_memory: split present and non-present huge PMDs separately Yin Tirui
2026-08-28 18:33 ` [PATCH RFC 9/9] mm/huge_memory: unify the migration and device private PTE loops Yin Tirui
2026-09-11 16:51 ` [PATCH RFC 0/9] mm/huge_memory: refactor __split_huge_pmd_locked() David Hildenbrand (Arm)

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=afafcdd7-3854-4860-a12d-35498a007106@linux.dev \
    --to=lance.yang@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=chenjun102@huawei.com \
    --cc=david@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=nico.pache@linux.dev \
    --cc=ryan.roberts@arm.com \
    --cc=usama.arif@linux.dev \
    --cc=wangkefeng.wang@huawei.com \
    --cc=yintirui@gmail.com \
    --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

all inboxes | Powered by JetHome®