From: Balbir Singh <balbirs@nvidia.com>
To: "T.J. Mercier" <tjmercier@google.com>
Cc: roman.gushchin@linux.dev, muchun.song@linux.dev,
Andrew Morton <akpm@linux-foundation.org>,
Kairui Song <kasong@tencent.com>, Qi Zheng <qi.zheng@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
Barry Song <baohua@kernel.org>,
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>,
David Hildenbrand <david@kernel.org>,
Lorenzo Stoakes <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>, Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Randy Dunlap <rdunlap@infradead.org>,
Johannes Weiner <hannes@cmpxchg.org>,
cgroups@vger.kernel.org, linux-mm@kvack.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] mm/mglru: stop rotating offlined memcgs to the old generation
Date: Wed, 28 Oct 2026 13:42:20 +1100 [thread overview]
Message-ID: <auFhDMtwymMynf8j@parvat> (raw)
In-Reply-To: <20261028010611.3929937-3-tjmercier@google.com>
On Tue, Oct 27, 2026 at 06:06:06PM -0700, T.J. Mercier wrote:
> lru_gen_offline_memcg() moves an offlining memcg to the head of the old
> generation of the memcg LRU (MEMCG_LRU_OLD), so that global reclaim
> visits it first and evicts the folios it left behind.
>
> Since commit f1cf8d2f36dc ("mm: memcontrol: eliminate the problem of
> dying memory cgroup for LRU folios"), those folios are reparented to the
> parent before lru_gen_offline_memcg() runs, and nothing can be added
> back to the offlined memcg's lruvec afterwards. Putting an empty
> offlined memcg at the head of the old generation no longer serves any
> purpose and only delays reclaim from the memcgs that still have memory
> due to additional shrink_many() iteration.
>
> Remove lru_gen_offline_memcg(), so that an offlined memcg is rotated
> like any other memcg below the reclaimable size threshold until
> lru_gen_release_memcg() takes it off the memcg LRU. MEMCG_LRU_OLD has no
> other user, so remove the op and update the memcg LRU comment as well.
>
> Signed-off-by: T.J. Mercier <tjmercier@google.com>
> ---
> Documentation/mm/multigen_lru.rst | 4 +---
> include/linux/mmzone.h | 14 +++-----------
> mm/memcontrol.c | 1 -
> mm/vmscan.c | 20 +-------------------
> 4 files changed, 5 insertions(+), 34 deletions(-)
>
> diff --git a/Documentation/mm/multigen_lru.rst b/Documentation/mm/multigen_lru.rst
> index 52ed5092022f..b532ce961371 100644
> --- a/Documentation/mm/multigen_lru.rst
> +++ b/Documentation/mm/multigen_lru.rst
> @@ -234,9 +234,7 @@ the active/inactive LRU (of folios):
> 1. It has the young and the old (generations), i.e., the counterparts
> to the active and the inactive;
> 2. The increment of ``max_seq`` triggers promotion, i.e., the
> - counterpart to activation;
> -3. Other events trigger similar operations, e.g., offlining an memcg
> - triggers demotion, i.e., the counterpart to deactivation.
> + counterpart to activation.
>
> In terms of global reclaim, it has two distinct features:
>
> diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
> index 7f078ff0dd76..542e465ee7a1 100644
> --- a/include/linux/mmzone.h
> +++ b/include/linux/mmzone.h
> @@ -626,12 +626,10 @@ struct lru_gen_mm_walk {
> * per-node memcg generation counter, whose reminder (mod MEMCG_NR_GENS) indexes
> * the old generation, is incremented when all its bins become empty.
> *
> - * There are three operations:
> + * There are two operations:
> * 1. MEMCG_LRU_TAIL, which moves a memcg to the tail of a random bin in its
> * current generation (old or young) and updates its "seg" to "tail";
> - * 2. MEMCG_LRU_OLD, which moves a memcg to the head of a random bin in the old
> - * generation, updates its "gen" to "old" and resets its "seg" to "default";
> - * 3. MEMCG_LRU_YOUNG, which moves a memcg to the tail of a random bin in the
> + * 2. MEMCG_LRU_YOUNG, which moves a memcg to the tail of a random bin in the
> * young generation, updates its "gen" to "young" and resets its "seg" to
> * "default".
> *
> @@ -643,8 +641,7 @@ struct lru_gen_mm_walk {
> * 3. The second attempt to reclaim a memcg below reclaimable size threshold,
> * which triggers MEMCG_LRU_YOUNG;
> * 4. Attempting to reclaim a memcg below min, which triggers MEMCG_LRU_YOUNG;
> - * 5. Finishing the aging on the eviction path, which triggers MEMCG_LRU_YOUNG;
> - * 6. Offlining a memcg, which triggers MEMCG_LRU_OLD.
> + * 5. Finishing the aging on the eviction path, which triggers MEMCG_LRU_YOUNG.
> *
> * Notes:
> * 1. Memcg LRU only applies to global reclaim, and the round-robin incrementing
> @@ -675,7 +672,6 @@ bool lru_gen_look_around(struct page_vma_mapped_walk *pvmw, unsigned int nr);
> void lru_gen_init_memcg(struct mem_cgroup *memcg);
> void lru_gen_exit_memcg(struct mem_cgroup *memcg);
> void lru_gen_online_memcg(struct mem_cgroup *memcg);
> -void lru_gen_offline_memcg(struct mem_cgroup *memcg);
> void lru_gen_release_memcg(struct mem_cgroup *memcg);
> void max_lru_gen_memcg(struct mem_cgroup *memcg, int nid);
> bool recheck_lru_gen_max_memcg(struct mem_cgroup *memcg, int nid);
> @@ -709,10 +705,6 @@ static inline void lru_gen_online_memcg(struct mem_cgroup *memcg)
> {
> }
>
> -static inline void lru_gen_offline_memcg(struct mem_cgroup *memcg)
> -{
> -}
> -
> static inline void lru_gen_release_memcg(struct mem_cgroup *memcg)
> {
> }
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index a05d9a8baa1b..e2ddf0680e62 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -4475,7 +4475,6 @@ static void mem_cgroup_css_offline(struct cgroup_subsys_state *css)
> memcg_reparent_objcgs(memcg);
> reparent_shrinker_deferred(memcg);
> wb_memcg_offline(memcg);
> - lru_gen_offline_memcg(memcg);
>
> drain_all_stock(memcg);
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 636152d8c94d..45a2c1021f4f 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -4538,7 +4538,6 @@ bool lru_gen_look_around(struct page_vma_mapped_walk *pvmw, unsigned int nr)
> enum {
> MEMCG_LRU_NOP,
> MEMCG_LRU_TAIL,
> - MEMCG_LRU_OLD,
> MEMCG_LRU_YOUNG,
> };
>
> @@ -4560,8 +4559,6 @@ static void lru_gen_rotate_memcg(struct lruvec *lruvec, int op)
> /* see the comment on MEMCG_NR_GENS */
> if (op == MEMCG_LRU_TAIL)
> seg = MEMCG_LRU_TAIL;
> - else if (op == MEMCG_LRU_OLD)
> - new = get_memcg_gen(pgdat->memcg_lru.seq);
> else if (op == MEMCG_LRU_YOUNG)
> new = get_memcg_gen(pgdat->memcg_lru.seq + 1);
> else
> @@ -4571,11 +4568,7 @@ static void lru_gen_rotate_memcg(struct lruvec *lruvec, int op)
> WRITE_ONCE(lruvec->lrugen.gen, new);
>
> hlist_nulls_del_rcu(&lruvec->lrugen.list);
> -
> - if (op == MEMCG_LRU_OLD)
> - hlist_nulls_add_head_rcu(&lruvec->lrugen.list, &pgdat->memcg_lru.fifo[new][bin]);
> - else
> - hlist_nulls_add_tail_rcu(&lruvec->lrugen.list, &pgdat->memcg_lru.fifo[new][bin]);
> + hlist_nulls_add_tail_rcu(&lruvec->lrugen.list, &pgdat->memcg_lru.fifo[new][bin]);
>
> pgdat->memcg_lru.nr_memcgs[old]--;
> pgdat->memcg_lru.nr_memcgs[new]++;
> @@ -4613,17 +4606,6 @@ void lru_gen_online_memcg(struct mem_cgroup *memcg)
> }
> }
>
> -void lru_gen_offline_memcg(struct mem_cgroup *memcg)
> -{
> - int nid;
> -
> - for_each_node(nid) {
> - struct lruvec *lruvec = get_lruvec(memcg, nid);
> -
> - lru_gen_rotate_memcg(lruvec, MEMCG_LRU_OLD);
> - }
> -}
> -
> void lru_gen_release_memcg(struct mem_cgroup *memcg)
> {
> int gen;
Acked-by: Balbir Singh <balbirs@nvidia.com>
next prev parent reply other threads:[~2026-10-28 2:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 1:06 [PATCH 0/2] mm/vmscan: remove obsolete offlined memcg reclaim handling T.J. Mercier
2026-10-28 1:06 ` [PATCH 2/2] mm/mglru: stop rotating offlined memcgs to the old generation T.J. Mercier
2026-10-28 2:42 ` Balbir Singh [this message]
2026-10-28 10:43 ` 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=auFhDMtwymMynf8j@parvat \
--to=balbirs@nvidia.com \
--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=cgroups@vger.kernel.org \
--cc=corbet@lwn.net \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kasong@tencent.com \
--cc=liam@infradead.org \
--cc=linux-doc@vger.kernel.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=qi.zheng@linux.dev \
--cc=rdunlap@infradead.org \
--cc=roman.gushchin@linux.dev \
--cc=rppt@kernel.org \
--cc=shakeel.butt@linux.dev \
--cc=skhan@linuxfoundation.org \
--cc=surenb@google.com \
--cc=tjmercier@google.com \
--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