From: Shakeel Butt <shakeel.butt@linux.dev>
To: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>,
Muchun Song <muchun.song@linux.dev>,
Yosry Ahmed <yosry.ahmed@linux.dev>,
Waiman Long <llong@redhat.com>,
linux-mm@kvack.org, cgroups@vger.kernel.org,
linux-kernel@vger.kernel.org,
Meta kernel team <kernel-team@meta.com>
Subject: Re: [PATCH] memcg: no refill for offlined objcg
Date: Mon, 14 Apr 2025 11:44:49 -0700 [thread overview]
Message-ID: <ttlcvw2jiwloctvqblvoo4mdn7cg7av6uzauzjlwnpyevghnpt@jthjpbztrvii> (raw)
In-Reply-To: <7ia47c3r1sb0.fsf@castle.c.googlers.com>
On Thu, Apr 10, 2025 at 11:59:47PM +0000, Roman Gushchin wrote:
> Shakeel Butt <shakeel.butt@linux.dev> writes:
>
> > In our fleet, we are observing refill_obj_stock() spending a lot of cpu
> > in obj_cgroup_get() and on further inspection it seems like the given
> > objcg is offlined and the kernel has to take the slow path i.e. atomic
> > operations for objcg reference counting.
> >
> > Other than expensive atomic operations, refilling stock of an offlined
> > objcg is a waster as there will not be new allocations for the offlined
> > objcg. In addition, refilling triggers flush of the previous objcg which
> > might be used in future. So, let's just avoid refilling the stock with
> > the offlined objcg.
>
> Hm, but on the other side if there are multiple uncharges in a row,
> refilling obj stocks might be still cheaper?
>
Thanks for the review. I looked at the fleet data again and what you are
suspecting i.e. multiple objects of same objcg getting freed closeby is
possible. I think I should be optimizing/batching at the upper layer. I
will be looking at rcu freeing side which is the most obvious batching
opportunity.
> In general I think that switching to atomic css refcnt on memcg
> offlining is a mistake - it makes memory reclaim generally more
> expensive. We can simple delay it until the approximate refcnt
> number reaches some low value, e.g. 100 objects.
This is a good idea. For the memcg, I think after Muchun's LRU
reparenting, we should not have zombie refcnt slowdown but for objcg
this idea might help. Anyways this is for later.
prev parent reply other threads:[~2025-04-14 18:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-10 21:05 Shakeel Butt
2025-04-10 23:59 ` Roman Gushchin
2025-04-14 18:44 ` Shakeel Butt [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=ttlcvw2jiwloctvqblvoo4mdn7cg7av6uzauzjlwnpyevghnpt@jthjpbztrvii \
--to=shakeel.butt@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=llong@redhat.com \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=yosry.ahmed@linux.dev \
/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