]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mm: memcg: adjust the warning when seq_buf overflows
authorXiu Jianfeng <xiujianfeng@huawei.com>
Fri, 28 Jun 2024 07:23:33 +0000 (07:23 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 5 Jul 2024 01:05:59 +0000 (18:05 -0700)
Currently it uses WARN_ON_ONCE() if seq_buf overflows when user reads
memory.stat, the only advantage of WARN_ON_ONCE is that the splat is so
verbose that it gets noticed.  And also it panics the system if
panic_on_warn is enabled.  It seems like the warning is just an over
reaction and a simple pr_warn should just achieve the similar effect.

Link: https://lkml.kernel.org/r/20240628072333.2496527-1-xiujianfeng@huawei.com
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
Suggested-by: Michal Hocko <mhocko@suse.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/memcontrol.c

index d0d9658ed1365658da7468a6a197c00514611ca7..500a4dba97336f836d125f4efb911276f40768b0 100644 (file)
@@ -1484,7 +1484,8 @@ static void memory_stat_format(struct mem_cgroup *memcg, struct seq_buf *s)
                memcg_stat_format(memcg, s);
        else
                memcg1_stat_format(memcg, s);
-       WARN_ON_ONCE(seq_buf_has_overflowed(s));
+       if (seq_buf_has_overflowed(s))
+               pr_warn("%s: Warning, stat buffer overflow, please report\n", __func__);
 }
 
 /**