All of lore.kernel.org
 help / color / mirror / Atom feed
From: Usama Arif <usama.arif@linux.dev>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: david@kernel.org, ljs@kernel.org, liam@infradead.org,
	vbabka@kernel.org, rppt@kernel.org, surenb@google.com,
	mhocko@suse.com, kasong@tencent.com, qi.zheng@linux.dev,
	shakeel.butt@linux.dev, axelrasmussen@google.com,
	yuanchu@google.com, weixugc@google.com, chrisl@kernel.org,
	nphamcs@gmail.com, baoquan.he@linux.dev, youngjun.park@lge.com,
	hannes@cmpxchg.org, roman.gushchin@linux.dev,
	muchun.song@linux.dev, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, cgroups@vger.kernel.org,
	rientjes@google.com, kernel-team@meta.com
Subject: Re: [PATCH v4 0/2] mm/vmscan: reduce lru_lock contention via vmstat-derived scan-balance cost
Date: Fri, 24 Jul 2026 14:31:12 +0100	[thread overview]
Message-ID: <fb6b983e-843d-454c-bfa1-ec802228f981@linux.dev> (raw)
In-Reply-To: <20260723133548.2e12b638bd629ef63b935113@linux-foundation.org>



On 23/07/2026 21:35, Andrew Morton wrote:
> On Mon, 20 Jul 2026 09:41:21 -0700 Usama Arif <usama.arif@linux.dev> wrote:
> 
>> The anon/file scan balance heuristic in get_scan_count() is fed by two
>> scalars in struct lruvec (anon_cost, file_cost) that every reclaim
>> producer updates under lruvec->lru_lock. The cost-recording work
>> itself is trivial, but it both contends for and contributes to
>> contention on lru_lock - which is often a contention point on
>> memory-pressured workloads. Specifically:
>>
>> - shrink_inactive_list() re-acquires lru_lock at function exit just
>>   to call lru_note_cost_unlock_irq().
>> - shrink_active_list() does the same after rotation accounting.
>> - workingset_refault() takes folio_lruvec_lock_irq() purely to
>>   record the refault cost.
>> - prepare_scan_control() snapshots anon_cost/file_cost under
>>   lru_lock.
>> - lru_note_cost_unlock_irq() itself walks parent_lruvec() and
>>   re-acquires lru_lock on every ancestor, multiplying the cost
>>   of every update by memcg-hierarchy depth.
>>
>> This series removes those producer-side acquisitions entirely.
> 
> Thanks.  We're still awaiting review of [2/2].  I'll get this under
> test in order to parallelize things.

Thanks Andrew! Yes I think we have the reviews, but just 1 outstanding
comment from Shakeel and need to shorten commit message as Johannes
mentioned. Hopefully we will have a final version next week.

> 
>> Measurement is a 30 s `perf lock record -a` window
>> over otherwise-idle hardware.
>>
>> Workload rates are identical on both kernels (the bench drives the
>> same memory pressure):
>>
>>                           baseline    patched      delta
>>   pgscan_direct  / s      172,662     171,817      ~0%
>>   pgsteal_direct / s       67,162      66,306      ~0%
>>   workingset_refault_anon / s
>>                            40,696      39,830      ~0%
>>
>> perf lock contention (total wait per 30 s window):
>>
>>   Lock Name                Before      After     % change
>>   shrink_lruvec+0x770     722.84 ms    0         -100% (eliminated)
>>         (= lru_note_cost_unlock_irq)
>>   workingset_refault+0x167 385.26 ms   0         -100% (eliminated)
>>         (= lru_note_cost_refault)
>>   shrink_node+0x4ad       689.43 ms    26.95 ms  -96%
>>   shrink_active_list      208.34 ms    15.97 ms  -92%
>>   lru_add_drain_cpu+0x34    1.96 s    917.71 ms  -53%
>>
>>   Total LRU lock wait      ~4.23 s     ~1.66 s   -61%
> 
> So it saves 2.5 seconds out of 30 seconds?

Yes 2.5 seconds total CPU time in the 30 second perf record.



      reply	other threads:[~2026-07-24 13:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-20 16:41 [PATCH v4 0/2] mm/vmscan: reduce lru_lock contention via vmstat-derived scan-balance cost Usama Arif
2026-07-20 16:41 ` [PATCH v4 1/2] mm/vmstat, mm/memcontrol: add _monotonic vmstat readers Usama Arif
2026-07-23 19:41   ` Shakeel Butt
2026-07-20 16:41 ` [PATCH v4 2/2] mm/vmscan: reduce lru_lock contention via vmstat-derived scan-balance cost Usama Arif
2026-07-23 20:25   ` Johannes Weiner
2026-07-24  1:53   ` Shakeel Butt
2026-07-24 13:29     ` Usama Arif
2026-07-23 20:35 ` [PATCH v4 0/2] " Andrew Morton
2026-07-24 13:31   ` Usama Arif [this message]

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=fb6b983e-843d-454c-bfa1-ec802228f981@linux.dev \
    --to=usama.arif@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=axelrasmussen@google.com \
    --cc=baoquan.he@linux.dev \
    --cc=cgroups@vger.kernel.org \
    --cc=chrisl@kernel.org \
    --cc=david@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=kasong@tencent.com \
    --cc=kernel-team@meta.com \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=muchun.song@linux.dev \
    --cc=nphamcs@gmail.com \
    --cc=qi.zheng@linux.dev \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=rppt@kernel.org \
    --cc=shakeel.butt@linux.dev \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    --cc=weixugc@google.com \
    --cc=youngjun.park@lge.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.