From: Barry Song <21cnbao@gmail.com>
To: david@redhat.com, akpm@linux-foundation.org, linux-mm@kvack.org
Cc: chrisl@kernel.org, linux-kernel@vger.kernel.org, mhocko@suse.com,
ryan.roberts@arm.com, baolin.wang@linux.alibaba.com,
yosryahmed@google.com, shy828301@gmail.com, surenb@google.com,
v-songbaohua@oppo.com, willy@infradead.org, ying.huang@intel.com,
yuzhao@google.com
Subject: [PATCH RFC 3/3] mm: remove folio_test_anon(folio)==false path in __folio_add_anon_rmap()
Date: Thu, 13 Jun 2024 12:07:21 +1200 [thread overview]
Message-ID: <20240613000721.23093-4-21cnbao@gmail.com> (raw)
In-Reply-To: <20240613000721.23093-1-21cnbao@gmail.com>
From: Barry Song <v-songbaohua@oppo.com>
The folio_test_anon(folio)==false case within do_swap_page() has been
relocated to folio_add_new_anon_rmap(). Additionally, two other callers
consistently pass anonymous folios.
stack 1:
remove_migration_pmd
-> folio_add_anon_rmap_pmd
-> __folio_add_anon_rmap
stack 2:
__split_huge_pmd_locked
-> folio_add_anon_rmap_ptes
-> __folio_add_anon_rmap
__folio_add_anon_rmap() only needs to handle the cases
folio_test_anon(folio)==true now.
Suggested-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Barry Song <v-songbaohua@oppo.com>
---
mm/rmap.c | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)
diff --git a/mm/rmap.c b/mm/rmap.c
index e612d999811a..e84c706c8241 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1299,21 +1299,10 @@ static __always_inline void __folio_add_anon_rmap(struct folio *folio,
nr = __folio_add_rmap(folio, page, nr_pages, level, &nr_pmdmapped);
- if (unlikely(!folio_test_anon(folio))) {
- VM_WARN_ON_FOLIO(!folio_test_locked(folio), folio);
- /*
- * For a PTE-mapped large folio, we only know that the single
- * PTE is exclusive. Further, __folio_set_anon() might not get
- * folio->index right when not given the address of the head
- * page.
- */
- VM_WARN_ON_FOLIO(folio_test_large(folio) &&
- level != RMAP_LEVEL_PMD, folio);
- __folio_set_anon(folio, vma, address,
- !!(flags & RMAP_EXCLUSIVE));
- } else if (likely(!folio_test_ksm(folio))) {
+ VM_WARN_ON_FOLIO(!folio_test_anon(folio), folio);
+
+ if (likely(!folio_test_ksm(folio)))
__page_check_anon_rmap(folio, page, vma, address);
- }
__folio_mod_stat(folio, nr, nr_pmdmapped);
--
2.34.1
next prev parent reply other threads:[~2024-06-13 0:08 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Barry Song [this message]
2024-06-13 8:46 ` [PATCH RFC 3/3] mm: remove folio_test_anon(folio)==false path in __folio_add_anon_rmap() 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
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=20240613000721.23093-4-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