From: Balbir Singh <balbirs@nvidia.com>
To: Joshua Hahn <joshua.hahnjy@gmail.com>
Cc: "Johannes Weiner" <hannes@cmpxchg.org>,
"Shakeel Butt" <shakeel.butt@linux.dev>,
"Michal Hocko" <mhocko@kernel.org>,
"Michal Koutný" <mkoutny@suse.com>,
"Roman Gushchin" <roman.gushchin@linux.dev>,
"Muchun Song" <muchun.song@linux.dev>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Kuniyuki Iwashima" <kuniyu@google.com>,
"Harry Yoo" <harry@kernel.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>,
"Maarten Lankhorst" <dev@lankhorst.se>,
"Maxime Ripard" <mripard@kernel.org>,
"Natalie Vock" <nat@pixelcluster.dev>,
"Tejun Heo" <tj@kernel.org>, "Oscar Salvador" <osalvador@suse.de>,
cgroups@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, kernel-team@meta.com
Subject: Re: [PATCH v8 0/7] mm/page_counter: move stock from mem_cgroup to page_counter
Date: Fri, 6 Nov 2026 21:07:23 +1100 [thread overview]
Message-ID: <au2m28-Zl1MMs4Rk@parvat> (raw)
In-Reply-To: <CAN+CAwPNsSWyqbKRGEL_rtrz9CWTdFvhKFvZpbUNoJJONXxuZA@mail.gmail.com>
On Thu, Nov 05, 2026 at 09:50:43AM -0500, Joshua Hahn wrote:
> On Thu, Nov 5, 2026 at 1:17 AM Balbir Singh <balbirs@nvidia.com> wrote:
> >
> > On Wed, Nov 04, 2026 at 03:30:21PM -0800, Joshua Hahn wrote:
> > > INTRODUCTION
> > > ============
> > > Memcg keeps a per-CPU stock of precharged pages so that small and
> > > frequent allocations do not walk the page_counter hierarchy every time.
> > > Today, the stock implementation lives in memcontrol code, even though
> > > the operation it caches is a page_counter charge. This makes it
> > > difficult to add new page_counters to a memcg and preserve the fast path
> > > behavior.
> > >
> > > This series moves the stock into the page_counter layer.
> > > page_counter_try_charge() consumes the stock, charges a batch to the
> > > hierarchy on a miss, and refills the stock with the surplus. Memcg no
> > > longer manages the stock in try_charge_memcg.
> > >
> > > So the stock keeps the existing layout, which is still a per-CPU bank
> > > of 7 slots, each holding a count of precharged pages that it hands out.
> > > It maintains exclusion using local locks on each CPU, and for remote
> > > drains we schedule on the memcg workqueue.
> > >
> > > This change gives us the following benefits:
> > > - Separate charge caching (page_counter) from charge policy (memcg).
> > > - Makes it simple to keep stock out of interior cgroups on cgroup v2.
> > > - Prepares for future work for stock improvement, which can now be
> > > isolated from memcg changes.
>
> [...snip...]
>
> > Is the main motivation ease of addition of page_counters to a memcg?
> > What would those counters be, why not add them here?
>
> Hi Balbir,
>
> Thank you for your interest in the series! So yes, that is the main
> motivation but this series offers standalone benefits as well (which
> are right above).
>
> The new page_counters that I want to add track per-tier per-memcg
> residence. Those are used for enforcement (and not necessarily for
> visibility), so I think they wouldn't make too much sense to add on
> their own now, without the actual enforcement parts.
>
> What do you think? I've also linked my tiered memcg series [1] if you
> wanted additional context.
Thanks! I'll take a look. I was just curious based on the numbers I saw
in the cover letter and wondering what the changes got, I can see how it
helps in a hierarchial situation.
>
> Thank you, I hope you have a great day!
> Joshua
>
> [1] https://lore.kernel.org/all/20260807202059.2620949-1-joshua.hahnjy@gmail.com/
Balbir
prev parent reply other threads:[~2026-11-06 10:07 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 23:30 [PATCH v8 0/7] mm/page_counter: move stock from mem_cgroup to page_counter Joshua Hahn
2026-11-04 23:30 ` [PATCH v8 1/7] mm/memcontrol: flatten try_charge_memcg control flow Joshua Hahn
2026-11-05 6:08 ` Balbir Singh
2026-11-04 23:30 ` [PATCH v8 2/7] mm/page_counter: introduce per-CPU stock Joshua Hahn
2026-11-04 23:30 ` [PATCH v8 3/7] mm/page_counter: make page_counter_try_charge() stock-aware Joshua Hahn
2026-11-04 23:30 ` [PATCH v8 4/7] mm/memcontrol: check PF_MEMALLOC after trying the limits Joshua Hahn
2026-11-04 23:30 ` [PATCH v8 5/7] mm/memcontrol: move memory stock to page counters Joshua Hahn
2026-11-04 23:30 ` [PATCH v8 6/7] mm/memcontrol: add stock to the memsw page counter Joshua Hahn
2026-11-04 23:30 ` [PATCH v8 7/7] mm/memcontrol: restrict memory stock to leaf cgroups on v2 Joshua Hahn
2026-11-05 23:31 ` sashiko-bot
2026-11-09 18:48 ` Joshua Hahn
2026-11-05 6:17 ` [PATCH v8 0/7] mm/page_counter: move stock from mem_cgroup to page_counter Balbir Singh
2026-11-05 14:50 ` Joshua Hahn
2026-11-06 10:07 ` Balbir Singh [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=au2m28-Zl1MMs4Rk@parvat \
--to=balbirs@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=david@kernel.org \
--cc=dev@lankhorst.se \
--cc=hannes@cmpxchg.org \
--cc=harry@kernel.org \
--cc=joshua.hahnjy@gmail.com \
--cc=kernel-team@meta.com \
--cc=kuniyu@google.com \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@kernel.org \
--cc=mkoutny@suse.com \
--cc=mripard@kernel.org \
--cc=muchun.song@linux.dev \
--cc=nat@pixelcluster.dev \
--cc=osalvador@suse.de \
--cc=roman.gushchin@linux.dev \
--cc=rppt@kernel.org \
--cc=shakeel.butt@linux.dev \
--cc=surenb@google.com \
--cc=tj@kernel.org \
--cc=vbabka@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.