linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Minchan Kim <minchan@kernel.org>
To: David Hildenbrand <david@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Michal Hocko <mhocko@suse.com>, linux-mm <linux-mm@kvack.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	John Dias <joaodias@google.com>,
	huww98@outlook.com, John Hubbard <jhubbard@nvidia.com>
Subject: Re: [RFC v2] mm: introduce page pin owner
Date: Wed, 12 Jan 2022 08:22:57 -0800	[thread overview]
Message-ID: <Yd8AYViR6vuBVU2L@google.com> (raw)
In-Reply-To: <cf596fdc-6599-7c53-26e8-1524c5f214f7@redhat.com>

On Wed, Jan 12, 2022 at 01:25:04PM +0100, David Hildenbrand wrote:
> On 28.12.21 18:59, Minchan Kim wrote:
> > A Contiguous Memory Allocator(CMA) allocation can fail if any page
> > within the requested range has an elevated refcount(a pinned page).
> > 
> > Debugging such failures is difficult, because the struct pages only
> > show a combined refcount, and do not show the callstacks or
> > backtraces of the code that acquired each refcount. So the source
> > of the page pins remains a mystery, at the time of CMA failure.
> > 
> > In order to solve this without adding too much overhead, just do
> > nothing most of the time, which is pretty low overhead. However,
> > once a CMA failure occurs, then mark the page (this requires a
> > pointer's worth of space in struct page, but it uses page extensions
> > to get that), and start tracing the subsequent put_page() calls.
> > As the program finishes up, each page pin will be undone, and
> > traced with a backtrace. The programmer reads the trace output and
> > sees the list of all page pinning code paths.
> > 
> 
> It's worth noting that this is a pure debug feature, right?

Sure.

> 
> 
> I like the general approach, however, IMHO the current naming is a bit
> sub-optimal and misleading. All you're doing is flagging pages that
> should result in a tracepoint when unref'ed.
> 
> "page pinners" makes it somewhat sound like you're targeting FOLL_PIN,
> not simply any references.
> 
> "owner" is misleading IMHO as well.
> 
> 
> What about something like:
> 
> "mm: selective tracing of page reference holders on unref"
> 
> PAGE_EXT_PIN_OWNER -> PAGE_EXT_TRACE_UNREF
> 
> $whatever feature/user can then set the bit, for example, when migration
> fails.

I couldn't imagine put_page tracking is generally useful except
migration failure. Do you have reasonable usecase in your mind
to make the feature general to be used?
Otherwise, I'd like to have feature naming more higher level
to represent page migration failure and then tracking unref of
the page. In the sense, PagePinOwner John suggested was good
candidate(Even, my original naming PagePinner was worse) since
I was trouble to abstract the feature with short word.
If we approach "what feature is doing" rather than "what's
the feature's goal"(I feel the your suggestion would be close
to what feature is doing), I'd like to express "unreference on
migraiton failed page" so PAGE_EXT_UNMIGRATED_UNREF
(However, I prefer the feature naming more "what we want to achieve")

> 
> I somewhat dislike that it's implicitly activated by failed page
> migration. At least the current naming doesn't reflect that.
> 
> 
> > This will consume an additional 8 bytes per 4KB page, or an
> > additional 0.2% of RAM. In addition to the storage space, it will
> > have some performance cost, due to increasing the size of struct
> > page so that it is greater than the cacheline size (or multiples
> > thereof) of popular (x86, ...) CPUs.
> 
> I think I might be missing something. Aren't you simply reusing
> &page_ext->flags ? I mean, the "overhead" is just ordinary page_ext
> overhead ... and whee exactly are you changing "struct page" layout? Is
> this description outdated?

The feature enables page_ext which adds up 8 bytes per 4KB and on every
put operation, it need to access the additional flag on page_ext which
affects performance since page_put is the common operation.
Yeah, the struct size stuff in the wording is rather misleading.
Let me change the workding something like this:

 This will consume an additional 8 bytes per 4KB page, or an
 additional 0.2% of RAM. In addition to the storage space, it will
 have some performance cost, due to checking additional flag on
 every put_page opeartion.

> 
> > 
> > The idea can apply every user of migrate_pages as well as CMA to
> > know the reason why the page migration failed. To support it,
> > the implementation takes "enum migrate_reason" string as filter
> > of the tracepoint(see below).
> > 
> 
> I wonder if we could achieve the same thing for debugging by
> 
> a) Tracing the PFN when migration fails
> b) Tracing any unref of any PFN
> 
> User space can then combine both information to achieve the same result.
> I assume one would need a big trace buffer, but maybe for a debug
> feature good enough?

I definitely tried it for cma allocation failure but it generated
enormous output(Please keep it in mind that we also need stacktrace)
due to too frequent put_page and compaction operation(Even, I filter
them out to track only cma pages but it was still huge since the CMA
size is 1/8 of the system). Even though I increased the buffer size
a lot, the buffer was easily overwritten. Moreover, even though it's
debug feature, we need to release the feature into dogfooder to catch
the real problem in the field so consuming too much memory as well as
backtrace operhead on every put page are tough to be used in field.


  reply	other threads:[~2022-01-12 16:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-28 17:59 Minchan Kim
2022-01-06 18:14 ` Minchan Kim
2022-01-06 22:27 ` John Hubbard
2022-01-06 23:24   ` Minchan Kim
2022-01-12 12:25 ` David Hildenbrand
2022-01-12 16:22   ` Minchan Kim [this message]
2022-01-12 17:42     ` David Hildenbrand
2022-01-12 20:41       ` Minchan Kim
2022-01-14 13:31         ` David Hildenbrand
2022-01-14 16:39           ` Minchan Kim
2022-01-14 16:51             ` David Hildenbrand
2022-01-14 18:47               ` David Hildenbrand
2022-01-14 18:57                 ` Minchan Kim
2022-01-21 21:59                   ` Minchan Kim
2022-01-14 18:55               ` Minchan Kim

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=Yd8AYViR6vuBVU2L@google.com \
    --to=minchan@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=huww98@outlook.com \
    --cc=jhubbard@nvidia.com \
    --cc=joaodias@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=surenb@google.com \
    /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