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

Guopeng Zhang <[email protected]>
Newsgroups gmane.linux.kernel.cgroups,gmane.linux.kernel.mm,gmane.linux.kernel
Message-ID <[email protected]>

在 2026/8/11 02:47, Andrew Morton 写道:
> On Mon, 10 Aug 2026 15:42:47 +0800 Guopeng Zhang <[email protected]> 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-fxUVXftIFDnyG1zEObXtfA@public.gmane.org

Yeah, tcpmem has the same issue.

I'll add

    memcg->tcpmem.track_failcnt = !memcg_on_dfl;

and update the changelog accordingly in v2.

Thanks,
Guopeng
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.