Skip to contentSkip to conversation

mm: rectify a page bad reason

PATCH In review Rongwei Wang 2 participants 3 messages Dec 29, 2020 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: rectify a page bad reason

Hi

When I was doing some memory-related projects, it always reported error "nonzero mapcount", but its judgment condition was that _mapcount was not equal to -1, so I felt the original string was a bit inappropriate, so I tried to update it.

---
 mm/page_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_alloc.c +1 -1
index 7a2c89b..57d7f26 100644
@@ -1114,7 +1114,7 @@ static const char *page_bad_reason(struct page *page, unsigned long flags)
 	const char *bad_reason = NULL;
 
 	if (unlikely(atomic_read(&page->_mapcount) != -1))
-		bad_reason = "nonzero mapcount";
+		bad_reason = "non-(-1) _mapcount";
 	if (unlikely(page->mapping != NULL))
 		bad_reason = "non-NULL mapping";
 	if (unlikely(page_ref_count(page) != 0))
Signature · 1 line
1.8.3.1

A message that is not in the archive (sent off-list or not yet received): CAPSr9jFf4HoODzubWx-JkVKK69YGx0vgaesuVU8od-qyyGOjpw@mail.gmail.com

#2 lore raw
Quoted 13 lines · Muchun Song
Quoted 7 lines · Rongwei Wang <[email protected]> 于2020年12月29日周二 上午11:16写道:

Hi

When I was doing some memory-related projects, it always reported error "nonzero mapcount", but its judgment condition was that _mapcount was not equal to -1, so I felt the original string was a bit inappropriate, so I tried to update it.

Quoted 4 lines

Hi Rongwei,

Because the page_mapcount() just returns atomic_read(&page->_mapcount) + 1, reporting "nonzero mapcount" is reasonable when _mapcount is -1.

Hi, Muchun

Thank you for the tip. I read the __dump_page function again.
Indeed here need to combine page_mapcount+page_bad_reason to understand, and reporting "nonzero mapcount" is reasonable. It always feel a little strange ONLY look at page_bad_reason.

Maybe it should be changed (or NOT) to this:

if (unlikely(page_mapcount(page) != 0))

	bad_reason = "nonzero mapcount”;

Anyway, thanks
Rongwei Wang

Quoted 24 lines

Thanks.

Quoted 21 lines

---
mm/page_alloc.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_alloc.c +1 -2
index 7a2c89b..57d7f26 100644
@@ -1114,7 +1114,7 @@ static const char *page_bad_reason(struct page *page, unsigned long flags)
       const char *bad_reason = NULL;
 
       if (unlikely(atomic_read(&page->_mapcount) != -1))
-               bad_reason = "nonzero mapcount";
+               bad_reason = "non-(-1) _mapcount";
       if (unlikely(page->mapping != NULL))
               bad_reason = "non-NULL mapping";
       if (unlikely(page_ref_count(page) != 0))
--

1.8.3.1

#3 lore raw
In reply to Rongwei Wang
Quoted 4 lines · Rongwei Wang

When I was doing some memory-related projects, it always reported error "nonzero mapcount", but its judgment condition was that _mapcount was not equal to -1, so I felt the original string was a bit inappropriate, so I tried to update it.

But '_mapcount' of -1 _is_ a mapcount of 0. If we need to improve the documentation somewhere, that'd be better than changing this message.

I do wonder if we want to add:

	if (unlikely(page_has_type(page))
		bad_reason = "page still typed";

It's covered by the non-zero mapcount case, but is slightly misleading.

Quoted 10 lines
mm/page_alloc.c +1 -1
 	if (unlikely(atomic_read(&page->_mapcount) != -1))
-		bad_reason = "nonzero mapcount";
+		bad_reason = "non-(-1) _mapcount";
 	if (unlikely(page->mapping != NULL))
 		bad_reason = "non-NULL mapping";
 	if (unlikely(page_ref_count(page) != 0))
Signature · 1 line
1.8.3.1