Re: [PATCH v2] mm, dump_page: do not crash with bad compound_mapcount()

From: John Hubbard
Date: Fri Aug 07 2020 - 18:40:30 EST


On 8/7/20 9:48 AM, Kirill A. Shutemov wrote:
[...]
+static inline int head_mapcount(struct page *head)
+{

Do we want VM_BUG_ON_PAGE(!PageHead(head), head) here?

Well, no. That was the point of the bug report -- by the time we called
compound_mapcount, the page was no longer a head page.

Right. VM_BUG_ON_PAGE(PageTail(head), head)?

Sorry for overlooking that feedback point. Looking at it now, I'd much
rather not put any assertions at all here. This supposed to be for
implementing the failure case, and we've moved past assertions at this
point. In other words, dump_page() is part of *implementing* an
assertion, so calling assertions from within it is undesirable.

It's better to put the assertions in code that would call these inner
routines. Then, if we want to use these routines outside of mm/debug.c,
as per the other thread, then we should provide a wrapper that has such
assertions.


thanks,
--
John Hubbard
NVIDIA