Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Shakeel Butt <shakeel.butt@linux.dev>
To: kasong@tencent.com
Cc: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
	 Axel Rasmussen <axelrasmussen@google.com>,
	Yuanchu Xie <yuanchu@google.com>, Wei Xu <weixugc@google.com>,
	 Johannes Weiner <hannes@cmpxchg.org>,
	David Hildenbrand <david@kernel.org>,
	 Michal Hocko <mhocko@kernel.org>,
	Lorenzo Stoakes <ljs@kernel.org>, Barry Song <baohua@kernel.org>,
	 David Stevens <stevensd@google.com>,
	Chen Ridong <chenridong@huaweicloud.com>,
	 Leno Hou <lenohou@gmail.com>, Yafang Shao <laoar.shao@gmail.com>,
	Yu Zhao <yuzhao@google.com>,
	 Zicheng Wang <wangzicheng@honor.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	 Kalesh Singh <kaleshsingh@google.com>,
	Suren Baghdasaryan <surenb@google.com>,
	 Chris Li <chrisl@kernel.org>, Vernon Yang <vernon2gm@gmail.com>,
	linux-kernel@vger.kernel.org,  Kairui Song <ryncsn@gmail.com>,
	Qi Zheng <qi.zheng@linux.dev>
Subject: Re: [PATCH v7 04/15] mm/mglru: restructure the reclaim loop
Date: Fri, 29 May 2026 22:48:01 -0700	[thread overview]
Message-ID: <ahp5UEnswEZkU8j2@linux.dev> (raw)
In-Reply-To: <20260428-mglru-reclaim-v7-4-02fabb92dc43@tencent.com>

On Tue, Apr 28, 2026 at 02:06:55AM +0800, Kairui Song via B4 Relay wrote:
> From: Kairui Song <kasong@tencent.com>
> 
> The current loop will calculate the scan number on each iteration.  The
> number of folios to scan is based on the LRU length, with some unclear
> behaviors, e.g, the scan number is only shifted by reclaim priority when
> aging is not needed or when at the default priority, and it couples the
> number calculation with aging and rotation.
> 
> Adjust, simplify it, and decouple aging and rotation.  Just calculate the
> scan number for once at the beginning of the reclaim, always respect the
> reclaim priority, and make the aging and rotation more explicit.
> 
> This slightly changes how aging and offline memcg reclaim works:
> Previously, aging was skipped at DEF_PRIORITY even when eviction was no
> longer possible, so the reclaimer wasted an iteration until the priority
> escalated.  Now aging runs immediately whenever it is needed to make
> progress; the DEF_PRIORITY skip only applies when eviction is still
> viable.  This may avoid wasted iterations that over-reclaim slab and break
> reclaim balance in multi-cgroup setups.
> 
> Similar for offline memcg.  Previously, offline memcg wouldn't be aged
> unless it didn't have any evictable folios.  Now, we might age it if it
> has only 3 generations, which should be fine.  On one hand, offline memcg
> might still hold long-term folios, and in fact, a long-existing offline
> memcg must be pinned by some long-term folios like shmem.  These folios
> might be used by other memcg, so aging them as ordinary memcg seems
> correct.  Besides, aging enables further reclaim of an offlined memcg,
> which will certainly happen if we keep shrinking it.  And offline memcg
> might soon be no longer an issue with reparenting.

After the lru folios reparenting, we should not be seeing folios remaining on
offlined memcg LRUs. So, the above para can be removed.

> 
> Overall, the memcg LRU rotation, as described in mmzone.h, remains the
> same.
> 
> Note that because the scan budget is now pinned at loop entry, tiny
> lruvec might skip this reclaim pass, also skipping aging, which could be
> beneficial as aging is not helpful since it will still be un-reclaimable
> after aging. Reclaim will go on as usual once priority escalates.
> 
> Reviewed-by: Axel Rasmussen <axelrasmussen@google.com>
> Signed-off-by: Kairui Song <kasong@tencent.com>

