Re: [PATCH V6 0/2] mm/debug: Add tests validating architecture page table helpers

From: Qian Cai
Date: Tue Oct 15 2019 - 10:41:51 EST


The x86 will crash with linux-next during boot due to this series (v5) with the
config below plus CONFIG_DEBUG_VM_PGTABLE=y. I am not sure if v6 would address
it.

https://raw.githubusercontent.com/cailca/linux-mm/master/x86.config

[ÂÂÂ33.862600][ÂÂÂÂT1] page:ffffea0009000000 is uninitialized and poisoned
[ÂÂÂ33.862608][ÂÂÂÂT1] raw: ffffffffffffffff ffffffffffffffff ffffffffffffffff
ffffff871140][ÂÂÂÂT1]ÂÂ? _raw_spin_unlock_irq+0x27/0x40
[ÂÂÂ33.871140][ÂÂÂÂT1]ÂÂ? rest_init+0x307/0x307
[ÂÂÂ33.871140][ÂÂÂÂT1]ÂÂkernel_init+0x11/0x139
[ÂÂÂ33.871140][ÂÂÂÂT1]ÂÂ? rest_init+0x307/0x307
[ÂÂÂ33.871140][ÂÂÂÂT1]ÂÂret_from_fork+0x27/0x50
[ÂÂÂ33.871140][ÂÂÂÂT1] Modules linked in:
[ÂÂÂ33.871140][ÂÂÂÂT1] ---[ end trace e99d392b0f7befbd ]---
[ÂÂÂ33.871140][ÂÂÂÂT1] RIP: 0010:alloc_gigantic_page_order+0x3fe/0x490

