From: Matthew Wilcox <willy@infradead.org>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.com>,
Zhou Guanghui <zhouguanghui1@huawei.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
akpm@linux-foundation.org, hughd@google.com,
kirill.shutemov@linux.intel.com, npiggin@gmail.com,
ziy@nvidia.com, wangkefeng.wang@huawei.com, guohanjun@huawei.com,
dingtianhong@huawei.com, chenweilong@huawei.com,
rui.xiang@huawei.com
Subject: Re: [PATCH v2 2/2] mm/memcg: set memcg when split page
Date: Thu, 11 Mar 2021 16:23:45 +0000 [thread overview]
Message-ID: <20210311162345.GW3479805@casper.infradead.org> (raw)
In-Reply-To: <YEo1gz6wuYl1Fuqt@cmpxchg.org>
On Thu, Mar 11, 2021 at 10:21:39AM -0500, Johannes Weiner wrote:
> On Thu, Mar 11, 2021 at 09:37:02AM +0100, Michal Hocko wrote:
> > Johannes, Hugh,
> >
> > what do you think about this approach? If we want to stick with
> > split_page approach then we need to update the missing place Matthew has
> > pointed out.
>
> I find the __free_pages() code quite tricky as well. But for that
> reason I would actually prefer to initiate the splitting in there,
> since that's the place where we actually split the page, rather than
> spread the handling of this situation further out.
Mmm. The thing is, we don't actually split the page because it was
never compound. I don't know whether anybody actually does this,
but it's legitimate to write:
struct page *p = alloc_pages(GFP_KERNEL, 2);
free_unref_page(p + 1);
free_unref_page(p + 3);
free_unref_page(p + 2);
__free_page(p);
The good news is that I recently made free_unref_page() local to
mm/internal.h, so we don't need to worry about device drivers doing this.
As far as I can tell, we don't have any exposure to this kind of thing
today through functions exported from mm, but I might have missed
something.
I'd really like to get rid of non-compound high-order pages. Slab,
filesystems and anonymous memory all use compound pages. I think
it's just crusty old device drivers that don't. And alloc_pages_exact(),
of course, but that's kind of internal.
> The race condition shouldn't be hot, so I don't think we need to be as
> efficient about setting page->memcg_data only on the higher-order
> buddies as in Willy's scratch patch. We can call split_page_memcg(),
> which IMO should actually help document what's happening to the page.
I'm cool with that. I agree, this is not a performance case!
> I think that function could also benefit a bit more from step-by-step
> documentation about what's going on. The kerneldoc is helpful, but I
> don't think it does justice to how tricky this race condition is.
Always good to have other people read over your explanation ...
the kernel-doc could probably be simplified as a result.
next prev parent reply other threads:[~2021-03-11 16:24 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-04 7:40 [PATCH v2 0/2] set memcg when split page Zhou Guanghui
2021-03-04 7:40 ` [PATCH v2 1/2] mm/memcg: rename mem_cgroup_split_huge_fixup to split_page_memcg Zhou Guanghui
2021-03-04 15:50 ` Johannes Weiner
2021-03-04 16:20 ` Zi Yan
2021-03-04 18:54 ` Shakeel Butt
2021-03-08 22:37 ` Singh, Balbir
2021-03-09 8:28 ` Michal Hocko
2021-03-10 21:44 ` Singh, Balbir
2021-03-10 22:00 ` Hugh Dickins
2021-03-10 23:50 ` Singh, Balbir
2021-03-04 7:40 ` [PATCH v2 2/2] mm/memcg: set memcg when split page Zhou Guanghui
2021-03-04 15:52 ` Johannes Weiner
2021-03-04 16:22 ` Zi Yan
2021-03-04 18:55 ` Shakeel Butt
[not found] ` <YEIblNv0BMITFzYO@dhcp22.suse.cz>
2021-03-05 23:58 ` Andrew Morton
2021-03-08 8:41 ` Michal Hocko
2021-03-08 20:42 ` Andrew Morton
2021-03-08 20:47 ` Matthew Wilcox
2021-03-09 0:10 ` Andrew Morton
2021-03-08 21:02 ` Matthew Wilcox
2021-03-09 9:02 ` Michal Hocko
2021-03-09 12:32 ` Matthew Wilcox
2021-03-09 13:03 ` Michal Hocko
2021-03-11 8:37 ` Michal Hocko
2021-03-11 15:21 ` Johannes Weiner
2021-03-11 16:23 ` Matthew Wilcox [this message]
2021-03-11 16:26 ` Michal Hocko
2021-03-11 20:37 ` Hugh Dickins
2021-03-18 14:05 ` Michal Hocko
2021-03-18 15:02 ` Matthew Wilcox
2021-03-18 15:07 ` Johannes Weiner
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=20210311162345.GW3479805@casper.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=chenweilong@huawei.com \
--cc=dingtianhong@huawei.com \
--cc=guohanjun@huawei.com \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=npiggin@gmail.com \
--cc=rui.xiang@huawei.com \
--cc=wangkefeng.wang@huawei.com \
--cc=zhouguanghui1@huawei.com \
--cc=ziy@nvidia.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;
as well as URLs for NNTP newsgroup(s).