From: Michal Hocko <mhocko@suse.com>
To: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Muchun Song <muchun.song@linux.dev>,
linux-mm@kvack.org, cgroups@vger.kernel.org,
linux-kernel@vger.kernel.org,
Meta kernel team <kernel-team@meta.com>
Subject: Re: [PATCH] memcg: avoid refill_stock for root memcg
Date: Thu, 13 Mar 2025 08:52:27 +0100 [thread overview]
Message-ID: <Z9KOu9XTe5O7tqRd@tiehlicka> (raw)
In-Reply-To: <20250313054812.2185900-1-shakeel.butt@linux.dev>
On Wed 12-03-25 22:48:12, Shakeel Butt wrote:
> We never charge the page counters of root memcg, so there is no need to
> put root memcg in the memcg stock. At the moment, refill_stock() can be
> called from try_charge_memcg(), obj_cgroup_uncharge_pages() and
> mem_cgroup_uncharge_skmem().
>
> The try_charge_memcg() and mem_cgroup_uncharge_skmem() are never called
> with root memcg, so those are fine. However obj_cgroup_uncharge_pages()
> can potentially call refill_stock() with root memcg if the objcg object
> has been reparented over to the root memcg. Let's just avoid
> refill_stock() from obj_cgroup_uncharge_pages() for root memcg.
Makes sense. It is just pointless draining of a different memcg.
> Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
Acked-by: Michal Hocko <mhockoc@suse.com>
Thanks!
> ---
> mm/memcontrol.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index e08ce52caabd..393b73aec6dd 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -2643,7 +2643,8 @@ static void obj_cgroup_uncharge_pages(struct obj_cgroup *objcg,
>
> mod_memcg_state(memcg, MEMCG_KMEM, -nr_pages);
> memcg1_account_kmem(memcg, -nr_pages);
> - refill_stock(memcg, nr_pages);
> + if (!mem_cgroup_is_root(memcg))
> + refill_stock(memcg, nr_pages);
>
> css_put(&memcg->css);
> }
> --
> 2.47.1
>
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2025-03-13 7:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-13 5:48 Shakeel Butt
2025-03-13 7:52 ` Michal Hocko [this message]
2025-03-13 15:39 ` Johannes Weiner
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=Z9KOu9XTe5O7tqRd@tiehlicka \
--to=mhocko@suse.com \
--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=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@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