Re: [PATCH] mm: rectify a page bad reason

From: Matthew Wilcox
Date: Tue Dec 29 2020 - 07:14:52 EST


On Tue, Dec 29, 2020 at 11:11:56AM +0800, Rongwei Wang wrote:
> 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.

> 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
>
>