[PATCH v3 15/47] mm/khugepaged: always recheck the pmd in try_collapse_pte_mapped_thp()
Baolin Wang
baolin.wang at linux.alibaba.com
Sun Nov 1 23:09:35 PST 2026
On 10/31/26 5:39 PM, David Hildenbrand (Arm) wrote:
> From: Josef Bacik <josef at toxicpanda.com>
>
> try_collapse_pte_mapped_thp() drops the PTE lock after it has cleared the
> page table, and takes the PMD lock and the PTE lock to remove it.
>
> In between, MADV_DONTNEED with CONFIG_PT_RECLAIM can reclaim the
> page table. The pmd_same() check is supposed to handle this, but it is
> only done with CONFIG_SPLIT_PTE_PTLOCKS.
>
> Fix it by performing the check unconditionally.
>
> Fix generated by an LLM and sent by Josef Bacik in private.
>
> Fixes: 6375e95f381e ("mm: pgtable: reclaim empty PTE page in madvise(MADV_DONTNEED)")
> Cc: stable at vger.kernel.org
> Signed-off-by: Josef Bacik <josef at toxicpanda.com>
> [ david: adjust description ]
> Reviewed-by: Gregory Price (Meta) <gourry at gourry.net>
> Tested-by: Gregory Price (Meta) <gourry at gourry.net>
> Tested-by: Muhammad Usama Anjum <usama.anjum at arm.com>
> Signed-off-by: David Hildenbrand (Arm) <david at kernel.org>
> ---
LGTM.
Reviewed-by: Baolin Wang <baolin.wang at linux.alibaba.com>
More information about the kexec
mailing list