From: gaoxu <gaoxu2@honor.com>
To: Lokesh Gidra <lokeshgidra@google.com>,
Barry Song <21cnbao@gmail.com>, Minchan Kim <minchan@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>,
Nicolas Geoffray <ngeoffray@google.com>,
Michal Hocko <mhocko@suse.com>,
Andrew Morton <akpm@linux-foundation.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Shaohua Li <shli@fb.com>, yipengxiang <yipengxiang@honor.com>,
fengbaopeng <fengbaopeng@honor.com>,
Kalesh Singh <kaleshsingh@google.com>
Subject: 回复: [PATCH v2] mm: add lazyfree folio to lru tail
Date: Tue, 27 Aug 2024 04:07:57 +0000 [thread overview]
Message-ID: <1757d01334ee4391beba1ea3dcdfed7c@honor.com> (raw)
In-Reply-To: <CA+EESO4MsRxMcTA-_g55rtLE0QTfB3=E53eW8+MSfncwmDx5OQ@mail.gmail.com>
> -----邮件原件-----
> 发件人: Lokesh Gidra <lokeshgidra@google.com>
> 发送时间: 2024年8月27日 8:12
> 收件人: Barry Song <21cnbao@gmail.com>
> 抄送: Suren Baghdasaryan <surenb@google.com>; Nicolas Geoffray
> <ngeoffray@google.com>; Michal Hocko <mhocko@suse.com>; gaoxu
> <gaoxu2@honor.com>; Andrew Morton <akpm@linux-foundation.org>;
> linux-mm@kvack.org; linux-kernel@vger.kernel.org; Shaohua Li <shli@fb.com>;
> yipengxiang <yipengxiang@honor.com>; fengbaopeng
> <fengbaopeng@honor.com>; Kalesh Singh <kaleshsingh@google.com>
> 主题: Re: [PATCH v2] mm: add lazyfree folio to lru tail
>
> On Mon, Aug 26, 2024 at 12:55 PM Barry Song <21cnbao@gmail.com> wrote:
> >
> > On Tue, Aug 27, 2024 at 4:37 AM Lokesh Gidra <lokeshgidra@google.com>
> wrote:
> > >
> > > Thanks Suren for looping in
> > >
> > > On Fri, Aug 23, 2024 at 4:39 PM Suren Baghdasaryan <surenb@google.com>
> wrote:
> > > >
> > > > On Wed, Aug 21, 2024 at 2:47 PM Barry Song <21cnbao@gmail.com>
> wrote:
> > > > >
> > > > > On Wed, Aug 21, 2024 at 8:46 PM Michal Hocko <mhocko@suse.com>
> wrote:
> > > > > >
> > > > > > On Fri 16-08-24 07:48:01, gaoxu wrote:
> > > > > > > Replace lruvec_add_folio with lruvec_add_folio_tail in the
> lru_lazyfree_fn:
> > > > > > > 1. The lazy-free folio is added to the LRU_INACTIVE_FILE list. If it's
> > > > > > > moved to the LRU tail, it allows for faster release lazy-free folio
> and
> > > > > > > reduces the impact on file refault.
> > > > > >
> > > > > > This has been discussed when MADV_FREE was introduced. The
> question was
> > > > > > whether this memory has a lower priority than other inactive memory
> that
> > > > > > has been marked that way longer ago. Also consider several
> MADV_FREE
> > > > > > users should they be LIFO from the reclaim POV?
> > >
> > > Thinking from the user's perspective, it seems to me that FIFO within
> > > MADV_FREE'ed pages makes more sense. As a user I expect the longer a
> > > MADV_FREE'ed page hasn't been touched, the chances are higher that it
> > > may not be around anymore.
> > > > >
> >
> > Hi Lokesh,
> > Thanks!
> >
> > > > > The priority of this memory compared to other inactive memory that has
> been
> > > > > marked for a longer time likely depends on the user's expectations - How
> soon
> > > > > do users expect MADV_FREE to be reclaimed compared with old file
> folios.
> > > > >
> > > > > art guys moved to MADV_FREE from MADV_DONTNEED without any
> > > > > useful performance data and reason in the changelog:
> > > > > https://android-review.googlesource.com/c/platform/art/+/2633132
> > > > >
> > > > > Since art is the Android Java heap, it can be quite large. This increases the
> > > > > likelihood of packing the file LRU and reduces the chances of reclaiming
> > > > > anonymous memory, which could result in more file re-faults while
> helping
> > > > > anonymous folio persist longer in memory.
> > >
> > > Individual heaps of android apps are not big, and even in there we
> > > don't call MADV_FREE on the entire heap.
> >
> > How do you define "Individual heaps of android apps", do you know the usual
> > total_size for a phone with memory pressure by running multiple apps and
> how
> > much for each app?
> >
> Every app is a separate process and therefore has its own private ART
> heap. Those numbers that you are asking vary drastically. But here's
> what I can tell you:
>
> Max heap size for an app is 512MB typically. But it is rarely entirely
> used. Typical heap usage is 50MB to 250MB. But as I said, not all of
> it is MADV_FREE'ed. Only those pages which are freed after GC
> compaction are.
> > > > >
> > > > > I am really curious why art guys have moved to MADV_FREE if we have
> > > > > an approach to reach them.
> > >
> > > Honestly, it makes little sense as a user that calling MADV_FREE on an
> > > anonymous mapping will impact file LRU. That was never the intention
> > > with our ART change.
> > >
> >
> > This is just how MADV_FREE is implemented in the kernel, this kind of lazyfree
> > anon folios are moved to file but *NOT* anon LRU.
> >
> > > From our perspective, once a set of pages are MADV_FREE'ed, they are
> > > like a page-cache. It gives an opportunity, without hurting memory
> > > use, to avoid overhead of page-faults, which happen frequently after
> > > GC is done on running apps.
> > >
> > > IMHO, within LRU_INACTIVE_FILE, MADV_FREE'ed pages should be
> > > prioritized for reclamation over file ones.
> >
> > This is exactly what this patch is doing, putting lazyfree anon folios
> > to the tail of file LRU so that they can be reclaimed earlier than file
> > folios. But the question is: is the requirement "MADV_FREE'ed pages
> > should be prioritized for reclamation over file ones" universally true for
> > all other non-Android users?
> >
> That's definitely an important question to get answered. But putting
> my users hat on again, by explicitly MADV_FREE'ing we ask for that
> behavior. IMHO, MADV_FREE'ed pages should be the first ones to be
> reclaimed on memory pressure.
For non-Android systems, perhaps the author of MADV_FREE can provide a more
reasonable opinion;
Add Minchan Kim.
Please forgive me for forgetting to add you when sending the patch.
> > > >
> > > > Adding Lokesh.
> > > > Lokesh, could you please comment on the reasoning behind the above
> > > > mentioned change?
> > >
> > > Adding Nicolas as well, in case he wants to add something.
> > > >
> > > > >
> > > > > >
> > > > > > --
> > > > > > Michal Hocko
> > > > > > SUSE Labs
> > > > > >
> > > > >
> >
> > Thanks
> > Barry
next prev parent reply other threads:[~2024-08-27 4:08 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-16 7:48 [PATCH v2] mm: add lazyfree folio to lru tail gaoxu
2024-08-16 10:19 ` David Hildenbrand
2024-08-16 10:21 ` David Hildenbrand
2024-08-19 16:11 ` Suren Baghdasaryan
2024-08-20 10:11 ` Barry Song
2024-08-20 11:53 ` 回复: " gaoxu
2024-08-20 21:46 ` Barry Song
2024-08-21 12:46 ` Michal Hocko
2024-08-21 21:47 ` Barry Song
2024-08-23 23:39 ` Suren Baghdasaryan
2024-08-26 16:37 ` Lokesh Gidra
2024-08-26 19:54 ` Barry Song
2024-08-27 0:12 ` Lokesh Gidra
2024-08-27 2:21 ` Barry Song
2024-08-27 4:07 ` gaoxu [this message]
[not found] ` <Zs4TRi61grDvQNdW@google.com>
2024-08-29 3:55 ` 回复: 回复: " gaoxu
2024-09-10 8:51 ` Barry Song
2024-08-27 2:13 ` Hailong Liu
2024-08-27 2:18 ` Barry Song
2024-08-27 2:29 ` Hailong Liu
2024-09-09 22:22 ` Andrew Morton
2024-09-10 8:20 ` Michal Hocko
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=1757d01334ee4391beba1ea3dcdfed7c@honor.com \
--to=gaoxu2@honor.com \
--cc=21cnbao@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=fengbaopeng@honor.com \
--cc=kaleshsingh@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lokeshgidra@google.com \
--cc=mhocko@suse.com \
--cc=minchan@kernel.org \
--cc=ngeoffray@google.com \
--cc=shli@fb.com \
--cc=surenb@google.com \
--cc=yipengxiang@honor.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