From: Barry Song <21cnbao@gmail.com>
To: akpm@linux-foundation.org, david@redhat.com, linux-mm@kvack.org
Cc: baolin.wang@linux.alibaba.com, chrisl@kernel.org,
linux-kernel@vger.kernel.org, mhocko@suse.com,
ryan.roberts@arm.com, shy828301@gmail.com, surenb@google.com,
v-songbaohua@oppo.com, willy@infradead.org, ying.huang@intel.com,
yosryahmed@google.com, yuzhao@google.com
Subject: [PATCH v2 0/3] mm: clarify folio_add_new_anon_rmap() and __folio_add_anon_rmap()
Date: Tue, 18 Jun 2024 11:11:34 +1200 [thread overview]
Message-ID: <20240617231137.80726-1-21cnbao@gmail.com> (raw)
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/
-v2:
* fix crashes reported by Yuan Shuai during swapoff, thanks; David
also commented unuse_pte() for swapoff;
* add comments for !anon according to David, thanks;
* add Yuan Shuai's tested-by tags, thanks for Yuan Shuai's testing
on real phones;
* refine changelog;
-v1(RFC):
https://lore.kernel.org/linux-mm/20240613000721.23093-1-21cnbao@gmail.com/
Barry Song (3):
mm: extend rmap flags arguments for folio_add_new_anon_rmap
mm: 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 | 18 +++++++++++++-----
mm/migrate_device.c | 2 +-
mm/rmap.c | 34 +++++++++++++---------------------
mm/swapfile.c | 15 ++++++++++++---
mm/userfaultfd.c | 2 +-
9 files changed, 44 insertions(+), 35 deletions(-)
--
2.34.1
next reply other threads:[~2024-06-17 23:11 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-17 23:11 Barry Song [this message]
2024-06-17 23:11 ` [PATCH v2 1/3] mm: extend rmap flags arguments for folio_add_new_anon_rmap Barry Song
2024-06-22 3:02 ` Barry Song
2024-06-17 23:11 ` [PATCH v2 2/3] mm: use folio_add_new_anon_rmap() if folio_test_anon(folio)==false Barry Song
2024-06-18 9:54 ` David Hildenbrand
2024-06-20 7:46 ` David Hildenbrand
2024-06-20 8:33 ` Barry Song
2024-06-20 8:49 ` David Hildenbrand
2024-06-20 9:59 ` Barry Song
2024-06-21 9:18 ` David Hildenbrand
2024-06-22 3:20 ` Barry Song
2024-06-24 23:25 ` Andrew Morton
2024-06-24 23:42 ` Barry Song
2024-06-17 23:11 ` [PATCH v2 3/3] mm: remove folio_test_anon(folio)==false path in __folio_add_anon_rmap() Barry Song
2024-06-18 9:55 ` David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240617231137.80726-1-21cnbao@gmail.com \
--to=21cnbao@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=chrisl@kernel.org \
--cc=david@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=ryan.roberts@arm.com \
--cc=shy828301@gmail.com \
--cc=surenb@google.com \
--cc=v-songbaohua@oppo.com \
--cc=willy@infradead.org \
--cc=ying.huang@intel.com \
--cc=yosryahmed@google.com \
--cc=yuzhao@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox