linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/26] mm: Page fault accounting cleanups
@ 2020-06-19 16:05 Peter Xu
  2020-06-19 16:05 ` [PATCH 01/26] mm: Do page fault accounting in handle_mm_fault Peter Xu
                   ` (25 more replies)
  0 siblings, 26 replies; 38+ messages in thread
From: Peter Xu @ 2020-06-19 16:05 UTC (permalink / raw)
  To: linux-kernel, linux-mm
  Cc: Gerald Schaefer, peterx, Andrew Morton, Andrea Arcangeli,
	Will Deacon, Michael Ellerman, Linus Torvalds

(Forgot to cc mm list on v1; adding in)

This is v2 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/

This version used a better approach suggested by Linus so that we do accounting
directly in handle_mm_fault().  Moreover, we'll cover some special accounting
too like gup or IOMMU fault requests on process page tables.  The outcome of
this series is to keep all the pf accountings in handle_mm_fault() (besides
PERF_COUNT_SW_PAGE_FAULTS, which is still done in per-arch #pf handlers).

Since v2 changed quite a lot from v1, changelog is omitted, and I also didn't
have a chance to pick up any r-b in previous version.  I really appreciate
anyone who has looked at v1.  V1 for reference:

  https://lore.kernel.org/lkml/20200615221607.7764-1-peterx@redhat.com/

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-24:  Enable the new accounting for arch #PF handlers one by one.
Patch 25:    Enable the new accounting for the rest outliers (gup, iommu, etc.)
Patch 26:    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 (26):
  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/unicore32: 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/unicore32/mm/fault.c                   |  14 +--
 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                   |   2 +-
 drivers/vfio/vfio_iommu_type1.c             |   2 +-
 fs/exec.c                                   |   2 +-
 include/linux/mm.h                          |  16 +--
 kernel/events/uprobes.c                     |   6 +-
 kernel/futex.c                              |   2 +-
 mm/gup.c                                    | 107 +++++++-------------
 mm/hmm.c                                    |   3 +-
 mm/ksm.c                                    |   3 +-
 mm/memory.c                                 |  72 ++++++++++++-
 mm/process_vm_access.c                      |   2 +-
 security/tomoyo/domain.c                    |   2 +-
 virt/kvm/async_pf.c                         |   2 +-
 virt/kvm/kvm_main.c                         |   2 +-
 47 files changed, 222 insertions(+), 360 deletions(-)

-- 
2.26.2



^ permalink raw reply	[flat|nested] 38+ messages in thread
* [PATCH 00/26] mm: Page fault accounting cleanups
@ 2020-06-26 22:31 Peter Xu
  2020-06-26 22:36 ` [PATCH 15/26] mm/parisc: Use general page fault accounting Peter Xu
  0 siblings, 1 reply; 38+ messages in thread
From: Peter Xu @ 2020-06-26 22:31 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: Andrew Morton, Linus Torvalds, Gerald Schaefer, Andrea Arcangeli,
	Will Deacon, peterx, Michael Ellerman

v3:
- comment fixes [Gerald]
- check VM_FAULT_ERROR too [Gerald]
- collect r-b

==================== cover letter for v2 =============================

This is v2 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/

This version used a better approach suggested by Linus so that we do accounting
directly in handle_mm_fault().  Moreover, we'll cover some special accounting
too like gup or IOMMU fault requests on process page tables.  The outcome of
this series is to keep all the pf accountings in handle_mm_fault() (besides
PERF_COUNT_SW_PAGE_FAULTS, which is still done in per-arch #pf handlers).

Since v2 changed quite a lot from v1, changelog is omitted, and I also didn't
have a chance to pick up any r-b in previous version.  I really appreciate
anyone who has looked at v1.  V1 for reference:

  https://lore.kernel.org/lkml/20200615221607.7764-1-peterx@redhat.com/

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-24:  Enable the new accounting for arch #PF handlers one by one.
Patch 25:    Enable the new accounting for the rest outliers (gup, iommu, etc.)
Patch 26:    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 (26):
  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/unicore32: 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/unicore32/mm/fault.c                   |  14 +--
 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                   |   2 +-
 drivers/vfio/vfio_iommu_type1.c             |   2 +-
 fs/exec.c                                   |   2 +-
 include/linux/mm.h                          |  16 +--
 kernel/events/uprobes.c                     |   6 +-
 kernel/futex.c                              |   2 +-
 mm/gup.c                                    | 107 +++++++-------------
 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 +-
 47 files changed, 219 insertions(+), 360 deletions(-)

-- 
2.26.2



^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2020-06-26 22:36 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-19 16:05 [PATCH 00/26] mm: Page fault accounting cleanups Peter Xu
2020-06-19 16:05 ` [PATCH 01/26] mm: Do page fault accounting in handle_mm_fault Peter Xu
2020-06-24 18:49   ` Gerald Schaefer
2020-06-24 20:34     ` Peter Xu
2020-06-26 19:54       ` Gerald Schaefer
2020-06-26 21:53         ` Peter Xu
2020-06-26 22:27           ` Peter Xu
2020-06-19 16:05 ` [PATCH 02/26] mm/alpha: Use general page fault accounting Peter Xu
2020-06-19 16:05 ` [PATCH 03/26] mm/arc: " Peter Xu
2020-06-19 16:05 ` [PATCH 04/26] mm/arm: " Peter Xu
2020-06-19 16:05 ` [PATCH 05/26] mm/arm64: " Peter Xu
2020-06-19 16:05 ` [PATCH 06/26] mm/csky: " Peter Xu
2020-06-20  1:44   ` Guo Ren
2020-06-20 16:08     ` Peter Xu
2020-06-19 16:05 ` [PATCH 07/26] mm/hexagon: " Peter Xu
2020-06-19 16:05 ` [PATCH 08/26] mm/ia64: " Peter Xu
2020-06-19 16:05 ` [PATCH 09/26] mm/m68k: " Peter Xu
2020-06-19 16:05 ` [PATCH 10/26] mm/microblaze: " Peter Xu
2020-06-19 16:05 ` [PATCH 11/26] mm/mips: " Peter Xu
2020-06-25  8:28   ` Thomas Bogendoerfer
2020-06-19 16:05 ` [PATCH 12/26] mm/nds32: " Peter Xu
2020-06-19 16:12 ` [PATCH 13/26] mm/nios2: " Peter Xu
2020-06-19 16:12 ` [PATCH 14/26] mm/openrisc: " Peter Xu
2020-06-19 16:13 ` [PATCH 15/26] mm/parisc: " Peter Xu
2020-06-19 16:13 ` [PATCH 16/26] mm/powerpc: " Peter Xu
2020-06-19 16:13 ` [PATCH 17/26] mm/riscv: " Peter Xu
2020-06-19 16:13 ` [PATCH 18/26] mm/s390: " Peter Xu
2020-06-24 18:49   ` Gerald Schaefer
2020-06-24 20:40     ` Peter Xu
2020-06-19 16:13 ` [PATCH 19/26] mm/sh: " Peter Xu
2020-06-19 16:13 ` [PATCH 20/26] mm/sparc32: " Peter Xu
2020-06-19 16:13 ` [PATCH 21/26] mm/sparc64: " Peter Xu
2020-06-19 16:13 ` [PATCH 22/26] mm/unicore32: " Peter Xu
2020-06-19 16:13 ` [PATCH 23/26] mm/x86: " Peter Xu
2020-06-19 16:13 ` [PATCH 24/26] mm/xtensa: " Peter Xu
2020-06-19 16:14 ` [PATCH 25/26] mm: Clean up the last pieces of page fault accountings Peter Xu
2020-06-19 16:14 ` [PATCH 26/26] mm/gup: Remove task_struct pointer for all gup code Peter Xu
2020-06-26 22:31 [PATCH 00/26] mm: Page fault accounting cleanups Peter Xu
2020-06-26 22:36 ` [PATCH 15/26] mm/parisc: Use general page fault accounting Peter Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).