All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hao Jia <jiahao.kernel@gmail.com>
To: Yosry Ahmed <yosry@kernel.org>
Cc: Nhat Pham <nphamcs@gmail.com>,
	akpm@linux-foundation.org, tj@kernel.org, hannes@cmpxchg.org,
	shakeel.butt@linux.dev, mhocko@kernel.org, mkoutny@suse.com,
	chengming.zhou@linux.dev, muchun.song@linux.dev,
	roman.gushchin@linux.dev, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	Hao Jia <jiahao1@lixiang.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH v5 1/6] mm/zswap: Fix global shrinker when memory cgroup is disabled
Date: Wed, 1 Jul 2026 17:39:15 +0800	[thread overview]
Message-ID: <e2ec0924-52b3-25f3-8432-4b8e33a101dd@gmail.com> (raw)
In-Reply-To: <CAO9r8zPBe9BPwP8NXz7pdH7T+8HLNsRAckL2Vfcnz0c23TH=iw@mail.gmail.com>



On 2026/7/1 00:02, Yosry Ahmed wrote:
>> How about something like this? If there are no objections, I'll fold
>> this into the next version.
>>
>>       mm/zswap: Fix global shrinker when memory cgroup is disabled
>>
>>       When memory cgroup is disabled, mem_cgroup_iter() always returns NULL.
>>       Therefore, the global shrinker shrink_worker() always takes the !memcg
>>       branch. After MAX_RECLAIM_RETRIES empty walks, the worker simply
>> gives up,
>>       so it fails to write back anything.
>>
>>       Therefore, when memory cgroup is disabled, fall through with the !memcg
>>       branch and shrink the root memcg directly.
>>
>>       With memcg disabled, shrink_memcg() only returns -ENOENT when the root
>>       LRU is empty, which means the total pages are already below thr.
>> The loop
>>       then safely bails out via the zswap_total_pages() <= thr check. For any
>>       other return value from shrink_memcg(), the loop is guaranteed to
>> terminate,
>>       either after MAX_RECLAIM_RETRIES failures or once the threshold is met.
>>
>>       Fixes: a65b0e7607cc ("zswap: make shrinking memcg-aware")
>>       Cc: stable@vger.kernel.org
>>       Reported-by: Yosry Ahmed <yosry@kernel.org>
>>       Closes:
>> https://lore.kernel.org/all/CAO9r8zPVzMKFbCixxD-qgtRrkFxWVrHiZZeLc=eyTPKPVQgX4g@mail.gmail.com
>>       Signed-off-by: Hao Jia <jiahao1@lixiang.com>
> 
> Feel free to add:
> 
> Acked-by: Yosry Ahmed <yosry@kernel.org>

Thank you for taking the time to review this.
> 
> A small nit below.
> 
>>
>> diff --git a/mm/zswap.c b/mm/zswap.c
>> index 4b5149173b0e..9d4f19fc440e 100644
>> --- a/mm/zswap.c
>> +++ b/mm/zswap.c
>> @@ -1361,11 +1361,12 @@ static void shrink_worker(struct work_struct *w)
>>                   } while (memcg && !mem_cgroup_tryget_online(memcg));
>>                   spin_unlock(&zswap_shrink_lock);
>>
>> -               if (!memcg) {
>> -                       /*
>> -                        * Continue shrinking without incrementing
>> failures if
>> -                        * we found candidate memcgs in the last tree walk.
>> -                        */
>> +               /*
>> +                * A NULL memcg ends a full hierarchy pass (except when
>> memcg is
>> +                * disabled, where it is always NULL: fall through to
>> the root LRU).
>> +                * Count a failure only if the pass found no candidates.
> 
> I think "last pass" is clearer than just "pass" here?


Will do.

Thanks,
Hao


  reply	other threads:[~2026-07-01  9:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-29 11:20 [PATCH v5 0/6] mm/zswap: Implement per-cgroup proactive writeback Hao Jia
2026-06-29 11:20 ` [PATCH v5 1/6] mm/zswap: Fix global shrinker when memory cgroup is disabled Hao Jia
2026-06-29 18:37   ` Nhat Pham
2026-06-30 10:51     ` Hao Jia
2026-06-30 16:02       ` Yosry Ahmed
2026-07-01  9:39         ` Hao Jia [this message]
2026-07-01 17:33       ` Nhat Pham
2026-06-29 11:20 ` [PATCH v5 2/6] mm/zswap: Support batch writeback in shrink_memcg() Hao Jia
2026-06-30  0:21   ` Yosry Ahmed
2026-06-30  1:18     ` Hao Jia
2026-06-29 11:20 ` [PATCH v5 3/6] mm/zswap: Extract a reusable writeback helper from shrink_worker() Hao Jia
2026-06-29 11:20 ` [PATCH v5 4/6] mm/zswap: Implement proactive writeback Hao Jia
2026-06-30  0:15   ` Yosry Ahmed
2026-06-30  1:49     ` Hao Jia
2026-06-30 16:10       ` Yosry Ahmed
2026-07-01  9:35         ` Hao Jia
2026-07-01 11:45         ` Hao Jia
2026-07-02 12:32           ` Hao Jia
2026-06-29 11:20 ` [PATCH v5 5/6] mm/zswap: Add per-memcg stat for " Hao Jia
2026-06-29 11:20 ` [PATCH v5 6/6] selftests/cgroup: Add tests for zswap " Hao Jia

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=e2ec0924-52b3-25f3-8432-4b8e33a101dd@gmail.com \
    --to=jiahao.kernel@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=chengming.zhou@linux.dev \
    --cc=hannes@cmpxchg.org \
    --cc=jiahao1@lixiang.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=mkoutny@suse.com \
    --cc=muchun.song@linux.dev \
    --cc=nphamcs@gmail.com \
    --cc=roman.gushchin@linux.dev \
    --cc=shakeel.butt@linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=yosry@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.