Skip to content

Generic page walk and ptdump

Steven Price kvm-ppc linux-arm-kernel linux-mips linux-mm linux-riscv linux-s390 linux-snps-arc linuxppc-dev lkml sparclinux 17 versions – Applied

Status from this message: [merged] mm-ptdump-reduce-level-numbers-by-1-in-note_page.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v17 Latest23 patches 10 repliesApplied 23/23
  2. v1625 patches 10 repliesSuperseded
  3. v1523 patches 11 repliesSuperseded
Earlier versions · 14
VersionPostedPatchesRepliesStatus
v1422 patches8 repliesSuperseded
v1322 patches3 repliesSuperseded
v1222 patches6 repliesSuperseded
v1122 patches8 repliesSuperseded
v1022 patches4 repliesSuperseded
v921 patches40 repliesSuperseded
v820 patches7 repliesSuperseded
v720 patches0 repliesSuperseded
v619 patches2 repliesSuperseded
v519 patches4 repliesSuperseded
v419 patches4 repliesSuperseded
v334 patches33 repliesSuperseded
v213 patches17 repliesSuperseded
v113 patches22 repliesSuperseded

Changes in v17 from the cover letter

https://lore.kernel.org/lkml/[email protected]/
* Introduced the ACTION_{SUBTREE,CONTINUE,AGAIN} concept suggested by Thomas Hellström
* Reworked the KASAN support to avoid the need for test_p?d() callbacks by using ACTION_CONTINUE instead
* powerpc: Use p?d_is_leaf rather than adding new functions
* Simplify x86 changes by leaving ptdump_walk_pgd_level_core() taking a pgd

Patches in v17 All 23 applied

#Subject and filesSizeRepliesApplied
1/23mm: Add generic p?d_leaf() macrosinclude/asm-generic/pgtable.h+20 -03 repliesApplied
2/23arc: mm: Add p?d_leaf() definitionsarch/arc/include/asm/pgtable.h+1 -00 repliesApplied
3/23arm: mm: Add p?d_leaf() definitionsarch/arm/include/asm/pgtable-2level.h arch/arm/include/asm/pgtable-3level.h+2 -00 repliesApplied
4/23arm64: mm: Add p?d_leaf() definitionsarch/arm64/include/asm/pgtable.h+2 -00 repliesApplied
5/23mips: mm: Add p?d_leaf() definitionsarch/mips/include/asm/pgtable.h+5 -00 repliesApplied
6/23powerpc: mm: Add p?d_leaf() definitionsarch/powerpc/include/asm/book3s/64/pgtable.h+3 -02 repliesApplied
7/23riscv: mm: Add p?d_leaf() definitionsarch/riscv/include/asm/pgtable-64.h arch/riscv/include/asm/pgtable.h+14 -00 repliesApplied
8/23s390: mm: Add p?d_leaf() definitionsarch/s390/include/asm/pgtable.h+2 -00 repliesApplied
9/23sparc: mm: Add p?d_leaf() definitionsarch/sparc/include/asm/pgtable_64.h+2 -00 repliesApplied
10/23x86: mm: Add p?d_leaf() definitionsarch/x86/include/asm/pgtable.h+5 -00 repliesApplied
11/23mm: pagewalk: Add p4d_entry() and pgd_entry()include/linux/pagewalk.h mm/hmm.c mm/pagewalk.c+94 -452 repliesApplied
12/23mm: pagewalk: Allow walking without vmainclude/linux/pagewalk.h mm/pagewalk.c+37 -80 repliesApplied
13/23mm: pagewalk: Don't lock PTEs for walk_page_range_novma()mm/pagewalk.c+28 -70 repliesApplied
14/23mm: pagewalk: fix termination condition in walk_pte_range()mm/pagewalk.c+2 -20 repliesApplied
15/23mm: pagewalk: Add 'depth' parameter to pte_holefs/proc/task_mmu.c include/linux/pagewalk.h mm/hmm.c +3 more+40 -160 repliesApplied
16/23x86: mm: Point to struct seq_file from struct pg_statearch/x86/mm/dump_pagetables.c+35 -340 repliesApplied
17/23x86: mm+efi: Convert ptdump_walk_pgd_level() to take a mm_structarch/x86/include/asm/pgtable.h arch/x86/mm/dump_pagetables.c arch/x86/platform/efi/efi_32.c +1 more+6 -60 repliesApplied
18/23x86: mm: Convert ptdump_walk_pgd_level_debugfs() to take an mm_structarch/x86/include/asm/pgtable.h arch/x86/mm/debug_pagetables.c arch/x86/mm/dump_pagetables.c+12 -130 repliesApplied
19/23mm: Add generic ptdumpinclude/linux/ptdump.h mm/Kconfig.debug mm/Makefile +1 more+182 -00 repliesApplied
20/23x86: mm: Convert dump_pagetables to use walk_page_rangearch/x86/Kconfig arch/x86/Kconfig.debug arch/x86/mm/Makefile +1 more+70 -2470 repliesApplied
21/23arm64: mm: Convert mm/dump.c to use walk_page_range()arch/arm64/Kconfig arch/arm64/Kconfig.debug arch/arm64/include/asm/ptdump.h +5 more+50 -1073 repliesApplied
22/23arm64: mm: Display non-present entries in ptdumparch/arm64/mm/dump.c+13 -120 repliesApplied
23/23mm: ptdump: Reduce level numbers by 1 in note_page()arch/arm64/mm/dump.c arch/x86/mm/dump_pagetables.c include/linux/ptdump.h +1 more+22 -200 repliesApplied

