From: Jakub Kicinski <kuba@kernel.org>
To: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Muchun Song <muchun.song@linux.dev>,
Vlastimil Babka <vbabka@suse.cz>,
Eric Dumazet <edumazet@google.com>,
Soheil Hassas Yeganeh <soheil@google.com>,
linux-mm@kvack.org, cgroups@vger.kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Meta kernel team <kernel-team@meta.com>
Subject: Re: [PATCH] memcg: multi-memcg percpu charge cache
Date: Wed, 23 Apr 2025 15:30:46 -0700 [thread overview]
Message-ID: <20250423153046.54d135f2@kernel.org> (raw)
In-Reply-To: <ha4sqstdknwvvubs2g33r3itrabepz2jwlr3ksrbjdlgjnbuel@appekpf6ffud>
On Wed, 23 Apr 2025 15:16:56 -0700 Shakeel Butt wrote:
> > > - if (!local_trylock_irqsave(&memcg_stock.stock_lock, flags)) {
> > > + if (nr_pages > MEMCG_CHARGE_BATCH ||
> > > + !local_trylock_irqsave(&memcg_stock.stock_lock, flags)) {
> > > /*
> > > - * In case of unlikely failure to lock percpu stock_lock
> > > - * uncharge memcg directly.
> > > + * In case of larger than batch refill or unlikely failure to
> > > + * lock the percpu stock_lock, uncharge memcg directly.
> > > */
> >
> > We're bypassing the cache for > CHARGE_BATCH because the u8 math
> > may overflow? Could be useful to refocus the comment on the 'why'
>
> We actually never put more than MEMCG_CHARGE_BATCH in the cache and thus
> we can use u8 as type here. Though we may increase the batch size in
> future, so I should put a BUILD_BUG_ON somewhere here.
No idea if this matters enough to deserve its own commit but basically
I was wondering if that behavior change is a separate optimization.
Previously we'd check if the cache was for the releasing cgroup and sum
was over BATCH - drain its stock completely. Now we bypass looking at
the cache if nr_pages > BATCH so the cgroup may retain some stock.
next prev parent reply other threads:[~2025-04-23 22:30 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-16 18:02 [PATCH] memcg: multi-memcg percpu charge cache Shakeel Butt
2025-04-23 1:10 ` Jakub Kicinski
2025-04-23 22:16 ` Shakeel Butt
2025-04-23 22:30 ` Jakub Kicinski [this message]
2025-04-23 22:59 ` Shakeel Butt
2025-04-23 23:14 ` Shakeel Butt
2025-04-25 20:18 ` Shakeel Butt
2025-04-29 9:40 ` Hugh Dickins
2025-04-29 14:50 ` Shakeel Butt
2025-04-30 10:05 ` Vlastimil Babka
2025-04-30 15:16 ` Shakeel Butt
2025-04-29 12:13 ` Michal Hocko
2025-04-29 18:43 ` Shakeel Butt
2025-04-30 6:48 ` Michal Hocko
2025-04-30 9:57 ` Vlastimil Babka
2025-04-30 15:05 ` Shakeel Butt
2025-04-30 15:32 ` Shakeel Butt
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=20250423153046.54d135f2@kernel.org \
--to=kuba@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=edumazet@google.com \
--cc=hannes@cmpxchg.org \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=netdev@vger.kernel.org \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=soheil@google.com \
--cc=vbabka@suse.cz \
/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.