From: Shakeel Butt <shakeel.butt@linux.dev>
To: Guopeng Zhang <guopeng.zhang@linux.dev>
Cc: hannes@cmpxchg.org, mhocko@kernel.org, akpm@linux-foundation.org,
roman.gushchin@linux.dev, muchun.song@linux.dev,
cgroups@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org,
Guopeng Zhang <zhangguopeng@kylinos.cn>,
Michal Hocko <mhocko@suse.com>
Subject: Re: [PATCH v2] mm: memcg-v1: fix memsw and TCP failcnt accounting
Date: Mon, 10 Aug 2026 21:31:39 -0700 [thread overview]
Message-ID: <anqlhbQ8BSJ1AKQ4@linux.dev> (raw)
In-Reply-To: <20260811030843.109104-1-guopeng.zhang@linux.dev>
On Tue, Aug 11, 2026 at 11:08:43AM +0800, Guopeng Zhang wrote:
> From: Guopeng Zhang <zhangguopeng@kylinos.cn>
>
> Commit 0e2759afcaf9 ("page_counter: track failcnt only for legacy
> cgroups") made failcnt accounting conditional on track_failcnt. It
> enabled the flag for memcg->memory, but not for memcg->memsw or
> memcg->tcpmem.
>
> Consequently, memory.memsw.failcnt remains zero when the memory+swap
> limit is hit. memory.kmem.tcp.limit_in_bytes still sets
> memcg->tcpmem.max, but TCP charge failures are not reflected in
> memory.kmem.tcp.failcnt.
>
> Enable failcnt accounting for both v1 counters.
>
> To reproduce memory.memsw.failcnt:
>
> CG=/sys/fs/cgroup/memory/memsw-test
> LIMIT=33554432
> mkdir "$CG"
> echo "$LIMIT" > "$CG/memory.limit_in_bytes"
> echo "$LIMIT" > "$CG/memory.memsw.limit_in_bytes"
>
> Start a child process in the cgroup and make it allocate and touch 96 MiB
> of memory, causing a memcg OOM.
>
> cat "$CG/memory.memsw.failcnt"
>
> Without the patch, memory.memsw.failcnt is 0. With the patch,
> memory.memsw.failcnt is greater than 0.
>
> To reproduce memory.kmem.tcp.failcnt:
>
> CG=/sys/fs/cgroup/memory/tcpmem-test
> LIMIT=65536
> mkdir "$CG"
> echo "$LIMIT" > "$CG/memory.kmem.tcp.limit_in_bytes"
>
> Start a child process in the cgroup, create a TCP socket, and reserve
> 1 MiB of socket memory with SO_RESERVE_MEM. The reservation fails with
> ENOMEM.
>
> cat "$CG/memory.kmem.tcp.failcnt"
>
> Without the patch, memory.kmem.tcp.failcnt is 0. With the patch,
> memory.kmem.tcp.failcnt is greater than 0.
>
> Closes: https://sashiko.dev/#/patchset/20260810074247.52747-1-guopeng.zhang@linux.dev?part=1
> Fixes: 0e2759afcaf9 ("page_counter: track failcnt only for legacy cgroups")
> Cc: stable@vger.kernel.org
> Acked-by: Johannes Weiner <hannes@cmpxchg.org>
> Acked-by: Michal Hocko <mhocko@suse.com>
> Signed-off-by: Guopeng Zhang <zhangguopeng@kylinos.cn>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
prev parent reply other threads:[~2026-08-11 4:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 3:08 [PATCH v2] mm: memcg-v1: fix memsw and TCP failcnt accounting Guopeng Zhang
2026-08-11 4:13 ` Tao Cui
2026-08-11 4:31 ` 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=anqlhbQ8BSJ1AKQ4@linux.dev \
--to=shakeel.butt@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=guopeng.zhang@linux.dev \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=mhocko@suse.com \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=zhangguopeng@kylinos.cn \
/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