Reviews trailers per patch

11 of 23 patches have a Reviewed-by or Acked-by.

PatchDavid S. MillerMark RutlandVineet GuptaCatalin MarinasPaul BurtonAlexandre GhitiZong LiPaul WalmsleyMichael EllermanThomas Hellstrom
1/23A-b
2/23A-b
3/23
4/23A-b
5/23A-b
6/23A-b
7/23R-b R-b A-b
8/23
9/23A-b
10/23
11/23R-b
12/23
13/23
14/23
15/23T-b
16/23
17/23
18/23
19/23
20/23
21/23R-b
22/23A-b
23/23R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 10 reviewers.

Read the v17 thread

Cover letter [PATCH v17 00/23] Generic page walk and ptdump

This version is two patches lighter than v16:
mm: pagewalk: Add test_p?d callbacks
x86: mm: Convert ptdump_walk_pgd_level_core() to take an mm_struct

There is a new enum page_walk_action in struct mm_walk which allows the callbacks to decide whether to recurse (ACTION_SUBTREE - the default), skip (ACTION_CONTINUE) or to be called again (ACTION_AGAIN). These are introduced in patch 11 and used for hmm.c to adapt it to the new behaviour of the pud_entry() callback.

The new page_walk_action means that we no longer need to test_p?d() callbacks as the p?d_entry() callbacks can simply return ACTION_CONTINUE to skip parts of the tree.

The x86 patch is dropped because I've updated patch 20 to always use a 'fake_mm' structure which simplifies the code and avoids issues with potentially double locking the mmap_sem of the real mm.

Previous description for the series
-----------------------------------

Many architectures current have a debugfs file for dumping the kernel page tables. Currently each architecture has to implement custom functions for this because the details of walking the page tables used by the kernel are different between architectures.

This series extends the capabilities of walk_page_range() so that it can deal with the page tables of the kernel (which have no VMAs and can contain larger huge pages than exist for user space). A generic PTDUMP implementation is the implemented making use of the new functionality of walk_page_range() and finally arm64 and x86 are switch to using it, removing the custom table walkers.

To enable a generic page table walker to walk the unusual mappings of the kernel we need to implement a set of functions which let us know when the walker has reached the leaf entry. After a suggestion from Will Deacon I've chosen the name p?d_leaf() as this (hopefully) describes the purpose (and is a new name so has no historic baggage). Some architectures have p?d_large macros but this is easily confused with "large pages".

This series ends with a generic PTDUMP implemention for arm64 and x86.

Mostly this is a clean up and there should be very little functional change. The exceptions are:

* arm64 PTDUMP debugfs now displays pages which aren't present (patch 22).

* arm64 has the ability to efficiently process KASAN pages (which previously only x86 implemented). This means that the combination of KASAN and DEBUG_WX is now useable.

Also available as a git tree:
git://linux-arm.org/linux-sp.git walk_page_range/v17

Changes since v16:
https://lore.kernel.org/lkml/[email protected]/
* Introduced the ACTION_{SUBTREE,CONTINUE,AGAIN} concept suggested by Thomas Hellström
* Reworked the KASAN support to avoid the need for test_p?d() callbacks by using ACTION_CONTINUE instead
* powerpc: Use p?d_is_leaf rather than adding new functions
* Simplify x86 changes by leaving ptdump_walk_pgd_level_core() taking a pgd

Changes since v15:
https://lore.kernel.org/lkml/[email protected]/
* Rebased onto Linus' tree, which includes the conflicting commit:
ace88f1018b8 ("mm: pagewalk: Take the pagetable lock in walk_pte_range()")
* New patch fixing conflict with above patch
* Squashed in fix for ordering of "static const"
* Squashed in fix checking p*d_present()
* New patch fixing termination condition for walk_pte_range()

Changes since v14:
https://lore.kernel.org/lkml/[email protected]/
* Switch walk_page_range() into two functions, the existing walk_page_range() now still requires VMAs (and treats areas without a VMA as a 'hole'). The new walk_page_range_novma() ignores VMAs and will report the actual page table layout. This fixes the previous breakage of /proc/<pid>/pagemap
* New patch at the end of the series which reduces the 'level' numbers by 1 to simplify the code slightly
* Added tags

Changes since v13:
https://lore.kernel.org/lkml/[email protected]/
* Fixed typo in arc definition of pmd_leaf() spotted by the kbuild test robot
* Added tags

Changes since v12:
https://lore.kernel.org/lkml/[email protected]/
* Correct code format in riscv pud_leaf()/pmd_leaf()
* v12 may not have reached everyone because of mail server problems (which are now hopefully resolved!)

