From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) (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 9BEF93C870E for ; Wed, 15 Jul 2026 09:37:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784108251; cv=none; b=qqpJXZ45MSM+xeP5a9Tk+bf+fXZt0W0WFsImeHDlScI87bRzmaV1a/eF1MCRd6VULcTFIFvdsr7rVuCGz9gTVlAXjqR8zIv+6MmBD/Sn4QNWuHMYJeOiaYaP0ii8KIIPunj7yJ15+3hBrsUxPffcQytLMZL9nl4Kp6hN+xOhfNs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784108251; c=relaxed/simple; bh=Rtn6sPWLe4AF3ME3MN9zJMWxFHQJ/jJF1X6MmkPm5cg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=eGkwqtG2SYLub65DwSHXPeTwc+y3v82jkhmsQNn3UdOceGTSpRAQyy7YnnAq2WlB6T4E5wsNZqkgyfUHkyieM8qb92WnmX1Rw/jGLJ8+8Hjk0iVrThggWZSSFljoMhu4yNLx38tqIKLYLTUvQ4tTRRtQt/J1nRpNxE6CzU+MiZA= 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=f9VbfwKT; arc=none smtp.client-ip=115.124.30.133 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="f9VbfwKT" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1784108241; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=eptxYIPlyXI5yfUO3tYamEyvhpSBeHvL6Xe1xWPd1To=; b=f9VbfwKTFuA20g4zFy3Fgsgw2e4kzi8h76JqGrwoQZUNKglG1uh6R8PYgGDkxNkUj1thekNgQfpcTe9YaJxoHmI9bTJs3WghgKElHy7PiyVbWtoN6/PgpCN2FT7GEPfZ+XrkwcY7mpK4k77/j9LNRHttWFFKKveU4zB2JwV13do= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037033178;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0X78cEzU_1784108239; Received: from 30.74.144.123(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0X78cEzU_1784108239 cluster:ay36) by smtp.aliyun-inc.com; Wed, 15 Jul 2026 17:37:20 +0800 Message-ID: <7624107f-6a2d-4959-b2ee-aa362a8972eb@linux.alibaba.com> Date: Wed, 15 Jul 2026 17:37:17 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mm: shmem: make unused huge shrinker memcg aware To: Qi Zheng , hughd@google.com, akpm@linux-foundation.org, usama.arif@linux.dev Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qi Zheng References: <20260714031918.308-1-qi.zheng@linux.dev> From: Baolin Wang In-Reply-To: <20260714031918.308-1-qi.zheng@linux.dev> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Qi, On 7/14/26 11:19 AM, Qi Zheng wrote: > From: Qi Zheng > > The shmem unused huge shrinker keeps a per-superblock list of inodes whose > tail huge folio extends beyond i_size. Since that list is not memcg aware, > reclaim triggered by one memcg can scan inodes from the whole superblock > and split shmem huge folios charged to unrelated memcgs. > > Convert the shrink list to a memcg-aware list_lru. Queue each inode on the > list_lru sublist matching the memcg and node of the current tail huge > folio, so non-root memcg reclaim only walks candidates charged to the > reclaiming memcg. Global reclaim, root memcg reclaim and shmem quota > reclaim keep global semantics. > > The list_lru still tracks inodes while the actual split target is the > current tail huge folio, so validate the folio memcg/node during scan. If > the folio no longer matches the reclaim context or splitting cannot > proceed, requeue the inode according to the current tail folio; if the > inode is no longer shrinkable, drop the scan entry. > > This can be tested with the shrinker debugfs interface by allocating 32 > tmpfs tail THPs in each of two memcgs, then scanning the sb-tmpfs shrinker > with memcg A's cgroup id: > > before A scan after A scan > base A=64M, B=64M A=0, B=0 > patched A=64M, B=64M A=0, B=64M > > Signed-off-by: Qi Zheng > --- Thanks for your patch. This work has been on my TODO list for a while :) Overall it looks good. I'll take a closer look and run some tests. > This patch is based on next-20260701 because it doesn't include this patch: > > https://lore.kernel.org/all/20260609123047.1948242-1-usama.arif@linux.dev/ > > Later on, Usama will consider moving this restriction down into the fs callback. > > include/linux/shmem_fs.h | 14 +- > mm/shmem.c | 379 ++++++++++++++++++++++++++++++--------- > 2 files changed, 310 insertions(+), 83 deletions(-) > > diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h > index e729b9b0e38d4..0b14de1e890a9 100644 > --- a/include/linux/shmem_fs.h > +++ b/include/linux/shmem_fs.h > @@ -11,6 +11,7 @@ > #include > #include > #include > +#include > > struct swap_iocb; > > @@ -56,6 +57,13 @@ struct shmem_inode_info { > struct dquot __rcu *i_dquot[MAXQUOTAS]; > #endif > struct inode vfs_inode; > + > +#ifdef CONFIG_TRANSPARENT_HUGEPAGE > + struct list_head shrinklist_scan; Why introduce another list_head member? Why can't we reuse 'shrinklist' in this structure? In other words, if we isolate this inode from list_lru, then 'inode_info->shrinklist' can be reused to link it into the temporary list, right? > + struct mem_cgroup *shrinklist_memcg; > + int shrinklist_nid; > + bool shrinklist_isolated; Do we need an extra bool to indicate whether it's isolated? Can't we just use 'list_empty(inode_info->shrinklist)'? I may have missed some details.