Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ridong Chen <ridong.chen@linux.dev>
To: Barry Song <baohua@kernel.org>
Cc: Kairui Song <ryncsn@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@kernel.org>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Qi Zheng <qi.zheng@linux.dev>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	Axel Rasmussen <axelrasmussen@google.com>,
	Yuanchu Xie <yuanchu@google.com>, Wei Xu <weixugc@google.com>,
	Baoquan He <baoquan.he@linux.dev>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	"Liam R. Howlett" <liam@infradead.org>,
	Vlastimil Babka <vbabka@kernel.org>,
	Mike Rapoport <rppt@kernel.org>, Michal Hocko <mhocko@suse.com>,
	"open list:MEMORY MANAGEMENT - MGLRU (MULTI-GEN LRU)"
	<linux-mm@kvack.org>, Ridong Chen <chenridong@xiaomi.com>
Subject: Re: [RFC PATCH 0/2] mm/mglru: shorten the lru_lock hold time in scan_folios()
Date: Fri, 4 Dec 2026 19:00:04 +0800	[thread overview]
Message-ID: <e4597f98-912f-4feb-b61b-cbad651a3c11@linux.dev> (raw)
In-Reply-To: <CAGsJ_4zOQQn=Gjxnam+A5w9ufNHEBxoB+KKLvcEP9a_378DCuw@mail.gmail.com>



On 12/4/2026 6:51 PM, Barry Song wrote:
> On Fri, Dec 4, 2026 at 6:36 PM Ridong Chen <ridong.chen@linux.dev> wrote:
> [...]
>>>
>>
>> Hi Kairui,
>>
>> Sorry for the late reply.
>>
>> I've been looking at MGLRU direct reclaim tail latency on Android.
>> When many tasks enter direct reclaim at the same time they pile up on
>> the same memcgs and slow each other down [1], so the time spent under
>> lru_lock matters there.
>>
>> To check the prefetch on arm64, I ran the same kind of microbenchmark
>> on an 8-CPU tablet: random 4K pread() on files 3x the memcg limit,
>> one thread per CPU, all threads in one memcg, base and patched
>> interleaved in one boot, 5 rounds each. Reads per second per thread:
>>
>> threads    base     prefetch
>>      1     180688      +1.5%
>>      2     189663      +2.0%
>>      4     181787      +3.2%
>>      6     168018      +3.8%
>>      8     146523      +6.1%
>>
>>   From 4 threads on, every round was faster, and there was no regression
>> with 1 thread.
> 
> I think this one-line change is fine if the data supports it.
> Usually, though, this kind of optimization warrants an explanation
> at the microarchitectural level, for example, using the top-down
> analysis model to identify where the CPU stalls.
> 
> I assume prefetching reduces memory-bound stalls, but what I don't
> quite understand is why it provides a greater benefit in
> multithreaded workloads. Could this be due to increased cache
> contention and more frequent cache evictions?
> 

The benchmark is concurrent reclaim on one memcg: all threads reclaim
from the same lruvec and serialize on lruvec_lock_irq(). The prefetch
shortens the critical section in scan_folios(), so the gain is in how
long the other reclaimers wait for the lock, not in the reclaimer
itself. With one thread nobody waits, so there is no change. With
more threads, the more of them wait, the bigger the gain.

> Would it be possible to perform a top-down analysis [1], at least
> on x86 if that's easier, to gain a deeper understanding of the
> performance improvement?
> 
> [1] https://github.com/andikleen/pmu-tools
> 
> Thanks,
> Barry

-- 
Best regards
Ridong



  reply	other threads:[~2026-12-04 11:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27  6:03 [RFC PATCH 0/2] mm/mglru: shorten the lru_lock hold time in scan_folios() Ridong Chen
2026-11-27  6:03 ` [RFC PATCH 1/2] mm/mglru: update LRU sizes once per zone when isolating folios Ridong Chen
2026-11-27  6:03 ` [RFC PATCH 2/2] mm/mglru: prefetch the previous folio in scan_folios() Ridong Chen
2026-11-27 19:34 ` [RFC PATCH 0/2] mm/mglru: shorten the lru_lock hold time " Kairui Song
2026-11-28  1:00   ` Ridong Chen
2026-11-28  8:30     ` Kairui Song
2026-12-04 10:36       ` Ridong Chen
2026-12-04 10:51         ` Barry Song
2026-12-04 11:00           ` Ridong Chen [this message]
2026-12-04 11:12             ` 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=e4597f98-912f-4feb-b61b-cbad651a3c11@linux.dev \
    --to=ridong.chen@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=axelrasmussen@google.com \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=baoquan.he@linux.dev \
    --cc=chenridong@xiaomi.com \
    --cc=david@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=liam@infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=qi.zheng@linux.dev \
    --cc=rppt@kernel.org \
    --cc=ryncsn@gmail.com \
    --cc=shakeel.butt@linux.dev \
    --cc=vbabka@kernel.org \
    --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