Re: [PATCH v1 03/11] mm: simplify hugetlb and file-THP handling in __page_mapcount()

From
David Hildenbrand <hidden>
Date
2021-12-17 17:30:36
Also in
linux-kselftest, linux-mm, lkml
Reply to
Nadav Amit, 2021-12-17
On 17.12.21 18:16, Nadav Amit wrote:
quoted
On Dec 17, 2021, at 3:30 AM, David Hildenbrand [off-list ref] wrote:

Let's return early for hugetlb, which really only relies on the compound
mapcount so far and does not support PageDoubleMap() yet. Use the chance
to cleanup the file-THP case to make it easier to grasp. While at it, use
head_compound_mapcount().

This is a preparation for further changes.
It would be useful to add “no functional change intended” or something.
Absolutely, same applies to other "simplification" patches.
quoted
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: David Hildenbrand <redacted>
---
mm/util.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/mm/util.c b/mm/util.c
index 741ba32a43ac..3239e75c148d 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -732,15 +732,18 @@ int __page_mapcount(struct page *page)
{
	int ret;

-	ret = atomic_read(&page->_mapcount) + 1;
+	if (PageHuge(page))
+		return compound_mapcount(page);
Before you return, perhaps you can add an assertion like:

	VM_BUG_ON(PageDoubleMap(page));

This would be make the code clearer and would ease debugging in the
future (if support for double-map is expanded).
I'd probably have to add this to a couple of places -- and I assume
anybody working on that has to grep the kernel for use of PageDoubleMap
already.

Thanks!

-- 
Thanks,

David / dhildenb
Thread (137 messages) 137 messages, 11 authors, last reply 2022-01-04
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help