Re: [tip:x86/mm] x86/mm/cpa: Fix populate_pgd(): Stop trying to deallocate failed PUDs

From: Linus Torvalds
Date: Sat Jul 23 2016 - 04:32:34 EST

On Sat, Jul 23, 2016 at 4:46 PM, tip-bot for Andy Lutomirski
<tipbot@xxxxxxxxx> wrote:
> Fixing this directly is difficult or impossible because of the awful
> state of Linux's page table accessors.

Quite frankly, this part of the message is misleading and wrong.

The "awful state" is purely "Andy didn't understand the folding".
There is nothing awful about it, quite the reverse. It is what allows
the generic code to mostly not have to care whether a particular level
actually exists or not, or is just folded into the next-higher level.
No, we don't alway have

I do agree that our *naming* is not great, and that when we get
five-level page tables we should strive to start having numbers
instead of the magic letters. The magic letters made sense with three
levels that had fairly well-known names (pgd/pmd/pte is not a Linux
invention), but with four levels it's already fairly questionable.

But the fact that a pud may not even exist, and in fact is just
another nested version of the pgd, is definitely *not* awful. And Andy
not understanding it and getting it wrong *still* doesn't make it

Yes, a folded level can be subtle. The level above the folded level
has no actual storage of its own, it just contains the folded level
directly. We've had confusion about it, and the naming really doesn't
help. But looking through include/asm-generic/pgtable-nopmd.h can
actually be instructive.

Calling something "awful" just because it's clever and you didn't
understand it is not right.

It would be *truly* awful if we forced everybody to actually have all
the levels, and then had to follow idiotic single-entry pointers at
the upper end that doesn't actually exist in reality, and we'd just
have these silly "software-only" levels to make everything be four
levels even if the hardware only does two.

That would be awful, because it would be *stupid*.