On Tue, 2019-10-15 at 14:51 +0530, Anshuman Khandual wrote:
> This series adds a test validation for architecture exported page table
> helpers. Patch in the series adds basic transformation tests at various
> levels of the page table. Before that it exports gigantic page allocation
> function from HugeTLB.
>
> This test was originally suggested by Catalin during arm64 THP migration
> RFC discussion earlier. Going forward it can include more specific tests
> with respect to various generic MM functions like THP, HugeTLB etc and
> platform specific tests.
>
> https://lore.kernel.org/linux-mm/20190628102003.GA56463@xxxxxxxxxxxxxxxxxxxx/
>
> Changes in V6:
>
> - Moved alloc_gigantic_page_order() into mm/page_alloc.c per Michal
> - Moved alloc_gigantic_page_order() within CONFIG_CONTIG_ALLOC in the test
> - Folded Andrew's include/asm-generic/pgtable.h fix into the test patch 2/2
>
> Changes in V5: (https://patchwork.kernel.org/project/linux-mm/list/?series=185991)
>
> - Redefined and moved X86 mm_p4d_folded() into a different header per Kirill/Ingo
> - Updated the config option comment per Ingo and dropped 'kernel module' reference
> - Updated the commit message and dropped 'kernel module' reference
> - Changed DEBUG_ARCH_PGTABLE_TEST into DEBUG_VM_PGTABLE per Ingo
> - Moved config option from mm/Kconfig.debug into lib/Kconfig.debug
> - Renamed core test function arch_pgtable_tests() as debug_vm_pgtable()
> - Renamed mm/arch_pgtable_test.c as mm/debug_vm_pgtable.c
> - debug_vm_pgtable() gets called from kernel_init_freeable() after init_mm_internals()
> - Added an entry in Documentation/features/debug/ per Ingo
> - Enabled the test on arm64 and x86 platforms for now
>
> Changes in V4: (https://patchwork.kernel.org/project/linux-mm/list/?series=183465)
>
> - Disable DEBUG_ARCH_PGTABLE_TEST for ARM and IA64 platforms
>
> Changes in V3: (https://lore.kernel.org/patchwork/project/lkml/list/?series=411216)
>
> - Changed test trigger from module format into late_initcall()
> - Marked all functions with __init to be freed after completion
> - Changed all __PGTABLE_PXX_FOLDED checks as mm_pxx_folded()
> - Folded in PPC32 fixes from Christophe
>
> Changes in V2:
>
> https://lore.kernel.org/linux-mm/1568268173-31302-1-git-send-email-anshuman.khandual@xxxxxxx/T/#t
>
> - Fixed small typo error in MODULE_DESCRIPTION()
> - Fixed m64k build problems for lvalue concerns in pmd_xxx_tests()
> - Fixed dynamic page table level folding problems on x86 as per Kirril
> - Fixed second pointers during pxx_populate_tests() per Kirill and Gerald
> - Allocate and free pte table with pte_alloc_one/pte_free per Kirill
> - Modified pxx_clear_tests() to accommodate s390 lower 12 bits situation
> - Changed RANDOM_NZVALUE value from 0xbe to 0xff
> - Changed allocation, usage, free sequence for saved_ptep
> - Renamed VMA_FLAGS as VMFLAGS
> - Implemented a new method for random vaddr generation
> - Implemented some other cleanups
> - Dropped extern reference to mm_alloc()
> - Created and exported new alloc_gigantic_page_order()
> - Dropped the custom allocator and used new alloc_gigantic_page_order()
>
> Changes in V1:
>
> https://lore.kernel.org/linux-mm/1567497706-8649-1-git-send-email-anshuman.khandual@xxxxxxx/
>
> - Added fallback mechanism for PMD aligned memory allocation failure
>
> Changes in RFC V2:
>
> https://lore.kernel.org/linux-mm/1565335998-22553-1-git-send-email-anshuman.khandual@xxxxxxx/T/#u
>
> - Moved test module and it's config from lib/ to mm/
> - Renamed config TEST_ARCH_PGTABLE as DEBUG_ARCH_PGTABLE_TEST
> - Renamed file from test_arch_pgtable.c to arch_pgtable_test.c
> - Added relevant MODULE_DESCRIPTION() and MODULE_AUTHOR() details
> - Dropped loadable module config option
> - Basic tests now use memory blocks with required size and alignment
> - PUD aligned memory block gets allocated with alloc_contig_range()
> - If PUD aligned memory could not be allocated it falls back on PMD aligned
> memory block from page allocator and pud_* tests are skipped
> - Clear and populate tests now operate on real in memory page table entries
> - Dummy mm_struct gets allocated with mm_alloc()
> - Dummy page table entries get allocated with [pud|pmd|pte]_alloc_[map]()
> - Simplified [p4d|pgd]_basic_tests(), now has random values in the entries
>
> Original RFC V1:
>
> https://lore.kernel.org/linux-mm/1564037723-26676-1-git-send-email-anshuman.khandual@xxxxxxx/
>
> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Cc: Vlastimil Babka <vbabka@xxxxxxx>
> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> Cc: Mike Rapoport <rppt@xxxxxxxxxxxxxxxxxx>
> Cc: Jason Gunthorpe <jgg@xxxxxxxx>
> Cc: Dan Williams <dan.j.williams@xxxxxxxxx>
> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Cc: Michal Hocko <mhocko@xxxxxxxxxx>
> Cc: Mark Rutland <mark.rutland@xxxxxxx>
> Cc: Mark Brown <broonie@xxxxxxxxxx>
> Cc: Steven Price <Steven.Price@xxxxxxx>
> Cc: Ard Biesheuvel <ard.biesheuvel@xxxxxxxxxx>
> Cc: Masahiro Yamada <yamada.masahiro@xxxxxxxxxxxxx>
> Cc: Kees Cook <keescook@xxxxxxxxxxxx>
> Cc: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx>
> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx>
> Cc: Sri Krishna chowdary <schowdary@xxxxxxxxxx>
> Cc: Dave Hansen <dave.hansen@xxxxxxxxx>
> Cc: Russell King - ARM Linux <linux@xxxxxxxxxxxxxxx>
> Cc: Michael Ellerman <mpe@xxxxxxxxxxxxxx>
> Cc: Paul Mackerras <paulus@xxxxxxxxx>
> Cc: Martin Schwidefsky <schwidefsky@xxxxxxxxxx>
> Cc: Heiko Carstens <heiko.carstens@xxxxxxxxxx>
> Cc: "David S. Miller" <davem@xxxxxxxxxxxxx>
> Cc: Vineet Gupta <vgupta@xxxxxxxxxxxx>
> Cc: James Hogan <jhogan@xxxxxxxxxx>
> Cc: Paul Burton <paul.burton@xxxxxxxx>
> Cc: Ralf Baechle <ralf@xxxxxxxxxxxxxx>
> Cc: Kirill A. Shutemov <kirill@xxxxxxxxxxxxx>
> Cc: Gerald Schaefer <gerald.schaefer@xxxxxxxxxx>
> Cc: Christophe Leroy <christophe.leroy@xxxxxx>
> Cc: Mike Kravetz <mike.kravetz@xxxxxxxxxx>
> Cc: linux-snps-arc@xxxxxxxxxxxxxxxxxxx
> Cc: linux-mips@xxxxxxxxxxxxxxx
> Cc: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
> Cc: linux-ia64@xxxxxxxxxxxxxxx
> Cc: linuxppc-dev@xxxxxxxxxxxxxxxx
> Cc: linux-s390@xxxxxxxxxxxxxxx
> Cc: linux-sh@xxxxxxxxxxxxxxx
> Cc: sparclinux@xxxxxxxxxxxxxxx
> Cc: x86@xxxxxxxxxx
> Cc: linux-kernel@xxxxxxxxxxxxxxx
>
>
> Anshuman Khandual (2):
> mm/page_alloc: Make alloc_gigantic_page() available for general use
> mm/debug: Add tests validating architecture page table helpers
>
> .../debug/debug-vm-pgtable/arch-support.txt | 34 ++
> arch/arm64/Kconfig | 1 +
> arch/x86/Kconfig | 1 +
> arch/x86/include/asm/pgtable_64.h | 6 +
> include/asm-generic/pgtable.h | 6 +
> include/linux/gfp.h | 3 +
> init/main.c | 1 +
> lib/Kconfig.debug | 21 +
> mm/Makefile | 1 +
> mm/debug_vm_pgtable.c | 450 ++++++++++++++++++
> mm/hugetlb.c | 76 +--
> mm/page_alloc.c | 98 ++++
> 12 files changed, 623 insertions(+), 75 deletions(-)
> create mode 100644 Documentation/features/debug/debug-vm-pgtable/arch-support.txt
> create mode 100644 mm/debug_vm_pgtable.c
>