linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC 0/3] mm: clarify folio_add_new_anon_rmap() and __folio_add_anon_rmap()
@ 2024-06-13  0:07 Barry Song
  2024-06-13  0:07 ` [PATCH RFC 1/3] mm: extend rmap flags arguments for folio_add_new_anon_rmap Barry Song
                   ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Barry Song @ 2024-06-13  0:07 UTC (permalink / raw)
  To: david, akpm, linux-mm
  Cc: chrisl, linux-kernel, mhocko, ryan.roberts, baolin.wang,
	yosryahmed, shy828301, surenb, v-songbaohua, willy, ying.huang,
	yuzhao

From: Barry Song <v-songbaohua@oppo.com>

The whole thing was originally suggested by David while we tried
to weaken the WARN_ON in __folio_add_anon_rmap() while bringing up
mTHP swapin[1]. This patchset is also preparatory work for mTHP
swapin.

folio_add_new_anon_rmap() assumes that new anon rmaps are always
exclusive. However, this assumption doesn’t hold true for cases
like do_swap_page(), where a new anon might be added to the
swapcache and is not necessarily exclusive.

The patchset extends the rmap flags to allow folio_add_new_anon_rmap()
to handle both exclusive and non-exclusive new anon folios.
The do_swap_page() function is updated to use this extended API with
rmap flags. Consequently, all new anon folios now consistently use
folio_add_new_anon_rmap().
The special case for !folio_test_anon() in __folio_add_anon_rmap() can
be safely removed.

In conclusion, new anon folios always use folio_add_new_anon_rmap(),
regardless of exclusivity. Old anon folios continue to use
__folio_add_anon_rmap() via folio_add_anon_rmap_pmd() and
folio_add_anon_rmap_ptes().

[1] https://lore.kernel.org/linux-mm/20240118111036.72641-6-21cnbao@gmail.com/

Barry Song (3):
  mm: extend rmap flags arguments for folio_add_new_anon_rmap
  mm: do_swap_page: use folio_add_new_anon_rmap() if
    folio_test_anon(folio)==false
  mm: remove folio_test_anon(folio)==false path in
    __folio_add_anon_rmap()

 include/linux/rmap.h    |  2 +-
 kernel/events/uprobes.c |  2 +-
 mm/huge_memory.c        |  2 +-
 mm/khugepaged.c         |  2 +-
 mm/memory.c             | 12 +++++++-----
 mm/migrate_device.c     |  2 +-
 mm/rmap.c               | 32 ++++++++++++--------------------
 mm/swapfile.c           |  2 +-
 mm/userfaultfd.c        |  2 +-
 9 files changed, 26 insertions(+), 32 deletions(-)

-- 
2.34.1



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

end of thread, other threads:[~2024-06-14 22:51 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-13  0:07 [PATCH RFC 0/3] mm: clarify folio_add_new_anon_rmap() and __folio_add_anon_rmap() Barry Song
2024-06-13  0:07 ` [PATCH RFC 1/3] mm: extend rmap flags arguments for folio_add_new_anon_rmap Barry Song
2024-06-13  8:39   ` Barry Song
2024-06-13  0:07 ` [PATCH RFC 2/3] mm: do_swap_page: use folio_add_new_anon_rmap() if folio_test_anon(folio)==false Barry Song
2024-06-13  9:23   ` David Hildenbrand
2024-06-13  9:58     ` Barry Song
2024-06-13 10:37       ` David Hildenbrand
2024-06-13 10:55         ` Barry Song
2024-06-13  0:07 ` [PATCH RFC 3/3] mm: remove folio_test_anon(folio)==false path in __folio_add_anon_rmap() Barry Song
2024-06-13  8:46   ` Barry Song
2024-06-13  8:49     ` David Hildenbrand
2024-06-13  9:06       ` Barry Song
2024-06-13  9:12         ` David Hildenbrand
2024-06-14  7:56           ` Barry Song
2024-06-14  8:51             ` David Hildenbrand
2024-06-14  8:56               ` Barry Song
2024-06-14  8:58                 ` Barry Song
2024-06-14  9:04                   ` David Hildenbrand
2024-06-14  9:33                     ` Barry Song
2024-06-14 11:10                       ` David Hildenbrand
2024-06-14 22:24                         ` Barry Song

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