linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Barry Song <baohua@kernel.org>
To: wangzicheng <wangzicheng@honor.com>
Cc: "akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	 "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	 Lei Liu <liulei.rjpt@vivo.com>,
	"Matthew Wilcox (Oracle)" <willy@infradead.org>,
	 Axel Rasmussen <axelrasmussen@google.com>,
	Yuanchu Xie <yuanchu@google.com>,  Wei Xu <weixugc@google.com>,
	Kairui Song <kasong@tencent.com>,
	 Tangquan Zheng <zhengtangquan@oppo.com>,
	wangtao <tao.wangtao@honor.com>,
	 liulu 00013167 <liulu.liu@honor.com>
Subject: Re: [PATCH RFC] mm/mglru: lazily activate folios while folios are really mapped
Date: Thu, 9 Apr 2026 14:39:56 +0800	[thread overview]
Message-ID: <CAGsJ_4wqd6Lg8vba8oeHjZTmahOdROG6eb4+f1QmGUtOBK8g0A@mail.gmail.com> (raw)
In-Reply-To: <d11be6d7aaf14d6e8542c5bfb56bb0c1@honor.com>

On Thu, Mar 19, 2026 at 6:13 PM wangzicheng <wangzicheng@honor.com> wrote:
>
> Hi Barry,
>
> Thank you for the suggestion.
>
> I have re-designed the workload and get the relative promising results.
> The workload repeatedly launches and switches between 30 apps
> for 500 rounds. Since the test takes quite a long time, the final results
> appear relatively stable across runs.
>
> The testing was done on an Android 16 device with kernel 6.6.89,
> 8GB RAM, MGLRU enabled.
>
> However, the results are not very easy to interpret.
>
> Average number of kept-alive apps: ±0.08 apps
> Average available memory (sampled after each app launch):
> baseline vs patched: 2216MB vs 2218MB (~2MB difference)
>
> Below is the vmstat comparison (patched vs baseline):
>
> Metric                       Change
> ---------------------------  --------
> pgpgin                       +2.06%
> pgpgout                      +3.10%
> pswpin                       +14.13%
> pswpout                      +4.55%
> pgfault                      -3.19%
> pgmajfault                   +12.75%
> workingset_refault_anon      +14.77%
> workingset_refault_file      +3.48%
> workingset_activate_anon     -3.45%
> workingset_activate_file     -17.76%
> workingset_restore_anon      -3.44%
> workingset_restore_file      -19.13%
>
> In v6.6, when PG_active is set, pages go to the youngest generation,
> while pages without PG_active go to the second oldest generation.
> ```
> static inline bool lru_gen_add_folio(
> ...
>               if (folio_test_active(folio))
>                 seq = lrugen->max_seq;
>         ...
>         else
>                 seq = lrugen->min_seq[type] + 1;
> ```
>
> My rough expectation was that the patch should make file pages more
> prone to reclaim and make file page hot/cold aging more accurate, so
> both file refault and anon refault might decrease. But here anon refault
> increases instead.
>
> I’m not sure if this assumption is correct. Could you share your thoughts
> on how to interpret these results?

Probably because readahead folios are soon mapped via
fault-around. Currently, the fault_around_pages value is quite
large.

There is an Android hook available for adjusting fault-around:

static inline bool should_fault_around(struct vm_fault *vmf)
{
        bool should_around = true;
        /* No ->map_pages?  No way to fault around... */
        if (!vmf->vma->vm_ops->map_pages)
                return false;

        if (uffd_disable_fault_around(vmf->vma))
                return false;

        trace_android_vh_should_fault_around(vmf, &should_around);
        if (!should_around)
                return false;

        /* A single page implies no faulting 'around' at all. */
        return fault_around_pages > 1;
}

If you reduce fault-around from 16 pages to 4 pages when
available memory falls below a certain threshold, you’ll see
this RFC deliver a significant improvement on low-memory
devices, such as 8 GB phones.

But for mainline, we still need an approach that can be merged.

Traditional LRU relies on PTE scanning to activate folios,
while MGLRU assumes mapped folios should be activated.
However, fault-around may map folios that are not actually
needed. If we drop activation in map_pages, we miss future
opportunities to promote those folios at mapping time.

Best Regards
Barry


  parent reply	other threads:[~2026-04-09  6:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-25 22:37 Barry Song
2026-02-26 12:57 ` wangzicheng
2026-02-27  0:15   ` Barry Song
2026-02-28 10:28     ` wangzicheng
2026-03-01  4:16       ` Barry Song
2026-03-19 10:12         ` wangzicheng
2026-03-20  9:59           ` 答复: " 郑堂权(Blues Zheng)
2026-04-02 22:29             ` Barry Song
2026-04-09  6:39           ` Barry Song [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-02-25 21:26 Barry Song

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=CAGsJ_4wqd6Lg8vba8oeHjZTmahOdROG6eb4+f1QmGUtOBK8g0A@mail.gmail.com \
    --to=baohua@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=axelrasmussen@google.com \
    --cc=kasong@tencent.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=liulei.rjpt@vivo.com \
    --cc=liulu.liu@honor.com \
    --cc=surenb@google.com \
    --cc=tao.wangtao@honor.com \
    --cc=wangzicheng@honor.com \
    --cc=weixugc@google.com \
    --cc=willy@infradead.org \
    --cc=yuanchu@google.com \
    --cc=zhengtangquan@oppo.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