From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-98.freemail.mail.aliyun.com (out30-98.freemail.mail.aliyun.com [115.124.30.98]) (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 D1D17374A12; Tue, 13 Oct 2026 03:12:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.98 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791861160; cv=none; b=sYSRtLi+8rWwMXeFtV0ZbKkzWNdxF2De+Br22rgpnSVOaF9lQwNI+El30IdKwcDYsD/J0xZHYIPzxVQWUoNiSDzifOg3/HoQEoeb3sT0jurSkR1dZL/4hURFQb5V7SWRkfgE6NhsKwY9ZSHdv53PcybG6t3bs2Hq0jgN9O9aYAU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791861160; c=relaxed/simple; bh=cKBnw0HVVyxle7u9yosNmZv3ltQviOkhRmlXJVRymww=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=u/H/2qEJp2uvhdE/KraTgEzQac+nGFAYnU0DSmDkTwzICaBHelEtf14jPJwe4+kpZkQnBGy8zkbs+YG0KsYuYjvGPSArUI2i+2rD8YrMQWBVIw1F9BTr7QIV7YMeZo3IdKFL94pq1gyGV825Af8+kdYg3Vp05k7IeTvn1xdW1aY= 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=S5F0k88r; arc=none smtp.client-ip=115.124.30.98 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="S5F0k88r" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1791861151; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; bh=mhdlXR8A75L7YeWWJ2AV4SzYhiaJarkmp87eHXPOcrA=; b=S5F0k88rgBf+hdnM0/oGyAWVuzwn25NNh8uMVR2BlLkOyRPPcEIY8G+mj+BWq/2PZaM/wmjP++Ejmpe/edEYrjFAvrjbXl02O14qp8Ju2TTGgT0jwgEl0afL+94tqySRD0JYPCl5RbvMcm4GnPqyuE6pLNIrco0SSnYKytsKSro= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R631e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037009110;MF=qinyuntan@linux.alibaba.com;NM=1;PH=DS;RN=23;SR=0;TI=SMTPD_---0XCkEjdu_1791861148; Received: from banye.tbsite.net(mailfrom:qinyuntan@linux.alibaba.com fp:SMTPD_---0XCkEjdu_1791861148 cluster:ay36) by smtp.aliyun-inc.com; Tue, 13 Oct 2026 11:12:29 +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 4/5] mm: thp: restore SHRINKER_NONSLAB on the deferred split shrinker Date: Tue, 13 Oct 2026 11:12:20 +0800 Message-ID: <20261013031221.1997194-5-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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On a system booted with cgroup.memory=nokmem, the deferred split shrinker is demoted to a non-memcg-aware one. As a result, partially unmapped THPs are only split under global reclaim; memcg (limit-induced) reclaim never splits them, so a cgroup under memory pressure keeps its underused THPs intact. The shrinker has carried SHRINKER_NONSLAB since commit 0a432dcbeb32 ("mm: shrinker: make shrinker not depend on memcg kmem") precisely so it would keep working with kmem accounting disabled. Commit fafaeceb89a5 ("mm: switch deferred split shrinker to list_lru") dropped it knowingly: under nokmem the list_lru collapses into a shared per-node list while __list_lru_add() still sets the shrinker bit on whichever memcg happens to add the first item, and with the flag set the shrinker would run twice per reclaim cycle. NONSLAB-backed lrus keep their per-memcg lists under nokmem now, so the shrinker bit identifies the owning memcg again. Restore the flag. This was noticed by Michal during review of the patch "mm/list_lru: don't copy stale shrinker id from non-memcg-aware shrinkers". Link: https://lore.kernel.org/all/ah9PGv12mqai84ES@cmpxchg.org/ Link: https://lore.kernel.org/lkml/697713c4-0857-485b-aba7-c74f37a3c8b4@linux.alibaba.com/ Fixes: fafaeceb89a5 ("mm: switch deferred split shrinker to list_lru") Suggested-by: Michal Koutný Signed-off-by: Qinyun Tan Acked-by: Zi Yan Acked-by: David Hildenbrand (Arm) Acked-by: Usama Arif Reviewed-by: Baolin Wang Reviewed-by: Johannes Weiner --- mm/huge_memory.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index a62d6592af7e..4ddbbdbfcc2d 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1059,7 +1059,8 @@ int folio_memcg_alloc_deferred(struct folio *folio) static int __init thp_shrinker_init(void) { deferred_split_shrinker = shrinker_alloc(SHRINKER_NUMA_AWARE | - SHRINKER_MEMCG_AWARE, + SHRINKER_MEMCG_AWARE | + SHRINKER_NONSLAB, "thp-deferred_split"); if (!deferred_split_shrinker) return -ENOMEM; -- 2.43.7