Re: [RFC PATCH] mm: dump_page: print total mapcount for compound page
From: Hugh Dickins
Date: Fri May 28 2021 - 15:52:24 EST
On Fri, 28 May 2021, Yang Shi wrote:
> The total mapcount is a useful information for debugging, but we can't
> call total_mapcount() directly since it calls some assertions which may
> be triggered as commit 6dc5ea16c86f ("mm,
> dump_page: do not crash with bad compound_mapcount()") met.
>
> We could implement yet another implementation for dump_page() but
> it has the limitation when individual mapcount of subpages is corrupted.
>
> Actually the total mapcount could be decoded from refcount, pincount and
> compound mapcount although it may be not very precise due to some
> transient references.
>
> Signed-off-by: Yang Shi <shy828301@xxxxxxxxx>
> ---
> I think we are on the same page that the total mapcount is useful
Well, it may be useful (and used to be shown) in the case we've been
thinking of; but there the critical fact, page_mapped(), is evident from
the fact that your VM_WARN_ON_ONCE_PAGE(page_mapped) is shown at all:
being a number, total_mapcount() tells a little more, but not a lot.
> information and it would be ideal to print this information when dumpping
Yes, I admit I did say "ideal": but not at this cost.
I'm sorry for pointing you down (something like) this path.
If total_mapcount() itself had been assuredly safe, it would
have been nice to add in; but not this substitute.
> page if possible. But how to implement it safely seems controversial.
> Some ideas and potential problems have been discussed by
> https://lore.kernel.org/linux-mm/alpine.LSU.2.11.2105261733110.16920@eggly.anvils/.
>
> So I prepared this patch to show a possible approach to get some
> feedback. The same thing could be decoded by the reader of page dump
> as well by using the same formula used by this patch. However it sounds
> more convenient to have kernel do the math.
>
> mm/debug.c | 35 +++++++++++++++++++++++++++++------
> 1 file changed, 29 insertions(+), 6 deletions(-)
Adding that code to come up with a deceptive approximation to a number
which most sites won't care about: speaking for me, I'll say no.
Hugh