linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Baoquan He <bhe@redhat.com>
To: Wupeng Ma <mawupeng1@huawei.com>
Cc: akpm@linux-foundation.org, tj@kernel.org, dennis@kernel.org,
	cl@linux.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH -next 1/1] percpu: cleanup invalid assignment to err in pcpu_alloc
Date: Sun, 4 Dec 2022 20:11:23 +0800	[thread overview]
Message-ID: <Y4yOMmnrT772wFSL@MiWiFi-R3L-srv> (raw)
In-Reply-To: <20221204031430.662169-1-mawupeng1@huawei.com>

On 12/04/22 at 11:14am, Wupeng Ma wrote:
> From: Ma Wupeng <mawupeng1@huawei.com>
> 
> Assignment to err if is_atomic is true will never be used since warn
> message can only be shown if is_atomic is false after label fail. So drop
> it.
> 
> Signed-off-by: Ma Wupeng <mawupeng1@huawei.com>
> ---
>  mm/percpu.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/mm/percpu.c b/mm/percpu.c
> index acd78da0493b..df86d79325b2 100644
> --- a/mm/percpu.c
> +++ b/mm/percpu.c
> @@ -1817,10 +1817,8 @@ static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved,
>  
>  	spin_unlock_irqrestore(&pcpu_lock, flags);
>  
> -	if (is_atomic) {
> -		err = "atomic alloc failed, no space left";
> +	if (is_atomic)
>  		goto fail;
> -	}

This is good catch. But I think Dennis may not like this way because he
added the message intentionally in commit 11df02bf9bc1 ("percpu: resolve
err may not be initialized in pcpu_alloc").

Can we change the conditional checking in fail part as below?

diff --git a/mm/percpu.c b/mm/percpu.c
index 27697b2429c2..0ac55500fad9 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1897,7 +1897,7 @@ 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();



  reply	other threads:[~2022-12-04 12:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-04  3:14 [PATCH -next 1/1] percpu: cleanup invalid assignment to err in pcpu_alloc Wupeng Ma
2022-12-04 12:11 ` Baoquan He [this message]
2022-12-04 16:21   ` Christoph Lameter
2022-12-05  0:30   ` Dennis Zhou
2022-12-05  2:24     ` Baoquan He

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y4yOMmnrT772wFSL@MiWiFi-R3L-srv \
    --to=bhe@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=dennis@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mawupeng1@huawei.com \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).