From: Matthew Wilcox <willy@infradead.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "zhaoyang.huang" <zhaoyang.huang@unisoc.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Zhaoyang Huang <huangzhaoyang@gmail.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
ke.wang@unisoc.com
Subject: Re: [Resend RFC PATCH] mm: introduce __GFP_TRACKLEAK to track in-kernel allocation
Date: Fri, 2 Sep 2022 20:08:52 +0100 [thread overview]
Message-ID: <YxJUxDn5v2MqmjKM@casper.infradead.org> (raw)
In-Reply-To: <20220902115839.1e3fafd159e42d4e7dae90af@linux-foundation.org>
On Fri, Sep 02, 2022 at 11:58:39AM -0700, Andrew Morton wrote:
> Cc willy for page-flags changes.
Thanks. This is probably OK. The biggest problem is that it won't
work for drivers which allocate memory and then map it to userspace.
If they try, they'll get a nice splat, but it may limit the usefulness
of this option. We should probably document that limitation in this
patch.
> On Fri, 2 Sep 2022 18:59:07 +0800 "zhaoyang.huang" <zhaoyang.huang@unisoc.com> wrote:
> > +++ b/mm/page_alloc.c
> > @@ -1361,6 +1361,8 @@ static __always_inline bool free_pages_prepare(struct page *page,
> > page->mapping = NULL;
> > if (memcg_kmem_enabled() && PageMemcgKmem(page))
> > __memcg_kmem_uncharge_page(page, order);
> > + if (PageTrackleak(page))
> > + kmemleak_free(page);
Don't we also need to __ClearPageTrackleak()?
> > + if (gfp & __GFP_TRACKLEAK) {
>
> And we'd want __GFP_TRACKLEAK to evaluate to zero at compile time if
> CONFIG_HAVE_DEBUG_KMEMLEAK=n.
>
> > + kmemleak_alloc(page_address(page), PAGE_SIZE << order, 1, gfp & ~__GFP_TRACKLEAK);
> > + __SetPageTrackleak(page);
> > + }
We only set this on the first page we allocate. I think there's a
problem for multi-page, non-compound allocations, no? Particularly
when you consider the problem fixed in e320d3012d25.
I'm not opposed to this tracking, it just needs a bit more thought and
awareness of some of the corner cases of the VM. A few test cases would
be nice; they could demonstrate that this works for both compound and
non-compound high-order allocations.
next prev parent reply other threads:[~2022-09-02 19:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-02 10:59 zhaoyang.huang
2022-09-02 18:58 ` Andrew Morton
2022-09-02 19:08 ` Matthew Wilcox [this message]
2022-09-06 7:29 ` Zhaoyang Huang
2022-09-07 10:00 ` Catalin Marinas
2022-09-12 2:23 ` Zhaoyang Huang
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=YxJUxDn5v2MqmjKM@casper.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=catalin.marinas@arm.com \
--cc=huangzhaoyang@gmail.com \
--cc=ke.wang@unisoc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=zhaoyang.huang@unisoc.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