From: sashiko-bot@kernel.org
To: "Eliav Farber" <farbere@amazon.com>,
"Andrew Morton" <akpm@linux-foundation.org>
Cc: "David Hildenbrand" <david@kernel.org>,
"Lorenzo Stoakes" <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
"Vlastimil Babka" <vbabka@kernel.org>,
"Mike Rapoport" <rppt@kernel.org>,
"Suren Baghdasaryan" <surenb@google.com>,
"Michal Hocko" <mhocko@suse.com>, "Zi Yan" <ziy@nvidia.com>,
"Baolin Wang" <baolin.wang@linux.alibaba.com>,
"Nico Pache" <nico.pache@linux.dev>,
"Ryan Roberts" <ryan.roberts@arm.com>,
"Dev Jain" <dev.jain@arm.com>, "Barry Song" <baohua@kernel.org>,
"Lance Yang" <lance.yang@linux.dev>,
"Usama Arif" <usama.arif@linux.dev>,
"Kiryl Shutsemau" <kas@kernel.org>,
"Thomas Gleixner" <tglx@kernel.org>,
"Ingo Molnar" <mingo@redhat.com>,
"Borislav Petkov" <bp@alien8.de>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, "William Kucharski" <william.kucharski@linux.dev>,
"Vishal Moola" <vishal.moola@gmail.com>,
"Alex Williamson" <alex@shazbot.org>,
"Peter Xu" <peterx@redhat.com>,
linux-mm@kvack.org
Subject: Re: [PATCH 2/4] mm: don't report OOM when a huge PMD race blocks a pfn insert
Date: Thu, 12 Nov 2026 14:07:42 +0000 [thread overview]
Message-ID: <sashiko-outbox-211264@kernel.org> (raw)
In-Reply-To: <20261111140655.34281-3-farbere@amazon.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mm: spurious VM_FAULT_OOM in insert_pfn() on concurrent PMD
zap or split
--
commit 0ac526524e0ffcc35b96005d118a4d79edeae689
Author: Eliav Farber <farbere@amazon.com>
mm: don't report OOM when a huge PMD race blocks a pfn insert
This commit updates insert_pfn() to walk to the PMD and check for a
concurrently installed huge PMD leaf when pte_alloc_map_lock() returns NULL,
returning VM_FAULT_NOPAGE instead of VM_FAULT_OOM.
> diff --git a/mm/memory.c b/mm/memory.c
> index 09ae7e21ff0f5..509a984f17f8f 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -2803,10 +2803,25 @@ static vm_fault_t insert_pfn(struct vm_area_struct *vma, unsigned long addr,
> struct mm_struct *mm = vma->vm_mm;
> pte_t *pte, entry;
> spinlock_t *ptl;
> + pmd_t *pmd;
>
> - pte = get_locked_pte(mm, addr, &ptl);
> - if (!pte)
> + pmd = walk_to_pmd(mm, addr);
> + if (!pmd)
> + return VM_FAULT_OOM;
> +
> + pte = pte_alloc_map_lock(mm, pmd, addr, &ptl);
> + if (!pte) {
> + /*
> + * A concurrent ->huge_fault may have installed a PMD leaf over
> + * addr, which pte_offset_map_lock() refuses to walk. The
> + * mapping is fine, so let the access refault instead of
> + * reporting a failed allocation.
> + */
> + if (pmd_trans_huge(pmdp_get_lockless(pmd)))
> + return VM_FAULT_NOPAGE;
> return VM_FAULT_OOM;
> + }
[Severity: Medium]
Can this still return a spurious VM_FAULT_OOM if the huge PMD leaf is split
or zapped before pmdp_get_lockless() re-reads it?
CPU0 CPU1
insert_pfn()
pte_alloc_map_lock()
pte_alloc() -> 0
unmap_mapping_range()
...
zap_huge_pmd()
pmdp_huge_get_and_clear_full()
pte_offset_map_lock() -> NULL
pmd_trans_huge(pmdp_get_lockless(pmd)) -> false
return VM_FAULT_OOM; <-- spurious OOM
pte_alloc_map_lock() expands to pte_alloc() followed by
pte_offset_map_lock(). Only pte_alloc() allocates memory and can fail with
OOM; pte_offset_map_lock() never allocates and returns NULL whenever the PMD
is a leaf or pmd_none(). If a concurrent huge PMD is cleared back to
pmd_none() (for example by unmap_mapping_range() or __split_huge_pmd())
after pte_alloc() sees !pmd_none() and before pmdp_get_lockless(pmd) runs,
pmd_trans_huge() is false and insert_pfn() triggers the OOM killer even
though no allocation failed.
Calling pte_alloc(mm, pmd) first (returning VM_FAULT_OOM on failure) and
then pte_offset_map_lock(mm, pmd, addr, &ptl) (returning VM_FAULT_NOPAGE
when NULL), as do_anonymous_page() and finish_fault() do, avoids re-reading
*pmd.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261111140655.34281-1-farbere@amazon.com?part=2
next prev parent reply other threads:[~2026-11-12 14:07 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 14:06 [PATCH 0/4] mm: fixes for huge PFN mappings Eliav Farber
2026-11-11 14:06 ` [PATCH 1/4] mm: drop the huge PMD assertion from walk_to_pmd() Eliav Farber
2026-11-11 16:52 ` Jose A. Perez de Azpillaga
2026-11-11 14:06 ` [PATCH 2/4] mm: don't report OOM when a huge PMD race blocks a pfn insert Eliav Farber
2026-11-11 16:54 ` Jose A. Perez de Azpillaga
2026-11-12 4:56 ` Farber, Eliav
2026-11-12 14:07 ` sashiko-bot [this message]
2026-11-11 14:06 ` [PATCH 3/4] mm/huge_memory: don't warn when a page table blocks a huge " Eliav Farber
2026-11-11 16:54 ` Jose A. Perez de Azpillaga
2026-11-12 14:07 ` sashiko-bot
2026-11-11 14:06 ` [PATCH 4/4] mm/huge_memory: use the large-page PAT encoding for huge pfn mappings Eliav Farber
2026-11-11 16:54 ` Jose A. Perez de Azpillaga
2026-11-12 4:58 ` Farber, Eliav
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=sashiko-outbox-211264@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=alex@shazbot.org \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=farbere@amazon.com \
--cc=hpa@zytor.com \
--cc=kas@kernel.org \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=mingo@redhat.com \
--cc=nico.pache@linux.dev \
--cc=peterx@redhat.com \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=surenb@google.com \
--cc=tglx@kernel.org \
--cc=usama.arif@linux.dev \
--cc=vbabka@kernel.org \
--cc=vishal.moola@gmail.com \
--cc=william.kucharski@linux.dev \
--cc=x86@kernel.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.