From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta1.migadu.com (out-59.mta1.migadu.com [95.215.58.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA8F93A784A for ; Mon, 17 Aug 2026 09:03:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.59 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786957433; cv=none; b=BmF9/VwTsN0n2nGIDfEj1awOKiW5hYftwH3zNJ/5Xy6Bt/yDGOUJ2TAPBw8xp3GbgxiZQMcck9TiJ6FQtP2JiXtcStQMYR7uebKjh0AlORy7O4YgJY2L+GetaiZg0N+HdHsuHVvOcslYCqJpwy/Y8x2Zj0hKdDbGeRE2UF2vXuU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786957433; c=relaxed/simple; bh=XzgGDt95Ipn1L8wXhdHD0C7oe53dd7o0MUGLso4B9JU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ZgZKpeAhF3jak+mrPOpxzD9TeRZ4Vc5pahq0GZUD6/CteckNTrjh7cqHu+57jmXxxbc54bz6O1iiHzLOIe6hmqMcSlUv6OG9SF/rYdMaXJGz9iD/2aO0DY87zZ/y+bUUB2Q7VQrK2I+GDJveNLFVeA60wj3Y+FPCH4sKDcFIa+U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=lSpBKF3J; arc=none smtp.client-ip=95.215.58.59 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="lSpBKF3J" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=XzgGDt95Ipn1L8wXhdHD0C7oe53dd7o0MUGLso4B9JU=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1786957429; v=1; x=1787562229; b=lSpBKF3JovltINNhdlyBHQjQpmDZC7EaVo3BtitgSMa01vBkZhvZx+btVWx/rCbVZ85GneFG 1XPdIGQ/Y+G9MCVyaK5sdTxtUqT+fI3chAtFa62CbEatmKJbYdh2l92SChE5HV9z9Tv88wLjI0G rBXcfzUI0otCFiI/zglAPWcg= X-Envelope-To: linux-kernel@vger.kernel.org Received: from localhost.localdomain (221.194.171.228) by smtp.migadu.com with ESMTPS id 62ddee2e1f4fc43a; Mon, 17 Aug 2026 09:03:49 +0000 X-Migadu-Flow: FLOW_OUT From: Qi Zheng To: hughd@google.com, baolin.wang@linux.alibaba.com, usama.arif@linux.dev, brauner@kernel.org, akpm@linux-foundation.org, david@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qi Zheng Subject: [PATCH v4 0/4] make unused huge shrinker memcg aware Date: Mon, 17 Aug 2026 17:03:24 +0800 Message-ID: X-Mailer: git-send-email 2.48.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Qi Zheng Changes in v4: - add [PATCH v4 2/4] to make obj_cgroup_memcg() handle NULL objcg - store obj_cgroup instead of mem_cgroup in shmem_inode_info to avoid pinning a dying memcg through a long-lived CSS reference (pointed by sashiko) - fix is_shmem_unused_huge_match() to always check the NUMA node for shrinker reclaim, not only for non-root memcg reclaim (pointed by sashiko) - collect Reviewed-by - rebase onto the next-20260814 Note: [PATCH v4 1/4] should ideally be folded into commit 0ef8faff490be ("fs: push nr_cached_objects memcg gating into individual filesystems") in linux-next. Changes in v3: - add a fix patch to fix missed removal of super_fs_objects_eligible() - move the original shrinklist addition logic after all checks are completed, and split it into a separate patch. (suggested by Baolin) - simplify the shmem_unused_huge_requeue() (suggested by Baolin) - keep the move_back label in shmem_unused_huge_shrink() (suggested by Baolin) - rebase onto the next-20260731 Changes in v2: - temporarily add the dependent patch from Usama to the series for review convenience - remove shrinklist_scan and shrinklist_isolated from struct shmem_inode_info, and re-implement the logic by resuing the same info->shrinklist (suggested by Baolin) - add more comments (suggested by Andrew) - fix missing initialization of info->shrinklist_memcg (pointed by sashiko) - rebase onto the next-20260717 Hi all, The shmem unused huge shrinker maintains a per-superblock list of inodes whose tail huge folio extends beyond i_size. Because this list is not memcg aware, reclaim triggered by memcg A can scan inodes across the entire superblock and split huge folios charged to unrelated memcg B, causing unexpected impact on it. In the worst case, memcg A has no reclaimable shmem at all, making the reclaim entirely useless and incurring unnecessary latency. We observed this in production, where page lock contention during split caused multi-hundred-millisecond stalls: tid 11340 comm scanner locked a page for 182264 us! kstack: unlock_page+1 split_huge_page_to_list+3135 shmem_unused_huge_shrink+767 super_cache_scan+329 do_shrink_slab+291 shrink_slab+533 shrink_node+400 do_try_to_free_pages+206 try_to_free_mem_cgroup_pages+262 try_charge_memcg+591 mem_cgroup_charge+136 __handle_mm_fault+2431 handle_mm_fault+194 do_user_addr_fault+462 __do_page_fault+176 do_page_fault+48 page_fault+62 Usama's recent patch [1] prevents the shmem unused shrinker from being invoked during memcg-level reclaim altogether, but this is overly conservative: we can do better by reclaiming only the shmem charged to the reclaiming memcg. This series converts the shrinker list to a memcg-aware list_lru, so that non-root memcg reclaim walks only candidates charged to the reclaiming memcg. Global reclaim, root memcg reclaim and shmem quota reclaim retain their existing global semantics. To avoid pinning a dying memcg through a long-lived CSS reference, each inode stores an obj_cgroup reference instead of a mem_cgroup reference. The list_lru add/delete paths resolve the current memcg from the objcg under RCU, staying consistent with list_lru's own memcg migration on offline. Thanks, Qi [1]. https://lore.kernel.org/all/20260715103516.2410175-1-usama.arif@linux.dev/ Qi Zheng (4): fs: fix missed removal of super_fs_objects_eligible() mm: memcontrol: make obj_cgroup_memcg() handle NULL objcg mm: shmem: move unused huge shrinklist queuing past the truncation check mm: shmem: make unused huge shrinker memcg aware fs/super.c | 18 +- include/linux/memcontrol.h | 11 +- include/linux/shmem_fs.h | 12 +- mm/page_owner.c | 2 +- mm/shmem.c | 382 ++++++++++++++++++++++++++++--------- mm/zswap.c | 17 +- 6 files changed, 315 insertions(+), 127 deletions(-) -- 2.54.0