Changes since v11:
https://lore.kernel.org/lkml/[email protected]/
* Use "-1" as dummy depth parameter in patch 14.

Changes since v10:
https://lore.kernel.org/lkml/[email protected]/
* Rebased to v5.4-rc1 - mainly various updates to deal with the splitting out of ops from struct mm_walk.
* Deal with PGD_LEVEL_MULT not always being constant on x86.

Changes since v9:
https://lore.kernel.org/lkml/[email protected]/
* Moved generic macros to first page in the series and explained the macro naming in the commit message.
* mips: Moved macros to pgtable.h as they are now valid for both 32 and 64 bit
* x86: Dropped patch which changed the debugfs output for x86, instead we have...
* new patch adding 'depth' parameter to pte_hole. This is used to provide the necessary information to output lines for 'holes' in the debugfs files
* new patch changing arm64 debugfs output to include holes to match x86
* generic ptdump KASAN handling has been simplified and now works with CONFIG_DEBUG_VIRTUAL.

Changes since v8:
https://lore.kernel.org/lkml/[email protected]/
* Rename from p?d_large() to p?d_leaf()
* Dropped patches migrating arm64/x86 custom walkers to walk_page_range() in favour of adding a generic PTDUMP implementation and migrating arm64/x86 to that instead.
* Rebased to v5.3-rc1

Steven Price (23):
mm: Add generic p?d_leaf() macros
arc: mm: Add p?d_leaf() definitions
arm: mm: Add p?d_leaf() definitions
arm64: mm: Add p?d_leaf() definitions
mips: mm: Add p?d_leaf() definitions
powerpc: mm: Add p?d_leaf() definitions
riscv: mm: Add p?d_leaf() definitions
s390: mm: Add p?d_leaf() definitions
sparc: mm: Add p?d_leaf() definitions
x86: mm: Add p?d_leaf() definitions
mm: pagewalk: Add p4d_entry() and pgd_entry()
mm: pagewalk: Allow walking without vma
mm: pagewalk: Don't lock PTEs for walk_page_range_novma()
mm: pagewalk: fix termination condition in walk_pte_range()
mm: pagewalk: Add 'depth' parameter to pte_hole
x86: mm: Point to struct seq_file from struct pg_state
x86: mm+efi: Convert ptdump_walk_pgd_level() to take a mm_struct
x86: mm: Convert ptdump_walk_pgd_level_debugfs() to take an mm_struct
mm: Add generic ptdump
x86: mm: Convert dump_pagetables to use walk_page_range
arm64: mm: Convert mm/dump.c to use walk_page_range()
arm64: mm: Display non-present entries in ptdump
mm: ptdump: Reduce level numbers by 1 in note_page()

 arch/arc/include/asm/pgtable.h               |   1 +
 arch/arm/include/asm/pgtable-2level.h        |   1 +
 arch/arm/include/asm/pgtable-3level.h        |   1 +
 arch/arm64/Kconfig                           |   1 +
 arch/arm64/Kconfig.debug                     |  19 +-
 arch/arm64/include/asm/pgtable.h             |   2 +
 arch/arm64/include/asm/ptdump.h              |   8 +-
 arch/arm64/mm/Makefile                       |   4 +-
 arch/arm64/mm/dump.c                         | 148 ++++-----
 arch/arm64/mm/mmu.c                          |   4 +-
 arch/arm64/mm/ptdump_debugfs.c               |   2 +-
 arch/mips/include/asm/pgtable.h              |   5 +
 arch/powerpc/include/asm/book3s/64/pgtable.h |   3 +
 arch/riscv/include/asm/pgtable-64.h          |   7 +
 arch/riscv/include/asm/pgtable.h             |   7 +
 arch/s390/include/asm/pgtable.h              |   2 +
 arch/sparc/include/asm/pgtable_64.h          |   2 +
 arch/x86/Kconfig                             |   1 +
 arch/x86/Kconfig.debug                       |  20 +-
 arch/x86/include/asm/pgtable.h               |  10 +-
 arch/x86/mm/Makefile                         |   4 +-
 arch/x86/mm/debug_pagetables.c               |   8 +-
 arch/x86/mm/dump_pagetables.c                | 320 +++++--------------
 arch/x86/platform/efi/efi_32.c               |   2 +-
 arch/x86/platform/efi/efi_64.c               |   4 +-
 drivers/firmware/efi/arm-runtime.c           |   2 +-
 fs/proc/task_mmu.c                           |   4 +-
 include/asm-generic/pgtable.h                |  20 ++
 include/linux/pagewalk.h                     |  46 ++-
 include/linux/ptdump.h                       |  22 ++
 mm/Kconfig.debug                             |  21 ++
 mm/Makefile                                  |   1 +
 mm/hmm.c                                     |  59 ++--
 mm/migrate.c                                 |   5 +-
 mm/mincore.c                                 |   1 +
 mm/pagewalk.c                                | 156 ++++++---
 mm/ptdump.c                                  | 139 ++++++++
 37 files changed, 596 insertions(+), 466 deletions(-)
 create mode 100644 include/linux/ptdump.h
 create mode 100644 mm/ptdump.c
Signature · 1 line
2.20.1