diff mbox series

[3/3] mm/percpu.c: print error message too if atomic alloc failed

Message ID 20230721131800.20003-4-bhe@redhat.com (mailing list archive)
State New
Headers show
Series percpu: some trivial cleanup patches | expand

Commit Message

Baoquan He July 21, 2023, 1:18 p.m. UTC
The variable 'err' is assgigned to an error message if atomic alloc
failed, while it has no chance to be printed if is_atomic is true.

Here change to print error message too if atomic alloc failed, while
avoid to call dump_stack() if that case.

Signed-off-by: Baoquan He <bhe@redhat.com>
---
 mm/percpu.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Dennis Zhou July 21, 2023, 9:03 p.m. UTC | #1
On Fri, Jul 21, 2023 at 09:18:00PM +0800, Baoquan He wrote:
> The variable 'err' is assgigned to an error message if atomic alloc
> failed, while it has no chance to be printed if is_atomic is true.
> 
> Here change to print error message too if atomic alloc failed, while
> avoid to call dump_stack() if that case.
> 
> Signed-off-by: Baoquan He <bhe@redhat.com>
> ---
>  mm/percpu.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/percpu.c b/mm/percpu.c
> index c25b058a46ad..74f75ef0ad58 100644
> --- a/mm/percpu.c
> +++ b/mm/percpu.c
> @@ -1890,13 +1890,15 @@ static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved,
>  fail:
>  	trace_percpu_alloc_percpu_fail(reserved, is_atomic, size, align);
>  
> -	if (!is_atomic && do_warn && warn_limit) {
> +	if (do_warn && warn_limit) {
>  		pr_warn("allocation failed, size=%zu align=%zu atomic=%d, %s\n",
>  			size, align, is_atomic, err);
> -		dump_stack();
> +		if (is_atomic)
> +			dump_stack();

This should be (!is_atomic) to preserve the current logic?

>  		if (!--warn_limit)
>  			pr_info("limit reached, disable warning\n");
>  	}
> +
>  	if (is_atomic) {
>  		/* see the flag handling in pcpu_balance_workfn() */
>  		pcpu_atomic_alloc_failed = true;
> -- 
> 2.34.1
> 

Thanks,
Dennis
Baoquan He July 22, 2023, 1:56 a.m. UTC | #2
On 07/21/23 at 02:03pm, Dennis Zhou wrote:
> On Fri, Jul 21, 2023 at 09:18:00PM +0800, Baoquan He wrote:
> > The variable 'err' is assgigned to an error message if atomic alloc
> > failed, while it has no chance to be printed if is_atomic is true.
> > 
> > Here change to print error message too if atomic alloc failed, while
> > avoid to call dump_stack() if that case.
> > 
> > Signed-off-by: Baoquan He <bhe@redhat.com>
> > ---
> >  mm/percpu.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/mm/percpu.c b/mm/percpu.c
> > index c25b058a46ad..74f75ef0ad58 100644
> > --- a/mm/percpu.c
> > +++ b/mm/percpu.c
> > @@ -1890,13 +1890,15 @@ static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved,
> >  fail:
> >  	trace_percpu_alloc_percpu_fail(reserved, is_atomic, size, align);
> >  
> > -	if (!is_atomic && do_warn && warn_limit) {
> > +	if (do_warn && warn_limit) {
> >  		pr_warn("allocation failed, size=%zu align=%zu atomic=%d, %s\n",
> >  			size, align, is_atomic, err);
> > -		dump_stack();
> > +		if (is_atomic)
> > +			dump_stack();
> 
> This should be (!is_atomic) to preserve the current logic?

You are quite right, I must be dizzy at the moment when making change.
Will fix this. Thanks for reviewing.

> 
> >  		if (!--warn_limit)
> >  			pr_info("limit reached, disable warning\n");
> >  	}
> > +
> >  	if (is_atomic) {
> >  		/* see the flag handling in pcpu_balance_workfn() */
> >  		pcpu_atomic_alloc_failed = true;
> > -- 
> > 2.34.1
> > 
> 
> Thanks,
> Dennis
>
diff mbox series

Patch

diff --git a/mm/percpu.c b/mm/percpu.c
index c25b058a46ad..74f75ef0ad58 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1890,13 +1890,15 @@  static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved,
 fail:
 	trace_percpu_alloc_percpu_fail(reserved, is_atomic, size, align);
 
-	if (!is_atomic && do_warn && warn_limit) {
+	if (do_warn && warn_limit) {
 		pr_warn("allocation failed, size=%zu align=%zu atomic=%d, %s\n",
 			size, align, is_atomic, err);
-		dump_stack();
+		if (is_atomic)
+			dump_stack();
 		if (!--warn_limit)
 			pr_info("limit reached, disable warning\n");
 	}
+
 	if (is_atomic) {
 		/* see the flag handling in pcpu_balance_workfn() */
 		pcpu_atomic_alloc_failed = true;