[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <171f18ed-3fc7-47c8-8aef-d4ab31f55be0@redhat.com>
Date: Tue, 18 Jun 2024 11:55:38 +0200
From: David Hildenbrand <david@...hat.com>
To: Barry Song <21cnbao@...il.com>, akpm@...ux-foundation.org,
linux-mm@...ck.org
Cc: baolin.wang@...ux.alibaba.com, chrisl@...nel.org,
linux-kernel@...r.kernel.org, mhocko@...e.com, ryan.roberts@....com,
shy828301@...il.com, surenb@...gle.com, v-songbaohua@...o.com,
willy@...radead.org, ying.huang@...el.com, yosryahmed@...gle.com,
yuzhao@...gle.com, Shuai Yuan <yuanshuai@...o.com>
Subject: Re: [PATCH v2 3/3] mm: remove folio_test_anon(folio)==false path in
__folio_add_anon_rmap()
On 18.06.24 01:11, Barry Song wrote:
> From: Barry Song <v-songbaohua@...o.com>
>
> The folio_test_anon(folio)==false cases has been relocated to
> folio_add_new_anon_rmap(). Additionally, four 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
>
> stack 3:
> remove_migration_pmd
> -> folio_add_anon_rmap_pmd
> -> __folio_add_anon_rmap (RMAP_LEVEL_PMD)
>
> stack 4:
> try_to_merge_one_page
> -> replace_page
> -> folio_add_anon_rmap_pte
> -> __folio_add_anon_rmap
>
> __folio_add_anon_rmap() only needs to handle the cases
> folio_test_anon(folio)==true now.
> We can remove the !folio_test_anon(folio)) path within
> __folio_add_anon_rmap() now.
>
> Suggested-by: David Hildenbrand <david@...hat.com>
> Signed-off-by: Barry Song <v-songbaohua@...o.com>
> Tested-by: Shuai Yuan <yuanshuai@...o.com>
> ---
> mm/rmap.c | 17 +++--------------
> 1 file changed, 3 insertions(+), 14 deletions(-)
>
> diff --git a/mm/rmap.c b/mm/rmap.c
> index 2b19bb92eda5..ddcdda752982 100644
> --- a/mm/rmap.c
> +++ b/mm/rmap.c
> @@ -1297,23 +1297,12 @@ static __always_inline void __folio_add_anon_rmap(struct folio *folio,
> {
> int i, nr, nr_pmdmapped = 0;
>
> + VM_WARN_ON_FOLIO(!folio_test_anon(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))) {
> + if (likely(!folio_test_ksm(folio)))
> __page_check_anon_rmap(folio, page, vma, address);
> - }
>
> __folio_mod_stat(folio, nr, nr_pmdmapped);
>
Lovely!
Acked-by: David Hildenbrand <david@...hat.com>
--
Cheers,
David / dhildenb
Powered by blists - more mailing lists