Linux cgroups development
 help / color / mirror / Atom feed
From: Jiayuan Chen <jiayuan.chen@linux.dev>
To: linux-mm@kvack.org
Cc: jiayuan.chen@shopee.com, Zhou Yingfu <yingfu.zhou@shopee.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@kernel.org>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	Muchun Song <muchun.song@linux.dev>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@kernel.org>,
	Qi Zheng <qi.zheng@linux.dev>, Lorenzo Stoakes <ljs@kernel.org>,
	Kairui Song <kasong@tencent.com>, Barry Song <baohua@kernel.org>,
	Axel Rasmussen <axelrasmussen@google.com>,
	Yuanchu Xie <yuanchu@google.com>, Wei Xu <weixugc@google.com>,
	cgroups@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 3/4] memcg: bail out proactive reclaim when memcg is dying
Date: Thu, 2 Jul 2026 20:55:10 +0800	[thread overview]
Message-ID: <358e9e58-77fb-465d-9b37-65b095ef8d2d@linux.dev> (raw)
In-Reply-To: <20260702120235.376752-4-jiayuan.chen@linux.dev>


On 7/2/26 8:02 PM, Jiayuan Chen wrote:
> From: Jiayuan Chen <jiayuan.chen@shopee.com>
>
> Proactive reclaim via memory.reclaim can run for a long time - swap I/O
> or thrashing again dominating the latency - and delays cgroup removal in
> the same way.
>
> Mitigate this by stopping the reclaim once memcg_is_dying().
>
> Cc: Jiayuan Chen <jiayuan.chen@linux.dev>
> Reported-by: Zhou Yingfu <yingfu.zhou@shopee.com>
> Acked-by: Johannes Weiner <hannes@cmpxchg.org>
> Signed-off-by: Jiayuan Chen <jiayuan.chen@shopee.com>
> ---
>   mm/vmscan.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 754c5f5d716a..6ae61be2fab8 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -7912,6 +7912,10 @@ int user_proactive_reclaim(char *buf,
>   		if (signal_pending(current))
>   			return -EINTR;
>   
> +		/* cgroup_rmdir() waits for us with cgroup_mutex held. */
> +		if (memcg && memcg_is_dying(memcg))
> +			return -EAGAIN;
> +
>   		/*
>   		 * This is the final attempt, drain percpu lru caches in the
>   		 * hope of introducing more evictable pages.



The issuse reported by Ai is benign:
https://sashiko.dev/#/patchset/20260702120235.376752-1-jiayuan.chen%40linux.dev

We have multiple break points to return in 
try_to_free_pages::do_try_to_free_pages
'''

     static unsigned long do_try_to_free_pages()
     {

         retry:
             do {

                 shrink_zones(zonelist, sc);

                 // break 1
                 if (sc->nr_reclaimed >= sc->nr_to_reclaim)
                     break;

             } while (--sc->priority >= 0); // at most 12 
times(DEF_PRIORITY)


             // break 2
             if (sc->nr_reclaimed)
                 return sc->nr_reclaimed;

             // retry twice logic
             ...
     }
'''


  reply	other threads:[~2026-07-02 12:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-02 12:02 [PATCH v3 0/4] memcg: bail out reclaim when memcg is dying Jiayuan Chen
2026-07-02 12:02 ` [PATCH v3 1/4] memcg: bail out memory.high " Jiayuan Chen
2026-07-02 12:02 ` [PATCH v3 2/4] memcg: bail out memory.max " Jiayuan Chen
2026-07-02 12:02 ` [PATCH v3 3/4] memcg: bail out proactive reclaim " Jiayuan Chen
2026-07-02 12:55   ` Jiayuan Chen [this message]
2026-07-02 12:02 ` [PATCH v3 4/4] memcg-v1: bail out " Jiayuan Chen

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=358e9e58-77fb-465d-9b37-65b095ef8d2d@linux.dev \
    --to=jiayuan.chen@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=axelrasmussen@google.com \
    --cc=baohua@kernel.org \
    --cc=cgroups@vger.kernel.org \
    --cc=david@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=jiayuan.chen@shopee.com \
    --cc=kasong@tencent.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=qi.zheng@linux.dev \
    --cc=roman.gushchin@linux.dev \
    --cc=shakeel.butt@linux.dev \
    --cc=weixugc@google.com \
    --cc=yingfu.zhou@shopee.com \
    --cc=yuanchu@google.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