From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 533FD47668B; Mon, 7 Sep 2026 11:01:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.132 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788778885; cv=none; b=m46DdYKz/VNyMhHzr4OXQYh5PfrAimUiCZ8mEZWXwwe5saAxZcDxYOP80/qjB06u/sbXgXGwmi33GSkdZeJwLMRg48FqYt8QhVp0yIR3vNHsKq8bNfZEcWYrF9HvAI9UtDs3N4v5nIYo572QOC34u1HfQsKIo4jiKBT8tKToBlo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788778885; c=relaxed/simple; bh=VCcBOevO7v28DR9ElX4VKsm9629srGlmO6ARvLKxABY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AAVZuMtmok09RQIQ2CO39y5g6pv7De9uv2/+yJ7G9LeXYe+lb7uqGT6zJJZCML0FNYLMbaFlkkvtl84l0hzRJJjAzZ5AsfYGI/H+9fxCTkDJ0YdGMed/Y7PyP1p6nx92aGdw+LvXXtIOawnzZWKgpYwFEqLmIleRe6bm/wfetuM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=B78lB6sL; arc=none smtp.client-ip=115.124.30.132 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="B78lB6sL" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1788778879; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=wwR9RFSxdLQeFFx4l5snm8ZYfxhsC29aBhmlxjFMRxc=; b=B78lB6sLNzoq4YrESjvHeWhAidY6vhXDEDiGBpAG9bUZ7QyZk7fP9WOdaP+b1UvEiDmywiBCl890De1b1KvaAat0FLlr9kGq4FCXidMbI00xztWLaSEbWTpK7VCxf/cDqfsjhE8lNGRLkha6P7kCuIEMjbTm1YyiillVrLHDaQc= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R471e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam011083073210;MF=qinyuntan@linux.alibaba.com;NM=1;PH=DS;RN=21;SR=0;TI=SMTPD_---0XATsw-l_1788778876; Received: from banye.tbsite.net(mailfrom:qinyuntan@linux.alibaba.com fp:SMTPD_---0XATsw-l_1788778876 cluster:ay36) by smtp.aliyun-inc.com; Mon, 07 Sep 2026 19:01:17 +0800 From: Qinyun Tan To: Andrew Morton Cc: Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , =?UTF-8?q?Michal=20Koutn=C3=BD?= , David Hildenbrand , Zi Yan , Baolin Wang , Usama Arif , Dave Chinner , Qi Zheng , Yosry Ahmed , Nhat Pham , Chengming Zhou , Xunlei Pang , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qinyun Tan Subject: [PATCH v2 2/4] mm: list_lru: keep per-memcg lists with nokmem for NONSLAB-backed lrus Date: Mon, 7 Sep 2026 19:01:09 +0800 Message-ID: <20260907110111.2286932-3-qinyuntan@linux.alibaba.com> X-Mailer: git-send-email 2.43.7 In-Reply-To: <20260907110111.2286932-1-qinyuntan@linux.alibaba.com> References: <20260907110111.2286932-1-qinyuntan@linux.alibaba.com> Precedence: bulk X-Mailing-List: cgroups@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit With cgroup.memory=nokmem, __list_lru_init() collapses every list_lru into per-node lists. That is fine for slab objects, which are not charged per memcg without kmem accounting. But a lru backed by a SHRINKER_NONSLAB shrinker, e.g. the THP deferred split queue or the zswap entries, holds user memory, which is charged regardless of nokmem. Collapsing such an lru loses the per-memcg view of its objects. Reclaim can no longer target just the cgroup under pressure. Keep such lrus memcg aware under nokmem when their backing shrinker is registered SHRINKER_NONSLAB. This leaves the savings of nokmem intact: slab-backed lrus (e.g. the superblock dentry/inode lrus) still fall back to the per-node lists, and the per-memcg lists are allocated only when a memcg actually holds such objects. Fixes: fafaeceb89a5 ("mm: switch deferred split shrinker to list_lru") Signed-off-by: Qinyun Tan --- mm/list_lru.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/list_lru.c b/mm/list_lru.c index 6fd4e9af84396..e84eff313a683 100644 --- a/mm/list_lru.c +++ b/mm/list_lru.c @@ -671,7 +671,9 @@ int __list_lru_init(struct list_lru *lru, bool memcg_aware, struct shrinker *shr else lru->shrinker_id = -1; - if (mem_cgroup_disabled() || mem_cgroup_kmem_disabled()) + if (mem_cgroup_disabled() || + (mem_cgroup_kmem_disabled() && + (!shrinker || !(shrinker->flags & SHRINKER_NONSLAB)))) memcg_aware = false; #endif -- 2.43.7