Acked-by: Shakeel Butt <shakeel.butt@linux.dev>



  reply	other threads:[~2026-05-30  5:48 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-27 18:06 [PATCH v7 00/15] mm/mglru: improve reclaim loop and dirty folio handling Kairui Song via B4 Relay
2026-04-27 18:06 ` [PATCH v7 01/15] mm/mglru: consolidate common code for retrieving evictable size Kairui Song via B4 Relay
2026-05-29  5:36   ` Shakeel Butt
2026-04-27 18:06 ` [PATCH v7 02/15] mm/mglru: rename variables related to aging and rotation Kairui Song via B4 Relay
2026-05-29  5:37   ` Shakeel Butt
2026-04-27 18:06 ` [PATCH v7 03/15] mm/mglru: relocate the LRU scan batch limit to callers Kairui Song via B4 Relay
2026-05-29  5:40   ` Shakeel Butt
2026-05-29  6:01     ` Kairui Song
2026-05-29 21:29       ` Shakeel Butt
2026-04-27 18:06 ` [PATCH v7 04/15] mm/mglru: restructure the reclaim loop Kairui Song via B4 Relay
2026-05-30  5:48   ` Shakeel Butt [this message]
2026-04-27 18:06 ` [PATCH v7 05/15] mm/mglru: scan and count the exact number of folios Kairui Song via B4 Relay
2026-04-27 18:06 ` [PATCH v7 06/15] mm/mglru: avoid reclaim type fall back when isolation makes no progress Kairui Song via B4 Relay
2026-04-28  4:18   ` Kairui Song
2026-04-27 18:06 ` [PATCH v7 07/15] mm/mglru: use a smaller batch for reclaim Kairui Song via B4 Relay
2026-04-27 18:06 ` [PATCH v7 08/15] mm/mglru: don't abort scan immediately right after aging Kairui Song via B4 Relay
2026-04-27 18:07 ` [PATCH v7 09/15] mm/mglru: remove redundant swap constrained check upon isolation Kairui Song via B4 Relay
2026-04-27 18:07 ` [PATCH v7 10/15] mm/mglru: use the common routine for dirty/writeback reactivation Kairui Song via B4 Relay
2026-04-27 18:07 ` [PATCH v7 11/15] mm/mglru: simplify and improve dirty writeback handling Kairui Song via B4 Relay
2026-04-27 18:07 ` [PATCH v7 12/15] mm/mglru: remove no longer used reclaim argument for folio protection Kairui Song via B4 Relay
2026-04-27 18:07 ` [PATCH v7 13/15] mm/vmscan: remove sc->file_taken Kairui Song via B4 Relay
2026-04-27 18:07 ` [PATCH v7 14/15] mm/vmscan: remove sc->unqueued_dirty Kairui Song via B4 Relay
2026-04-27 18:07 ` [PATCH v7 15/15] mm/vmscan: unify writeback reclaim statistic and throttling Kairui Song via B4 Relay
2026-04-27 18:22 ` [PATCH v7 00/15] mm/mglru: improve reclaim loop and dirty folio handling Andrew Morton
2026-05-11 18:51 ` Shakeel Butt
2026-05-12  5:08   ` Kairui Song
2026-05-12  5:56     ` Shakeel Butt
2026-05-27  1:35       ` Andrew Morton
2026-05-27  3:25         ` Shakeel Butt
2026-05-27  5:36         ` Kairui Song
2026-05-27 20:40           ` Andrew Morton
2026-05-14 18:50 ` Kairui 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=ahp5UEnswEZkU8j2@linux.dev \
    --to=shakeel.butt@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=axelrasmussen@google.com \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=chenridong@huaweicloud.com \
    --cc=chrisl@kernel.org \
    --cc=david@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=kaleshsingh@google.com \
    --cc=kasong@tencent.com \
    --cc=laoar.shao@gmail.com \
    --cc=lenohou@gmail.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=ryncsn@gmail.com \
    --cc=stevensd@google.com \
    --cc=surenb@google.com \
    --cc=vernon2gm@gmail.com \
    --cc=wangzicheng@honor.com \
    --cc=weixugc@google.com \
    --cc=yuanchu@google.com \
    --cc=yuzhao@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