From: Michal Hocko <mhocko@suse.com>
To: Hao Li <hao.li@linux.dev>
Cc: hannes@cmpxchg.org, roman.gushchin@linux.dev,
shakeel.butt@linux.dev, muchun.song@linux.dev,
akpm@linux-foundation.org, cgroups@vger.kernel.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: memcontrol: treat disabled memcg as kmem accounting disabled
Date: Thu, 27 Aug 2026 14:04:13 +0200 [thread overview]
Message-ID: <apAnveXHmeQlKJnU@tiehlicka> (raw)
In-Reply-To: <20260827091813.22327-1-hao.li@linux.dev>
On Thu 27-08-26 17:17:50, Hao Li wrote:
> mem_cgroup_kmem_disabled() currently only checks whether the
> "cgroup.memory=nokmem" option is specified. However, kmem accounting is
> also unavailable when memcg itself is disabled.
>
> Check both conditions to ensure the function accurately reflects the
> kmem accounting state.
It would be really great if you could describe how we could end up with
the inconsistent memcg enabled but kmem enabled and what kind of effect
does this have.
AFAICS the inconsistency is possible and it would lead some wastage but
no functional problems but the changelog should be more descriptive.
> Signed-off-by: Hao Li <hao.li@linux.dev>
> ---
> mm/memcontrol.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 1ebceade4021..b28f6165c354 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -132,7 +132,7 @@ static DEFINE_SPINLOCK(objcg_lock);
>
> bool mem_cgroup_kmem_disabled(void)
> {
> - return cgroup_memory_nokmem;
> + return cgroup_memory_nokmem || mem_cgroup_disabled();
> }
>
> static void memcg_uncharge(struct mem_cgroup *memcg, unsigned int nr_pages);
> --
> 2.54.0
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2026-08-27 12:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 9:17 [PATCH] mm: memcontrol: treat disabled memcg as kmem accounting disabled Hao Li
2026-08-27 12:04 ` Michal Hocko [this message]
2026-08-28 0:47 ` Hao Li
2026-08-28 13:58 ` Michal Hocko
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=apAnveXHmeQlKJnU@tiehlicka \
--to=mhocko@suse.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=hao.li@linux.dev \
--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