mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: Barry Song <baohua@kernel.org>
Cc: akpm@linux-foundation.org, kasong@tencent.com,
	qi.zheng@linux.dev, shakeel.butt@linux.dev,
	axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com,
	david@kernel.org, mhocko@kernel.org, ljs@kernel.org,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: mglru: promote mapped executable folios after first usage
Date: Wed, 15 Jul 2026 14:58:10 +0800	[thread overview]
Message-ID: <e62cdd47-4812-401d-8c69-51bd483b37ee@linux.alibaba.com> (raw)
In-Reply-To: <CAGsJ_4x560kU5Qd02rLHAhenx5nzyJ_3ZCWo1XgmWYe6BMrEqg@mail.gmail.com>



On 7/15/26 2:52 PM, Barry Song wrote:
> On Wed, Jul 15, 2026 at 2:33 PM Baolin Wang
> <baolin.wang@linux.alibaba.com> wrote:
>>
>> Classical LRU protects mapped executable file folios through commit
>> 8cab4754d24a0 ("vmscan: make mapped executable pages the first class
>> citizen") and commit c909e99364c8 ("vmscan: activate executable pages
>> after first usage"), giving executable code a better chance to stay in
>> memory, avoiding IO thrashing and improving workload performance.
>>
>> However, MGLRU's protection of mapped executable file folios is less
>> reliable. Although shrink_folio_list() checks references, the access flag
>> of mapped executable file folios may have already been checked and
>> cleared by lru_gen_look_around() or walk_mm(). Additionally,
>> folio_update_gen() only sets the 'PG_referenced' flag for mapped executable
>> file folios, which causes shrink_folio_list() to ignore the first usage
>> of these mapped executable file folios and reclaim them.
>>
>> Follow the classical LRU's logic, promoting mapped executable file folios
>> after their first usage in folio_update_gen(), giving executable code a
>> better chance to stay in memory.
>>
>> On my 32-core Arm machine, with the memcg limit set to 2G, running
>> 'make -j32' to build kernel showed some improvement in sys time.
> 
> Hi Baolin,
> 
> Because ARM doesn't set the surrounding PTEs to young, while x86
> may behave differently and mark the surrounding PTEs as young as
> well. Could we also collect the data on x86?
> 
> void set_pte_range(struct vm_fault *vmf, struct folio *folio,
>                  struct page *page, unsigned int nr, unsigned long addr)
> {
>          ...
> 
>          if (prefault && arch_wants_old_prefaulted_pte())
>                  entry = pte_mkold(entry);
>          else
>                  entry = pte_sw_mkyoung(entry);

Sure. But I don't think it's very relevant to this point. MGLRU doesn't 
protect normally accessed mmaped exec file folios well enough. Anyway, 
I'll test it on x86.

  reply	other threads:[~2026-07-15  6:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-15  6:33 Baolin Wang
2026-07-15  6:52 ` Barry Song
2026-07-15  6:58   ` Baolin Wang [this message]
2026-07-15  7:54     ` Barry Song
2026-07-15  7:57       ` Barry Song
2026-07-15  9:00         ` Baolin Wang
2026-07-15 19:44           ` Andrew Morton
2026-07-16  4:06             ` Baolin Wang
2026-07-15 16:50 ` Kairui Song
2026-07-16  2:30   ` Baolin Wang

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=e62cdd47-4812-401d-8c69-51bd483b37ee@linux.alibaba.com \
    --to=baolin.wang@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --cc=axelrasmussen@google.com \
    --cc=baohua@kernel.org \
    --cc=david@kernel.org \
    --cc=kasong@tencent.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@kernel.org \
    --cc=qi.zheng@linux.dev \
    --cc=shakeel.butt@linux.dev \
    --cc=weixugc@google.com \
    --cc=yuanchu@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

all inboxes | Powered by JetHome®