Re: [BUG] WARNING: CPU: 3 PID: 1 at mm/debug_vm_pgtable.c:493
From: Linus Torvalds
Date: Tue Oct 12 2021 - 15:16:05 EST
On Tue, Oct 12, 2021 at 11:55 AM Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
>
> I saved off that warning from a different branch, and looking at the dmesg,
> it is:
>
> Linux version 5.14.0-rc2-test+
>
> Which shows this happened on 5.14 as well (and explains why the line
> numbers are different).
Ok, yes, that's the exact same "pud_set_huge()" failure.
So it's the same issue, and has been going on for a while, and
presumably very few people end up enabling DEBUG_VM_PGTABLE (together
with it being hard to trigger).
Or it's something specific to your setup, but that sounds unlikely.
You might add some debugging to the x86 pud_set_huge() function,
something like the attached (obviously entirely untested) patch.
Linus
arch/x86/mm/pgtable.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
index 3481b35cb4ec..0a3d67ec73d4 100644
--- a/arch/x86/mm/pgtable.c
+++ b/arch/x86/mm/pgtable.c
@@ -706,12 +706,16 @@ int pud_set_huge(pud_t *pud, phys_addr_t addr, pgprot_t prot)
mtrr = mtrr_type_lookup(addr, addr + PUD_SIZE, &uniform);
if ((mtrr != MTRR_TYPE_INVALID) && (!uniform) &&
- (mtrr != MTRR_TYPE_WRBACK))
+ (mtrr != MTRR_TYPE_WRBACK)) {
+ pr_debug("mtrr_type_lookup() returned %d (%d)\n", mtrr, uniform);
return 0;
+ }
/* Bail out if we are we on a populated non-leaf entry: */
- if (pud_present(*pud) && !pud_huge(*pud))
+ if (pud_present(*pud) && !pud_huge(*pud)) {
+ pr_debug("pud is already present (%lx)\n", (unsigned long)pud_val(*pud));
return 0;
+ }
set_pte((pte_t *)pud, pfn_pte(
(u64)addr >> PAGE_SHIFT,