mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: Qi Zheng <qi.zheng@linux.dev>,
	hughd@google.com, akpm@linux-foundation.org,
	usama.arif@linux.dev
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Qi Zheng <zhengqi.arch@bytedance.com>
Subject: Re: [PATCH] mm: shmem: make unused huge shrinker memcg aware
Date: Wed, 15 Jul 2026 17:37:17 +0800	[thread overview]
Message-ID: <7624107f-6a2d-4959-b2ee-aa362a8972eb@linux.alibaba.com> (raw)
In-Reply-To: <20260714031918.308-1-qi.zheng@linux.dev>

Hi Qi,

On 7/14/26 11:19 AM, Qi Zheng wrote:
> From: Qi Zheng <zhengqi.arch@bytedance.com>
> 
> 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 <zhengqi.arch@bytedance.com>
> ---

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 <linux/fs_parser.h>
>   #include <linux/userfaultfd_k.h>
>   #include <linux/bits.h>
> +#include <linux/list_lru.h>
>   
>   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.

  parent reply	other threads:[~2026-07-15  9:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-14  3:19 Qi Zheng
2026-07-15  4:32 ` Andrew Morton
2026-07-15  6:49   ` Qi Zheng
2026-07-15 19:40     ` Andrew Morton
2026-07-16  2:20       ` Qi Zheng
2026-07-15  9:37 ` Baolin Wang [this message]
2026-07-15  9:55   ` Qi Zheng
2026-07-17 12:50     ` Baolin Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7624107f-6a2d-4959-b2ee-aa362a8972eb@linux.alibaba.com \
    --to=baolin.wang@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=qi.zheng@linux.dev \
    --cc=usama.arif@linux.dev \
    --cc=zhengqi.arch@bytedance.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox