From: Ridong Chen <ridong.chen@linux.dev>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@kernel.org>,
Lorenzo Stoakes <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
Brendan Jackman <brendan.jackman@linux.dev>,
Zi Yan <ziy@nvidia.com>, Kairui Song <kasong@tencent.com>,
Qi Zheng <qi.zheng@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
Barry Song <baohua@kernel.org>,
Axel Rasmussen <axelrasmussen@google.com>,
Yuanchu Xie <yuanchu@google.com>, Wei Xu <weixugc@google.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Ridong Chen <chenridong@xiaomi.com>
Subject: Re: [PATCH] memcg: sink mem_cgroup_uncharge_folios() into free_unref_folios()
Date: Fri, 28 Aug 2026 10:07:52 +0800 [thread overview]
Message-ID: <ac0d1ef0-1cbd-40d1-9f0f-c12d890be3ec@linux.dev> (raw)
In-Reply-To: <20260827145209.GA3004@cmpxchg.org>
On 8/27/2026 10:52 PM, Johannes Weiner wrote:
> On Thu, Aug 27, 2026 at 11:05:16AM +0800, Ridong Chen wrote:
>> From: Ridong Chen <chenridong@xiaomi.com>
>>
>> Every caller of free_unref_folios() invokes mem_cgroup_uncharge_folios()
>> on the same batch immediately beforehand. This pattern is duplicated
>> across shrink_folio_list(), move_folios_to_lru(), folio_batch_move_lru()
>> and folios_put_refs().
>>
>> Move the uncharge into free_unref_folios() itself so the batch is
>> uncharged in one place before the folios are freed. This removes the
>> repeated boilerplate at every call site and makes it impossible to free
>> a batch without uncharging it first. No functional change intended.
>
> Hm, IMO this is confusing. You're making uncharging an included
> service in a subset of the page allocator freeing API. Batch freeing
> uncharges, but single page freeing does not.
>
> I don't think saving 7 lines is worth that API caveat.
Thanks Johannes.
I thought this could improve cohesion, since we have to uncharge the batch when
freeing unreferenced folios. However, I didn't consider the symmetry with single
folio freeing.
I'll just drop the patch if it's causing confusion.
--
Best regards
Ridong
prev parent reply other threads:[~2026-08-28 2:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 3:05 [PATCH] memcg: sink mem_cgroup_uncharge_folios() into free_unref_folios() Ridong Chen
2026-08-27 14:52 ` Johannes Weiner
2026-08-28 2:07 ` Ridong Chen [this message]
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=ac0d1ef0-1cbd-40d1-9f0f-c12d890be3ec@linux.dev \
--to=ridong.chen@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=baohua@kernel.org \
--cc=brendan.jackman@linux.dev \
--cc=chenridong@xiaomi.com \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kasong@tencent.com \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=qi.zheng@linux.dev \
--cc=rppt@kernel.org \
--cc=shakeel.butt@linux.dev \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=weixugc@google.com \
--cc=yuanchu@google.com \
--cc=ziy@nvidia.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 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.