linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] mm: memcg: adjust the warning when seq_buf overflows
@ 2024-06-28  7:23 Xiu Jianfeng
  2024-06-28  7:45 ` Michal Hocko
  0 siblings, 1 reply; 5+ messages in thread
From: Xiu Jianfeng @ 2024-06-28  7:23 UTC (permalink / raw)
  To: hannes, mhocko, roman.gushchin, shakeel.butt, muchun.song, akpm
  Cc: cgroups, linux-mm, linux-kernel

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.

Suggested-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
---
 mm/memcontrol.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index c251bbe35f4b..8e5590ac43d7 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -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__);
 }
 
 /**
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH -next] mm: memcg: adjust the warning when seq_buf overflows
  2024-06-28  7:23 [PATCH -next] mm: memcg: adjust the warning when seq_buf overflows Xiu Jianfeng
@ 2024-06-28  7:45 ` Michal Hocko
  2024-06-28  7:55   ` xiujianfeng
  2024-06-28  8:09   ` xiujianfeng
  0 siblings, 2 replies; 5+ messages in thread
From: Michal Hocko @ 2024-06-28  7:45 UTC (permalink / raw)
  To: Xiu Jianfeng
  Cc: hannes, roman.gushchin, shakeel.butt, muchun.song, akpm, cgroups,
	linux-mm, linux-kernel

On Fri 28-06-24 07:23:33, Xiu Jianfeng wrote:
> 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.
> 
> Suggested-by: Michal Hocko <mhocko@suse.com>
> Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>

Acked-by: Michal Hocko <mhocko@suse.com>

I would just squash this with other patch removing it from
memcg_stat_format. But this is up to you.

Thanks!

> ---
>  mm/memcontrol.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index c251bbe35f4b..8e5590ac43d7 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -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__);
>  }
>  
>  /**
> -- 
> 2.34.1
> 

-- 
Michal Hocko
SUSE Labs


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH -next] mm: memcg: adjust the warning when seq_buf overflows
  2024-06-28  7:45 ` Michal Hocko
@ 2024-06-28  7:55   ` xiujianfeng
  2024-06-28  8:09   ` xiujianfeng
  1 sibling, 0 replies; 5+ messages in thread
From: xiujianfeng @ 2024-06-28  7:55 UTC (permalink / raw)
  To: Michal Hocko
  Cc: hannes, roman.gushchin, shakeel.butt, muchun.song, akpm, cgroups,
	linux-mm, linux-kernel



On 2024/6/28 15:45, Michal Hocko wrote:
> On Fri 28-06-24 07:23:33, Xiu Jianfeng wrote:
>> 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.
>>
>> Suggested-by: Michal Hocko <mhocko@suse.com>
>> Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
> 
> Acked-by: Michal Hocko <mhocko@suse.com>
> 
> I would just squash this with other patch removing it from
> memcg_stat_format. But this is up to you.

Thanks, the other patch has already been merged into the -next branch by
Andrew. In this situation, I'm not quite clear whether I should send a
small separate patch, or squash them and send a v2. If Andrew wants, I
can do it.

> 
> Thanks!
> 
>> ---
>>  mm/memcontrol.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
>> index c251bbe35f4b..8e5590ac43d7 100644
>> --- a/mm/memcontrol.c
>> +++ b/mm/memcontrol.c
>> @@ -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__);
>>  }
>>  
>>  /**
>> -- 
>> 2.34.1
>>
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH -next] mm: memcg: adjust the warning when seq_buf overflows
  2024-06-28  7:45 ` Michal Hocko
  2024-06-28  7:55   ` xiujianfeng
@ 2024-06-28  8:09   ` xiujianfeng
  2024-06-28  8:15     ` Michal Hocko
  1 sibling, 1 reply; 5+ messages in thread
From: xiujianfeng @ 2024-06-28  8:09 UTC (permalink / raw)
  To: Michal Hocko
  Cc: hannes, roman.gushchin, shakeel.butt, muchun.song, akpm, cgroups,
	linux-mm, linux-kernel



On 2024/6/28 15:45, Michal Hocko wrote:
> On Fri 28-06-24 07:23:33, Xiu Jianfeng wrote:
>> 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.
>>
>> Suggested-by: Michal Hocko <mhocko@suse.com>
>> Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
> 
> Acked-by: Michal Hocko <mhocko@suse.com>
> 
> I would just squash this with other patch removing it from
> memcg_stat_format. But this is up to you.

Sorry, I might have misunderstood, if you can squash them, it looks good
to me, thanks.

> 
> Thanks!
> 
>> ---
>>  mm/memcontrol.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
>> index c251bbe35f4b..8e5590ac43d7 100644
>> --- a/mm/memcontrol.c
>> +++ b/mm/memcontrol.c
>> @@ -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__);
>>  }
>>  
>>  /**
>> -- 
>> 2.34.1
>>
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH -next] mm: memcg: adjust the warning when seq_buf overflows
  2024-06-28  8:09   ` xiujianfeng
@ 2024-06-28  8:15     ` Michal Hocko
  0 siblings, 0 replies; 5+ messages in thread
From: Michal Hocko @ 2024-06-28  8:15 UTC (permalink / raw)
  To: xiujianfeng
  Cc: hannes, roman.gushchin, shakeel.butt, muchun.song, akpm, cgroups,
	linux-mm, linux-kernel

On Fri 28-06-24 16:09:02, xiujianfeng wrote:
> 
> 
> On 2024/6/28 15:45, Michal Hocko wrote:
> > On Fri 28-06-24 07:23:33, Xiu Jianfeng wrote:
> >> 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.
> >>
> >> Suggested-by: Michal Hocko <mhocko@suse.com>
> >> Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
> > 
> > Acked-by: Michal Hocko <mhocko@suse.com>
> > 
> > I would just squash this with other patch removing it from
> > memcg_stat_format. But this is up to you.
> 
> Sorry, I might have misunderstood, if you can squash them, it looks good
> to me, thanks.

Andrew usually can do that even when the patch is in his tree. But as
I've said having 2 patches is ok as well.
-- 
Michal Hocko
SUSE Labs


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-06-28  8:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-28  7:23 [PATCH -next] mm: memcg: adjust the warning when seq_buf overflows Xiu Jianfeng
2024-06-28  7:45 ` Michal Hocko
2024-06-28  7:55   ` xiujianfeng
2024-06-28  8:09   ` xiujianfeng
2024-06-28  8:15     ` Michal Hocko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).