linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/5] move per-vma lock into vm_area_struct
@ 2024-11-12 19:46 Suren Baghdasaryan
  2024-11-12 19:46 ` [PATCH v2 1/5] mm: introduce vma_start_read_locked{_nested} helpers Suren Baghdasaryan
                   ` (4 more replies)
  0 siblings, 5 replies; 39+ messages in thread
From: Suren Baghdasaryan @ 2024-11-12 19:46 UTC (permalink / raw)
  To: akpm
  Cc: willy, liam.howlett, lorenzo.stoakes, mhocko, vbabka, hannes,
	mjguzik, oliver.sang, mgorman, david, peterx, oleg, dave,
	paulmck, brauner, dhowells, hdanton, hughd, minchan, jannh,
	shakeel.butt, souravpanda, pasha.tatashin, linux-mm,
	linux-kernel, kernel-team, surenb

Back when per-vma locks were introduces, vm_lock was moved out of
vm_area_struct in [1] because of the performance regression caused by
false cacheline sharing. Recent investigation [2] revealed that the
regressions is limited to a rather old Broadwell microarchitecture and
even there it can be mitigated by disabling adjacent cacheline
prefetching, see [3].
This patchset moves vm_lock back into vm_area_struct, aligning it at the
cacheline boundary and changing the cache to be cache-aligned as well.
This causes VMA memory consumption to grow from 160 (vm_area_struct) + 40
(vm_lock) bytes to 256 bytes:

    slabinfo before:
     <name>           ... <objsize> <objperslab> <pagesperslab> : ...
     vma_lock         ...     40  102    1 : ...
     vm_area_struct   ...    160   51    2 : ...

    slabinfo after moving vm_lock:
     <name>           ... <objsize> <objperslab> <pagesperslab> : ...
     vm_area_struct   ...    256   32    2 : ...

Aggregate VMA memory consumption per 1000 VMAs grows from 50 to 64 pages,
which is 5.5MB per 100000 VMAs. This overhead will be addressed in a
separate patchset by replacing rw_semaphore in vma_lock's implementation
with a different type of lock.
Moving vm_lock into vm_area_struct lets us simplify vm_area_free() path,
which in turn allows us to use SLAB_TYPESAFE_BY_RCU for vm_area_struct
cache. This should facilitate vm_area_struct reuse and will minimize the
number of call_rcu() calls.

Suren Baghdasaryan (5):
  mm: introduce vma_start_read_locked{_nested} helpers
  mm: move per-vma lock into vm_area_struct
  mm: mark vma as detached until it's added into vma tree
  mm: make vma cache SLAB_TYPESAFE_BY_RCU
  docs/mm: document latest changes to vm_lock

 Documentation/mm/process_addrs.rst | 10 +++--
 include/linux/mm.h                 | 54 +++++++++++++++++-----
 include/linux/mm_types.h           | 16 ++++---
 include/linux/slab.h               |  6 ---
 kernel/fork.c                      | 72 +++++++-----------------------
 mm/memory.c                        |  2 +-
 mm/mmap.c                          |  2 +
 mm/nommu.c                         |  2 +
 mm/userfaultfd.c                   | 14 +++---
 mm/vma.c                           |  3 ++
 tools/testing/vma/vma_internal.h   |  3 +-
 11 files changed, 92 insertions(+), 92 deletions(-)


base-commit: 931086f2a88086319afb57cd3925607e8cda0a9f
-- 
2.47.0.277.g8800431eea-goog



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

end of thread, other threads:[~2024-12-05 15:23 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-12 19:46 [PATCH v2 0/5] move per-vma lock into vm_area_struct Suren Baghdasaryan
2024-11-12 19:46 ` [PATCH v2 1/5] mm: introduce vma_start_read_locked{_nested} helpers Suren Baghdasaryan
2024-11-13 14:10   ` Lorenzo Stoakes
2024-11-13 15:30     ` Suren Baghdasaryan
2024-11-12 19:46 ` [PATCH v2 2/5] mm: move per-vma lock into vm_area_struct Suren Baghdasaryan
2024-11-13 14:28   ` Lorenzo Stoakes
2024-11-13 14:45     ` Vlastimil Babka
2024-11-13 14:58       ` Lorenzo Stoakes
2024-11-13 15:09         ` Vlastimil Babka
2024-11-13 14:53     ` Mateusz Guzik
2024-11-13 14:59       ` Lorenzo Stoakes
2024-11-13 15:01     ` Lorenzo Stoakes
2024-11-13 15:45       ` Suren Baghdasaryan
2024-11-13 15:42     ` Suren Baghdasaryan
2024-11-12 19:46 ` [PATCH v2 3/5] mm: mark vma as detached until it's added into vma tree Suren Baghdasaryan
2024-11-13 14:43   ` Lorenzo Stoakes
2024-11-13 15:37     ` Suren Baghdasaryan
2024-11-12 19:46 ` [PATCH v2 4/5] mm: make vma cache SLAB_TYPESAFE_BY_RCU Suren Baghdasaryan
2024-11-13  2:57   ` Suren Baghdasaryan
2024-11-13  5:08     ` Hugh Dickins
2024-11-13  6:03       ` Suren Baghdasaryan
2024-11-13  6:52         ` Hugh Dickins
2024-11-13  8:19           ` Suren Baghdasaryan
2024-11-13  8:58   ` Vlastimil Babka
2024-11-13 12:38     ` Liam R. Howlett
2024-11-13 13:57       ` Matthew Wilcox
2024-11-13 15:22         ` Liam R. Howlett
2024-11-13 15:25           ` Suren Baghdasaryan
2024-11-13 15:29             ` Liam R. Howlett
2024-11-13 15:47               ` Suren Baghdasaryan
2024-11-13 19:05                 ` Suren Baghdasaryan
2024-11-14 16:18                   ` Suren Baghdasaryan
2024-11-14 16:21                     ` Vlastimil Babka
2024-11-13 16:44           ` Jann Horn
2024-11-13 20:59             ` Matthew Wilcox
2024-11-13 21:23               ` Jann Horn
2024-11-12 19:46 ` [PATCH v2 5/5] docs/mm: document latest changes to vm_lock Suren Baghdasaryan
2024-11-12 19:51   ` Suren Baghdasaryan
2024-11-13 14:46     ` Lorenzo Stoakes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox