Skip to content

mm: Page fault accounting cleanups

Peter Xu linux-alpha linux-arm-kernel linux-csky linux-hexagon linux-m68k linux-mips linux-mm linux-parisc linux-riscv linux-s390 linux-sh linux-snps-arc linuxppc-dev lkml openrisc sparclinux 3 versions – Applied

Status from this message: [merged] mm-gup-remove-task_struct-pointer-for-all-gup-code.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest25 patches 2 repliesApplied 25/25
  2. v426 patches 15 repliesSuperseded
  3. v126 patches 8 repliesSuperseded

Changes in v5 from the cover letter

- rebase to linux-next/akpm, add r-bs
- patch 1: pass vm_fault_t into mm_account_fault() [DavidR]
- patch 25: fix comment in get_user_pages() to remove the ref to task [John]
- dropped the unicore32 patch because the arch was thrown away

Patches in v5 All 25 applied

#Subject and filesSizeRepliesApplied
1/25mm: Do page fault accounting in handle_mm_faultarch/alpha/mm/fault.c arch/arc/mm/fault.c arch/arm/mm/fault.c +28 more+103 -340 repliesApplied
2/25mm/alpha: Use general page fault accountingarch/alpha/mm/fault.c+3 -50 repliesApplied
3/25mm/arc: Use general page fault accountingarch/arc/mm/fault.c+3 -150 repliesApplied
4/25mm/arm: Use general page fault accountingarch/arm/mm/fault.c+6 -190 repliesApplied
5/25mm/arm64: Use general page fault accountingarch/arm64/mm/fault.c+6 -230 repliesApplied
6/25mm/csky: Use general page fault accountingarch/csky/mm/fault.c+1 -110 repliesApplied
7/25mm/hexagon: Use general page fault accountingarch/hexagon/mm/vm_fault.c+4 -50 repliesApplied
8/25mm/ia64: Use general page fault accountingarch/ia64/mm/fault.c+4 -50 repliesApplied
9/25mm/m68k: Use general page fault accountingarch/m68k/mm/fault.c+4 -100 repliesApplied
10/25mm/microblaze: Use general page fault accountingarch/microblaze/mm/fault.c+4 -50 repliesApplied
11/25mm/mips: Use general page fault accountingarch/mips/mm/fault.c+3 -110 repliesApplied
12/25mm/nds32: Use general page fault accountingarch/nds32/mm/fault.c+3 -160 repliesApplied
13/25mm/nios2: Use general page fault accountingarch/nios2/mm/fault.c+4 -100 repliesApplied
14/25mm/openrisc: Use general page fault accountingarch/openrisc/mm/fault.c+4 -50 repliesApplied
15/25mm/parisc: Use general page fault accountingarch/parisc/mm/fault.c+3 -50 repliesApplied
16/25mm/powerpc: Use general page fault accountingarch/powerpc/mm/fault.c+3 -80 repliesApplied
17/25mm/riscv: Use general page fault accountingarch/riscv/mm/fault.c+1 -150 repliesApplied
18/25mm/s390: Use general page fault accountingarch/s390/mm/fault.c+1 -152 repliesApplied
19/25mm/sh: Use general page fault accountingarch/sh/mm/fault.c+1 -100 repliesApplied
20/25mm/sparc32: Use general page fault accountingarch/sparc/mm/fault_32.c+1 -100 repliesApplied
21/25mm/sparc64: Use general page fault accountingarch/sparc/mm/fault_64.c+1 -100 repliesApplied
22/25mm/x86: Use general page fault accountingarch/x86/mm/fault.c+2 -150 repliesApplied
23/25mm/xtensa: Use general page fault accountingarch/xtensa/mm/fault.c+4 -110 repliesApplied
24/25mm: Clean up the last pieces of page fault accountingsarch/powerpc/mm/copro_fault.c arch/um/kernel/trap.c mm/gup.c +1 more+10 -290 repliesApplied
25/25mm/gup: Remove task_struct pointer for all gup codearch/arc/kernel/process.c arch/s390/kvm/interrupt.c arch/s390/kvm/kvm-s390.c +15 more+69 -870 repliesApplied

Reviews trailers per patch

13 of 25 patches have a Reviewed-by or Acked-by.

PatchBrian CainDavid S. MillerWill DeaconGuo RenThomas BogendoerferGreentime HuStafford HorneGerald SchaeferMichael EllermanPekka EnbergMax FilippovJohn Hubbard
1/25
2/25
3/25
4/25
5/25A-b
6/25A-b
7/25A-b
8/25
9/25
10/25
11/25A-b
12/25A-b
13/25
14/25A-b
15/25
16/25A-b
17/25R-b
18/25R-b A-b
19/25
20/25A-b
21/25A-b
22/25
23/25A-b
24/25
25/25R-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 12 reviewers.

Read the v5 thread

Cover letter [PATCH v5 00/25] mm: Page fault accounting cleanups

v5:
- rebase to linux-next/akpm, add r-bs
- patch 1: pass vm_fault_t into mm_account_fault() [DavidR]
- patch 25: fix comment in get_user_pages() to remove the ref to task [John]
- dropped the unicore32 patch because the arch was thrown away

This is v5 of the pf accounting cleanup series. It originates from Gerald Schaefer's report on an issue a week ago regarding to incorrect page fault accountings for retried page fault after commit 4064b9827063 ("mm: allow VM_FAULT_RETRY for multiple times"):

https://lore.kernel.org/lkml/20200610174811.44b94525@thinkpad/

What this series did:

