All of lore.kernel.org
 help / color / mirror / Atom feed
* + mm-workingset-compare-shadow-nodes-node-wide-without-kmem-accounting.patch added to mm-new branch
@ 2026-11-19  3:24 Andrew Morton
  0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-11-19  3:24 UTC (permalink / raw)
  To: mm-commits, yuanchu, ycshark.kim, weixugc, shakeel.butt,
	roman.gushchin, qi.zheng, muchun.song, mkoutny, mhocko, ljs,
	kasong, jason.sim, jaewon31.kim, hannes, dskiba, david, david,
	baoquan.he, baolin.wang, baohua, axelrasmussen, tjmercier, akpm

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 5668 bytes --]


The patch titled
     Subject: mm: workingset: compare shadow nodes node-wide without kmem accounting
has been added to the -mm mm-new branch.  Its filename is
     mm-workingset-compare-shadow-nodes-node-wide-without-kmem-accounting.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-workingset-compare-shadow-nodes-node-wide-without-kmem-accounting.patch

This patch will later appear in the mm-new branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews.  Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.

The mm-new branch of mm.git is not included in linux-next

If a few days of testing in mm-new is successful, the patch will me moved
into mm.git's mm-unstable branch, which is included in linux-next

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days

------------------------------------------------------
From: "T.J. Mercier" <tjmercier@google.com>
Subject: mm: workingset: compare shadow nodes node-wide without kmem accounting
Date: Fri,  6 Nov 2026 15:59:04 -0800

count_shadow_nodes() limits the number of xarray nodes holding shadow
entries to 1/8th of the pages that could be using them.  For a memcg, it
counts the LRU and slab pages local to that memcg.

With kmem accounting disabled (cgroup.memory=nokmem), shadow nodes are not
charged to any memcg and __list_lru_init() makes the shadow_nodes list_lru
non-memcg-aware, so all shadow nodes of a NUMA node are on a single list. 
shrinker_alloc() falls back to a non-memcg-aware shadow node shrinker,
which shrink_slab() only invokes for the root memcg.  count_shadow_nodes()
therefore compares every shadow node on the NUMA node against the pages
local to the root memcg.

When most tasks run in child memcgs, the root memcg only holds a small
fraction of all pages, so the shadow node limit derived from the root
memcg page count is far below the number of shadow nodes on the NUMA node.
Since the shrinker has seeks == 0, every root shrink_slab() call trims
about half of the "excess" shadow nodes.  Most refault information is
thrown away, so refaults of recently evicted file folios are not detected.
Refaulted folios lose PG_workingset and the workingset_refault and
workingset_restore stats drop.

In testing on devices with kmem accounting disabled, moving tasks from the
root memcg into per-application memcgs dropped workingset_nodes from
~37,000 to ~900 and raised workingset_nodereclaim 4.6x while pgsteal_file
rose by ~12%.

When kmem accounting is disabled, compare the shadow nodes against the
whole NUMA node, as is done without memcg.  Behavior with kmem accounting
enabled is unchanged.

Link: https://lore.kernel.org/20261106235904.1092712-1-tjmercier@google.com
Signed-off-by: T.J. Mercier <tjmercier@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Tested-by: Jaeseon Sim <jason.sim@samsung.com> # Galaxy A18 LTE
Tested-by: Youngchan Kim <ycshark.kim@samsung.com> # Galaxy S27
Tested-by: Dmitry Skiba <dskiba@google.com> # Pixel 10
Reviewed-by: Barry Song <baohua@kernel.org>
Reviewed-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Jaewon Kim <jaewon31.kim@samsung.com>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Qi Zheng <qi.zheng@linux.dev>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Michal Koutný <mkoutny@suse.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Kairui Song <kasong@tencent.com>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: Yuanchu Xie <yuanchu@google.com>
Cc: Wei Xu <weixugc@google.com>
Cc: Baoquan He <baoquan.he@linux.dev>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>

 mm/workingset.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

--- a/mm/workingset.c~mm-workingset-compare-shadow-nodes-node-wide-without-kmem-accounting
+++ a/mm/workingset.c
@@ -682,7 +682,16 @@ static unsigned long count_shadow_nodes(
 	 * PAGE_SIZE / xa_nodes / node_entries * 8 / PAGE_SIZE
 	 */
 #ifdef CONFIG_MEMCG
-	if (sc->memcg) {
+	/*
+	 * Without kmem accounting the shadow_nodes list_lru is not
+	 * memcg-aware. So the count above covers the whole NUMA node, and the
+	 * shrinker only runs for the root memcg, whose local pages can be a
+	 * small fraction of the node's when most tasks run in child memcgs.
+	 * Compare the shadow node count against the memcg page count only when
+	 * the shadow_nodes list_lru is memcg-aware. Otherwise use the NUMA node
+	 * page count as is done without memcg.
+	 */
+	if (sc->memcg && shadow_nodes.memcg_aware) {
 		struct lruvec *lruvec;
 		int i;
 
_

Patches currently in -mm which might be from tjmercier@google.com are

mm-vmscan-remove-redundant-mem_cgroup_online-checks.patch
mm-mglru-stop-rotating-offlined-memcgs-to-the-old-generation.patch
mm-workingset-compare-shadow-nodes-node-wide-without-kmem-accounting.patch


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-19  3:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19  3:24 + mm-workingset-compare-shadow-nodes-node-wide-without-kmem-accounting.patch added to mm-new branch Andrew Morton

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.