linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] madvise cleanup
@ 2025-06-19 20:26 Lorenzo Stoakes
  2025-06-19 20:26 ` [PATCH 1/5] mm/madvise: remove the visitor pattern and thread anon_vma state Lorenzo Stoakes
                   ` (4 more replies)
  0 siblings, 5 replies; 29+ messages in thread
From: Lorenzo Stoakes @ 2025-06-19 20:26 UTC (permalink / raw)
  To: Andrew Morton
  Cc: David Hildenbrand, Zi Yan, Baolin Wang, Liam R . Howlett,
	Nico Pache, Ryan Roberts, Dev Jain, Barry Song, Vlastimil Babka,
	Jann Horn, linux-mm, linux-kernel, Lance Yang, SeongJae Park,
	Suren Baghdasaryan

This is a series of patches that helps address a number of historic
problems in the madvise() implementation:

* Eliminate the visitor pattern and having the code which is implemented
  for both the anon_vma_name implementation and ordinary madvise()
  operations use the same madvise_vma_behavior() implementation.

* Thread state through the madvise_behavior state object - this object,
  very usefully introduced by SJ, is already used to transmit state through
  operations. This series extends this by having all madvise() operations
  use this, including anon_vma_name.

* Thread range, VMA state through madvise_behavior - This helps avoid a lot
  of the confusing code around range and VMA state and again keeps things
  consistent and with a single 'source of truth'.

* Addressing the very strange behaviour around the passed around struct
  vm_area_struct **prev pointer - all read-only users do absolutely nothing
  with the prev pointer. The only function that uses it is
  madvise_update_vma(), and in all cases prev is always reset to
  VMA.

  Fix this by no longer having aything but madvise_update_vma() reference
  prev, and having madvise_walk_vmas() update prev in each
  instance. Additionally make it clear that the meaningful change in vma
  state is when madvise_update_vma() potentially merges a VMA, so
  explicitly retrieve the VMA in this case.

* Update and clarify the madvise_walk_vmas() function - this is a source of
  a great deal of confusion, so simplify, stop using prev = NULL to signify
  that the mmap lock has been dropped (!) and make that explicit, and add
  some comments to explain what's going on.

Lorenzo Stoakes (5):
  mm/madvise: remove the visitor pattern and thread anon_vma state
  mm/madvise: thread mm_struct through madvise_behavior
  mm/madvise: thread VMA range state through madvise_behavior
  mm/madvise: thread all madvise state through madv_behavior
  mm/madvise: eliminate very confusing manipulation of prev VMA

 include/linux/huge_mm.h |   9 +-
 mm/khugepaged.c         |   9 +-
 mm/madvise.c            | 569 +++++++++++++++++++++-------------------
 3 files changed, 309 insertions(+), 278 deletions(-)

--
2.49.0

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

end of thread, other threads:[~2025-06-20 15:02 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-19 20:26 [PATCH 0/5] madvise cleanup Lorenzo Stoakes
2025-06-19 20:26 ` [PATCH 1/5] mm/madvise: remove the visitor pattern and thread anon_vma state Lorenzo Stoakes
2025-06-20  1:32   ` Zi Yan
2025-06-20  2:43     ` Lance Yang
2025-06-20  5:10       ` Lorenzo Stoakes
2025-06-20  5:08     ` Lorenzo Stoakes
2025-06-20 13:05   ` Vlastimil Babka
2025-06-20 13:17     ` Lorenzo Stoakes
2025-06-19 20:26 ` [PATCH 2/5] mm/madvise: thread mm_struct through madvise_behavior Lorenzo Stoakes
2025-06-20  1:40   ` Zi Yan
2025-06-20  5:12     ` Lorenzo Stoakes
2025-06-20 13:19   ` Vlastimil Babka
2025-06-19 20:26 ` [PATCH 3/5] mm/madvise: thread VMA range state " Lorenzo Stoakes
2025-06-20  1:54   ` Zi Yan
2025-06-20  2:13     ` Zi Yan
2025-06-20  5:21       ` Lorenzo Stoakes
2025-06-20  5:17     ` Lorenzo Stoakes
2025-06-20 13:49   ` Vlastimil Babka
2025-06-20 13:51     ` Lorenzo Stoakes
2025-06-20 14:16     ` Lorenzo Stoakes
2025-06-19 20:26 ` [PATCH 4/5] mm/madvise: thread all madvise state through madv_behavior Lorenzo Stoakes
2025-06-20  2:20   ` Zi Yan
2025-06-20  5:21     ` Lorenzo Stoakes
2025-06-20 14:16   ` Vlastimil Babka
2025-06-20 14:17     ` Lorenzo Stoakes
2025-06-20 14:32   ` Vlastimil Babka
2025-06-20 14:58     ` Lorenzo Stoakes
2025-06-19 20:26 ` [PATCH 5/5] mm/madvise: eliminate very confusing manipulation of prev VMA Lorenzo Stoakes
2025-06-20 15:02   ` Vlastimil Babka

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).