From: Matthew Wilcox <willy@infradead.org>
To: Yang Shi <shy828301@gmail.com>
Cc: hughd@google.com, jhubbard@nvidia.com,
kirill.shutemov@linux.intel.com, vbabka@suse.cz,
akpm@linux-foundation.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] mm: dump_page: print total mapcount for compound page
Date: Fri, 28 May 2021 19:22:10 +0100 [thread overview]
Message-ID: <YLE00rVi6O3DF3XA@casper.infradead.org> (raw)
In-Reply-To: <20210528175403.4506-1-shy828301@gmail.com>
On Fri, May 28, 2021 at 10:54:03AM -0700, Yang Shi wrote:
> 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.
You haven't taken enough things into consideration ...
> + bool is_slab = PageSlab(head);
We should probably have a separate dump_slab_page(). Almost nothing
in __dump_page() is really useful for slab pages (eg, mapping, index,
mapcount, compound_mapcount, compound_pincount, aops), and the flags
(such as are used) have different meanings.
> + nr = compound_nr(head);
> + if (is_slab)
> + total_mapcount = 0;
> + else if (PageHuge(head))
> + total_mapcount = comp_mapcnt;
> + else {
> + if (mapping) {
> + if (!PageAnon(head))
> + nr = nr * (comp_mapcnt + 1) - comp_mapcnt;
> + } else
> + nr = 0;
> + total_mapcount = refcount - pincount - nr;
I see what you're trying to do here, but there are so many other things
which take a refcount on a page. The LRU, the page cache, private fs
data, random temporary "gets" (eg, buffered reads, buffered writes,
get_user_pages(), readahead, truncate, migration). I think this is
likely to be so inaccurate as to be confusing.
I had to think hard about it though. I like what you're trying to do,
I just don't think it works ;-(
next prev parent reply other threads:[~2021-05-28 18:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-28 17:54 Yang Shi
2021-05-28 18:22 ` Matthew Wilcox [this message]
2021-05-28 18:56 ` Yang Shi
2021-05-28 18:26 ` John Hubbard
2021-05-28 19:03 ` Yang Shi
2021-05-28 19:59 ` John Hubbard
2021-05-28 19:47 ` Hugh Dickins
2021-05-31 8:19 ` Kirill A. Shutemov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YLE00rVi6O3DF3XA@casper.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=jhubbard@nvidia.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=shy828301@gmail.com \
--cc=vbabka@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox