lkml.org 
[lkml]   [2021]   [Dec]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v1 04/11] mm: thp: simlify total_mapcount()
Date
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@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.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
\
 
 \ /
  Last update: 2021-12-17 12:34    [W:0.271 / U:1.788 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site