Re: [PATCH] mm: memcg-v1: fix memory.memsw.failcnt accounting

From: Andrew Morton

Date: Mon Aug 10 2026 - 14:49:49 EST


On Mon, 10 Aug 2026 15:42:47 +0800 Guopeng Zhang <guopeng.zhang@xxxxxxxxx> wrote:

> 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.
>
> Consequently, memory.memsw.failcnt remains zero when the memory+swap
> limit is hit. Enable failcnt accounting for the v1 memsw counter.
>
> Reproducer:
>
> 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.

Thanks. Nice changelog.

> Fixes: 0e2759afcaf9 ("page_counter: track failcnt only for legacy cgroups")

I'll add cc:stable to this.

AI review thinks that memcg->tcpmem.track_failcnt should receive the
same treatment:

https://sashiko.dev/#/patchset/20260810074247.52747-1-guopeng.zhang@xxxxxxxxx