[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHbLzkrY3MBsr+xKp_6zr8jwe=d1ua_5tpgVHjBgU90srW2Srw@mail.gmail.com>
Date: Fri, 17 Dec 2021 11:12:17 -0800
From: Yang Shi <shy828301@...il.com>
To: David Hildenbrand <david@...hat.com>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Hugh Dickins <hughd@...gle.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
David Rientjes <rientjes@...gle.com>,
Shakeel Butt <shakeelb@...gle.com>,
John Hubbard <jhubbard@...dia.com>,
Jason Gunthorpe <jgg@...dia.com>,
Mike Kravetz <mike.kravetz@...cle.com>,
Mike Rapoport <rppt@...ux.ibm.com>,
"Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>,
Matthew Wilcox <willy@...radead.org>,
Vlastimil Babka <vbabka@...e.cz>, Jann Horn <jannh@...gle.com>,
Michal Hocko <mhocko@...nel.org>,
Nadav Amit <namit@...are.com>, Rik van Riel <riel@...riel.com>,
Roman Gushchin <guro@...com>,
Andrea Arcangeli <aarcange@...hat.com>,
Peter Xu <peterx@...hat.com>,
Donald Dutile <ddutile@...hat.com>,
Christoph Hellwig <hch@....de>,
Oleg Nesterov <oleg@...hat.com>, Jan Kara <jack@...e.cz>,
Linux MM <linux-mm@...ck.org>, linux-kselftest@...r.kernel.org,
linux-doc@...r.kernel.org
Subject: Re: [PATCH v1 04/11] mm: thp: simlify total_mapcount()
On Fri, Dec 17, 2021 at 3:33 AM David Hildenbrand <david@...hat.com> wrote:
>
> Let's simplify a bit, returning for PageHuge() early and using
> head_compound_page() as we are only getting called for HEAD pages.
>
> Note the VM_BUG_ON_PAGE(PageTail(page), page) check at the beginning of
> total_mapcount().
>
> This is a preparation for further changes.
>
> Reviewed-by: Peter Xu <peterx@...hat.com>
> Signed-off-by: David Hildenbrand <david@...hat.com>
Reviewed-by: Yang Shi <shy828301@...il.com>
> ---
> mm/huge_memory.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 4751d03947da..826cabcad11a 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -2506,12 +2506,11 @@ int total_mapcount(struct page *page)
>
> if (likely(!PageCompound(page)))
> return atomic_read(&page->_mapcount) + 1;
> + if (PageHuge(page))
> + return head_compound_mapcount(page);
>
> - compound = compound_mapcount(page);
> nr = compound_nr(page);
> - if (PageHuge(page))
> - return compound;
> - ret = compound;
> + ret = compound = head_compound_mapcount(page);
> for (i = 0; i < nr; i++)
> ret += atomic_read(&page[i]._mapcount) + 1;
> /* File pages has compound_mapcount included in _mapcount */
> --
> 2.31.1
>
Powered by blists - more mailing lists