- Correct page fault accounting: we do accounting for a page fault (no matter whether it's from #PF handling, or gup, or anything else) only with the one that completed the fault. For example, page fault retries should not be counted in page fault counters. Same to the perf events.

- Unify definition of PERF_COUNT_SW_PAGE_FAULTS: currently this perf event is used in an adhoc way across different archs.

Case (1): for many archs it's done at the entry of a page fault handler, so that it will also cover e.g. errornous faults.

Case (2): for some other archs, it is only accounted when the page fault is resolved successfully.

Case (3): there're still quite some archs that have not enabled this perf event.

Since this series will touch merely all the archs, we unify this perf event to always follow case (1), which is the one that makes most sense. And since we moved the accounting into handle_mm_fault, the other two MAJ/MIN perf events are well taken care of naturally.

- Unify definition of "major faults": the definition of "major fault" is slightly changed when used in accounting (not VM_FAULT_MAJOR). More information in patch 1.

- Always account the page fault onto the one that triggered the page fault. This does not matter much for #PF handlings, but mostly for gup. More information on this in patch 25.

Patchset layout:

Patch 1:     Introduced the accounting in handle_mm_fault(), not enabled.
Patch 2-23:  Enable the new accounting for arch #PF handlers one by one.
Patch 24:    Enable the new accounting for the rest outliers (gup, iommu, etc.)
Patch 25:    Cleanup GUP task_struct pointer since it's not needed any more

For each of the patch that fixes a specific arch, I'm CCing the maintainers and the arch list if there is. Besides, I only lightly tested this series on x86.

Please have a look, thanks.

Peter Xu (25):
mm: Do page fault accounting in handle_mm_fault mm/alpha: Use general page fault accounting mm/arc: Use general page fault accounting mm/arm: Use general page fault accounting mm/arm64: Use general page fault accounting mm/csky: Use general page fault accounting mm/hexagon: Use general page fault accounting mm/ia64: Use general page fault accounting mm/m68k: Use general page fault accounting mm/microblaze: Use general page fault accounting mm/mips: Use general page fault accounting mm/nds32: Use general page fault accounting mm/nios2: Use general page fault accounting mm/openrisc: Use general page fault accounting mm/parisc: Use general page fault accounting mm/powerpc: Use general page fault accounting mm/riscv: Use general page fault accounting mm/s390: Use general page fault accounting mm/sh: Use general page fault accounting mm/sparc32: Use general page fault accounting mm/sparc64: Use general page fault accounting mm/x86: Use general page fault accounting mm/xtensa: Use general page fault accounting
mm: Clean up the last pieces of page fault accountings mm/gup: Remove task_struct pointer for all gup code

 arch/alpha/mm/fault.c                       |   8 +-
 arch/arc/kernel/process.c                   |   2 +-
 arch/arc/mm/fault.c                         |  18 +--
 arch/arm/mm/fault.c                         |  25 +----
 arch/arm64/mm/fault.c                       |  29 +----
 arch/csky/mm/fault.c                        |  13 +--
 arch/hexagon/mm/vm_fault.c                  |   9 +-
 arch/ia64/mm/fault.c                        |   9 +-
 arch/m68k/mm/fault.c                        |  14 +--
 arch/microblaze/mm/fault.c                  |   9 +-
 arch/mips/mm/fault.c                        |  14 +--
 arch/nds32/mm/fault.c                       |  19 +---
 arch/nios2/mm/fault.c                       |  14 +--
 arch/openrisc/mm/fault.c                    |   9 +-
 arch/parisc/mm/fault.c                      |   8 +-
 arch/powerpc/mm/copro_fault.c               |   7 +-
 arch/powerpc/mm/fault.c                     |  11 +-
 arch/riscv/mm/fault.c                       |  16 +--
 arch/s390/kvm/interrupt.c                   |   2 +-
 arch/s390/kvm/kvm-s390.c                    |   2 +-
 arch/s390/kvm/priv.c                        |   8 +-
 arch/s390/mm/fault.c                        |  16 +--
 arch/s390/mm/gmap.c                         |   4 +-
 arch/sh/mm/fault.c                          |  11 +-
 arch/sparc/mm/fault_32.c                    |  13 +--
 arch/sparc/mm/fault_64.c                    |  11 +-
 arch/um/kernel/trap.c                       |   6 +-
 arch/x86/mm/fault.c                         |  17 +--
 arch/xtensa/mm/fault.c                      |  15 +--
 drivers/gpu/drm/i915/gem/i915_gem_userptr.c |   2 +-
 drivers/infiniband/core/umem_odp.c          |   2 +-
 drivers/iommu/amd/iommu_v2.c                |   2 +-
 drivers/iommu/intel/svm.c                   |   3 +-
 drivers/vfio/vfio_iommu_type1.c             |   4 +-
 fs/exec.c                                   |   2 +-
 include/linux/mm.h                          |  16 +--
 kernel/events/uprobes.c                     |   6 +-
 kernel/futex.c                              |   2 +-
 mm/gup.c                                    | 118 ++++++++------------
 mm/hmm.c                                    |   3 +-
 mm/ksm.c                                    |   3 +-
 mm/memory.c                                 |  69 +++++++++++-
 mm/process_vm_access.c                      |   2 +-
 security/tomoyo/domain.c                    |   2 +-
 virt/kvm/async_pf.c                         |   2 +-
 virt/kvm/kvm_main.c                         |   2 +-
 46 files changed, 219 insertions(+), 360 deletions(-)
Signature · 1 line
2.26.2