x86/mm/dump_pagetables: Speed up page tables dump for CONFIG_KASAN=y
authorAndrey Ryabinin <[email protected]>
Mon, 24 Jul 2017 15:25:58 +0000 (18:25 +0300)
committerIngo Molnar <[email protected]>
Tue, 25 Jul 2017 09:22:09 +0000 (11:22 +0200)
commit04b67022fb6d5b13025591f61a487a6ef7f4f05c
tree1bf6f1bd2104b15b5cc2efcb8cc31c9e69bd1451
parent10af6235e0d327d42e1bad974385197817923dc1
x86/mm/dump_pagetables: Speed up page tables dump for CONFIG_KASAN=y

KASAN fills kernel page tables with repeated values to map several
TBs of the virtual memory to the single kasan_zero_page:
  kasan_zero_p4d ->
    kasan_zero_pud ->
        kasan_zero_pmd->
            kasan_zero_pte->
                kasan_zero_page

Walking the whole KASAN shadow range takes a lot of time, especially
with 5-level page tables. Since we already know that all kasan page tables
eventually point to the kasan_zero_page we could call note_page()
right and avoid walking lower levels of the page tables.
This will not affect the output of the kernel_page_tables file,
but let us avoid spending time in page table walkers:

Before:

  $ time cat /sys/kernel/debug/kernel_page_tables > /dev/null

  real    0m55.855s
  user    0m0.000s
  sys     0m55.840s

After:

  $ time cat /sys/kernel/debug/kernel_page_tables > /dev/null

  real    0m0.054s
  user    0m0.000s
  sys     0m0.054s

Signed-off-by: Andrey Ryabinin <[email protected]>
Acked-by: Kirill A. Shutemov <[email protected]>
Cc: Alexander Potapenko <[email protected]>
Cc: Dmitry Vyukov <[email protected]>
Cc: Kirill A. Shutemov <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
arch/x86/mm/dump_pagetables.c