Re: [PATCH -next 1/1] percpu: cleanup invalid assignment to err in pcpu_alloc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/04/22 at 11:14am, Wupeng Ma wrote:
> From: Ma Wupeng <mawupeng1@xxxxxxxxxx>
> 
> 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@xxxxxxxxxx>
> ---
>  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();





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux