Re: [PATCH] x86/mm: avoid a reclaiming allocation in pud_free_pmd_page()
From: Mikhail Gavrilov
Date: Wed Sep 23 2026 - 19:06:41 EST
On 9/23/26 15:53, Dave Hansen wrote:
> I think that means we can do something like the completely untested
> attached patch.
>
> Looks like Mikhail came to basically the same conclusion.
Yes - v2 does the same thing, and also drops the now-stale NOTE about
the page allocation. It went out about 20 minutes before your mail:
https://lore.kernel.org/all/20260923223116.20090-1-mikhail.v.gavrilov@xxxxxxxxx/
It was tested on a box that reaches this path at boot without any
instrumentation (from amdgpu_ttm_init()), plus the TTM shrinker
reproducer; the details are below the scissors there.
Two things in the attached sketch, in case it gets picked up as is:
- The first hunk prepends the patch name to the SPDX line
("pud_free_pmd_page-simplify// SPDX-License-Identifier: ..."),
which will not build.
- Making it return void conflicts with the prototype in
include/linux/pgtable.h, and vmap_try_huge_pud() still does
"if (!pud_free_pmd_page(pud, addr))". The arm64, riscv and powerpc
versions also always return 1, so dropping the return value looks
like a reasonable follow-up across architectures, but I kept v2
x86-only and returning int so that it stays small for stable.
Your comment above the flush explains it better than the "INVLPG to
clear all paging-structure caches" one-liner. If you prefer it, I can
send a v3 with it, or feel free to fold it in when applying.