From: Lance Yang <lance.yang@linux.dev>
To: david@kernel.org
Cc: akpm@linux-foundation.org, ziy@nvidia.com,
baolin.wang@linux.alibaba.com, liam@infradead.org,
nico.pache@linux.dev, ryan.roberts@arm.com, dev.jain@arm.com,
baohua@kernel.org, lance.yang@linux.dev, usama.arif@linux.dev,
kas@kernel.org, qi.zheng@linux.dev, hughd@google.com,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v2 2/2] mm: don't allocate a page table under RCU in do_set_pmd()
Date: Sun, 8 Nov 2026 17:23:15 +0800 [thread overview]
Message-ID: <20261108092315.89639-1-lance.yang@linux.dev> (raw)
In-Reply-To: <20261106-khugepaged_set_pmd-v2-2-d2457b5e377a@kernel.org>
On Fri, Nov 06, 2026 at 01:36:13PM +0100, David Hildenbrand (Arm) wrote:
>do_fault_around() skips PTE table preallocation when the PMD already points
>to a PTE table. A concurrent collapse can then retract that table and
>clear the PMD before filemap_map_pages() locks the new PMD-sized folio.
Right, having a PTE table when we check in do_fault_around() doesn't mean
it'll still be there later ;)
>filemap_map_pmd() can then call do_set_pmd() with an empty PMD and no
>preallocated table. On PowerPC hash MMU, do_set_pmd() then tries
>allocating a PTE table to deposit. But filemap_map_pmd() calls
>do_set_pmd() under RCU, so allocating from that context is not good.
>
>This race became possible when retract_page_tables() stopped taking the
>mmap and VMA locks. Previously, those locks excluded retraction while
>the fault was in progress.
>
>Add a may_alloc argument to do_set_pmd() and pass false from
>filemap_map_pmd(), so we can fail with VM_FAULT_FALLBACK instead of
>trying to allocate.
YES, just fall back and let the regular fault handling take over after
leaving RCU.
>This issue should be fairly hard to hit in practice.
>
>Fixes: 1d65b771bc08 ("mm/khugepaged: retract_page_tables() without mmap or vma lock")
>Cc: stable@vger.kernel.org
>Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
>---
LGTM1
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Cheers, Lance
next prev parent reply other threads:[~2026-11-08 9:23 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 12:36 [PATCH v2 0/2] mm: free unused page table allocated by do_set_pmd() David Hildenbrand (Arm)
2026-11-06 12:36 ` [PATCH v2 1/2] " David Hildenbrand (Arm)
2026-11-06 15:34 ` Usama Arif
2026-11-09 14:26 ` David Hildenbrand (Arm)
2026-11-08 9:14 ` Lance Yang
2026-11-09 14:25 ` David Hildenbrand (Arm)
2026-11-10 6:37 ` Baolin Wang
2026-11-06 12:36 ` [PATCH v2 2/2] mm: don't allocate a page table under RCU in do_set_pmd() David Hildenbrand (Arm)
2026-11-06 15:56 ` Usama Arif
2026-11-09 14:27 ` David Hildenbrand (Arm)
2026-11-08 9:23 ` Lance Yang [this message]
2026-11-09 17:16 ` Kiryl Shutsemau
2026-11-09 14:27 ` [PATCH v2 0/2] mm: free unused page table allocated by do_set_pmd() David Hildenbrand
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=20261108092315.89639-1-lance.yang@linux.dev \
--to=lance.yang@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=hughd@google.com \
--cc=kas@kernel.org \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nico.pache@linux.dev \
--cc=qi.zheng@linux.dev \
--cc=ryan.roberts@arm.com \
--cc=stable@vger.kernel.org \
--cc=usama.arif@linux.dev \
--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.