From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) (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 0693935C6B9; Tue, 13 Oct 2026 03:12:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791861160; cv=none; b=Nqw2V2HbcKyHdUSX+Jl0yqXamwxVa9VHm+IcWs9di5fK+l2XoEtS80dIPDexvz/GpyAjoUjvyCTAV+16tKNaY3RVwdY4WfIpprrllMo1Vz/1XSqV4NcNO/lUvHcFU2gnmGogHnkk3rDYMQHQObwQNG4YYp2OIt4q9L/g1fQZ7Fs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791861160; c=relaxed/simple; bh=EC9nAHk+K2TPuQZdh2tqhkTGbDJCnfDnBB79UHGYPt4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XmIs4qb6TB2EiuiKuA9s/cfS6aBHaGZWgHtNu2ngq285MEGnqHaTFg2sNMyphh2VPvLPLrj7IoFKWwbnxu3rvxOLVcac5jGspHZaieQQkAeaxLKiDqjXtx5r/YZxfyXP7u7k353Or9kH01Nd6ONeFdC2YDMmA15+sLrSmBo2FNI= 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=SJ/tpuiO; arc=none smtp.client-ip=115.124.30.124 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="SJ/tpuiO" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1791861150; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=goZgGhsuDnXRMkG633Mg/AsrAm2B4reGrlV8Qh0TTu0=; b=SJ/tpuiOv6lSj0kPhKuS/IUcX7UYeo+BWeZEXRP1sALyw3Lj37EnZYSHoblxNKd3CCuy76mNYokm9l06KmO4al8+ysd+uw053peJgCjRo9u9Al7A0fqHSPqO4Fvx/1t1RdCIeAfe8jfc9NibzYNxJjKrPXkWF7X77OHg3wP3Y7M= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R191e4;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=23;SR=0;TI=SMTPD_---0XCkEjdM_1791861147; Received: from banye.tbsite.net(mailfrom:qinyuntan@linux.alibaba.com fp:SMTPD_---0XCkEjdM_1791861147 cluster:ay36) by smtp.aliyun-inc.com; Tue, 13 Oct 2026 11:12:28 +0800 From: Qinyun Tan To: akpm@linux-foundation.org Cc: hannes@cmpxchg.org, mhocko@kernel.org, roman.gushchin@linux.dev, shakeel.butt@linux.dev, muchun.song@linux.dev, mkoutny@suse.com, david@kernel.org, ziy@nvidia.com, baolin.wang@linux.alibaba.com, usama.arif@linux.dev, david@fromorbit.com, qi.zheng@linux.dev, yosry@kernel.org, nphamcs@gmail.com, chengming.zhou@linux.dev, xlpang@linux.alibaba.com, ryncsn@gmail.com, gourry@gourry.net, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qinyun Tan Subject: [PATCH v4 3/5] mm: list_lru: keep per-memcg lists with nokmem for NONSLAB-backed lrus Date: Tue, 13 Oct 2026 11:12:19 +0800 Message-ID: <20261013031221.1997194-4-qinyuntan@linux.alibaba.com> X-Mailer: git-send-email 2.43.7 In-Reply-To: <20261013031221.1997194-1-qinyuntan@linux.alibaba.com> References: <20261013031221.1997194-1-qinyuntan@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-kernel@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 Reviewed-by: Johannes Weiner --- 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 8e9577c5cb19..7c8d0b959bed 100644 --- a/mm/list_lru.c +++ b/mm/list_lru.c @@ -690,7 +690,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