[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170127113014.GA7662@node.shutemov.name>
Date: Fri, 27 Jan 2017 14:30:14 +0300
From: "Kirill A. Shutemov" <kirill@...temov.name>
To: Vlastimil Babka <vbabka@...e.cz>
Cc: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Andrew Morton <akpm@...ux-foundation.org>, x86@...nel.org,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Arnd Bergmann <arnd@...db.de>,
"H. Peter Anvin" <hpa@...or.com>, Andi Kleen <ak@...ux.intel.com>,
Dave Hansen <dave.hansen@...el.com>,
Andy Lutomirski <luto@...capital.net>,
linux-arch@...r.kernel.org, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCHv2 02/29] asm-generic: introduce 5level-fixup.h
On Fri, Jan 27, 2017 at 12:06:02PM +0100, Vlastimil Babka wrote:
> On 12/27/2016 02:53 AM, Kirill A. Shutemov wrote:
> >We are going to switch core MM to 5-level paging abstraction.
> >
> >This is preparation step which adds <asm-generic/5level-fixup.h>
> >As with 4level-fixup.h, the new header allows quickly make all
> >architectures compatible with 5-level paging in core MM.
> >
> >In long run we would like to switch architectures to properly folded p4d
> >level by using <asm-generic/pgtable-nop4d.h>, but it requires more
> >changes to arch-specific code.
> >
> >Signed-off-by: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>
> >---
> > include/asm-generic/4level-fixup.h | 3 ++-
> > include/asm-generic/5level-fixup.h | 41 ++++++++++++++++++++++++++++++++++++++
> > include/linux/mm.h | 3 +++
> > 3 files changed, 46 insertions(+), 1 deletion(-)
> > create mode 100644 include/asm-generic/5level-fixup.h
> >
> >diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
> >index 5bdab6bffd23..928fd66b1271 100644
> >--- a/include/asm-generic/4level-fixup.h
> >+++ b/include/asm-generic/4level-fixup.h
> >@@ -15,7 +15,6 @@
> > ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
> > NULL: pmd_offset(pud, address))
> >
> >-#define pud_alloc(mm, pgd, address) (pgd)
>
> This...
>
> > #define pud_offset(pgd, start) (pgd)
> > #define pud_none(pud) 0
> > #define pud_bad(pud) 0
> >@@ -35,4 +34,6 @@
> > #undef pud_addr_end
> > #define pud_addr_end(addr, end) (end)
> >
> >+#include <asm-generic/5level-fixup.h>
>
> ... plus this...
>
> >+
> > #endif
> >diff --git a/include/asm-generic/5level-fixup.h b/include/asm-generic/5level-fixup.h
> >new file mode 100644
> >index 000000000000..b5ca82dc4175
> >--- /dev/null
> >+++ b/include/asm-generic/5level-fixup.h
> >@@ -0,0 +1,41 @@
> >+#ifndef _5LEVEL_FIXUP_H
> >+#define _5LEVEL_FIXUP_H
> >+
> >+#define __ARCH_HAS_5LEVEL_HACK
> >+#define __PAGETABLE_P4D_FOLDED
> >+
> >+#define P4D_SHIFT PGDIR_SHIFT
> >+#define P4D_SIZE PGDIR_SIZE
> >+#define P4D_MASK PGDIR_MASK
> >+#define PTRS_PER_P4D 1
> >+
> >+#define p4d_t pgd_t
> >+
> >+#define pud_alloc(mm, p4d, address) \
> >+ ((unlikely(pgd_none(*(p4d))) && __pud_alloc(mm, p4d, address)) ? \
> >+ NULL : pud_offset(p4d, address))
>
> ... and this, makes me wonder if that broke pud_alloc() for architectures
> that use the 4level-fixup.h. Don't those need to continue having pud_alloc()
> as (pgd)?
Okay, that's very hacky, but works:
For 4level-fixup.h case we have __PAGETABLE_PUD_FOLDED set, so
__pud_alloc() will always succeed (see <linux/mm.h>). And pud_offset()
from 4level-fixup.h always returns pgd.
I've tested this on alpha with qemu.
--
Kirill A. Shutemov
Powered by blists - more mailing lists