All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Snitzer <snitzer@redhat.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Jens Axboe <axboe@kernel.dk>, Mark Rutland <mark.rutland@arm.com>,
	Jan Kara <jack@suse.cz>, Eric Biggers <ebiggers@google.com>,
	linux-kernel@vger.kernel.org, dm-devel@redhat.com,
	Aliaksei Karaliou <akaraliou.dev@gmail.com>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Mikulas Patocka <mpatocka@redhat.com>,
	Ingo Molnar <mingo@kernel.org>, Alasdair Kergon <agk@redhat.com>
Subject: Re: dm-bufio: avoid false-positive Wmaybe-uninitialized warning
Date: Thu, 22 Feb 2018 11:04:32 -0500	[thread overview]
Message-ID: <20180222160432.GA16971@redhat.com> (raw)
In-Reply-To: <20180222155627.1800948-1-arnd@arndb.de>

On Thu, Feb 22 2018 at 10:56am -0500,
Arnd Bergmann <arnd@arndb.de> wrote:

> gcc-6.3 and earlier show a new warning after a seemingly unrelated change
> to the arm64 PAGE_KERNEL definition:
> 
> In file included from drivers/md/dm-bufio.c:14:0:
> drivers/md/dm-bufio.c: In function 'alloc_buffer':
> include/linux/sched/mm.h:182:56: warning: 'noio_flag' may be used uninitialized in this function [-Wmaybe-uninitialized]
>   current->flags = (current->flags & ~PF_MEMALLOC_NOIO) | flags;
>                                                         ^
> 
> The same warning happened earlier on linux-3.18 for MIPS and I did a
> workaround for that, but now it's come back.
> 
> gcc-7 and newer are apparently smart enough to figure this out, and
> other architectures don't show it, so the best I could come up with is
> to rework the caller slightly in a way that makes it obvious enough to
> all arm64 compilers what is happening here.
> 
> Fixes: 41acec624087 ("arm64: kpti: Make use of nG dependent on arm64_kernel_unmapped_at_el0()")
> Link: https://patchwork.kernel.org/patch/9692829/
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/md/dm-bufio.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
> index 414c9af54ded..e7ad6fc6a5ea 100644
> --- a/drivers/md/dm-bufio.c
> +++ b/drivers/md/dm-bufio.c
> @@ -413,13 +413,13 @@ static void *alloc_buffer_data(struct dm_bufio_client *c, gfp_t gfp_mask,
>  	 * as if GFP_NOIO was specified.
>  	 */
>  
> -	if (gfp_mask & __GFP_NORETRY)
> +	if (gfp_mask & __GFP_NORETRY) {
>  		noio_flag = memalloc_noio_save();
> -
> -	ptr = __vmalloc(c->block_size, gfp_mask, PAGE_KERNEL);
> -
> -	if (gfp_mask & __GFP_NORETRY)
> +		ptr = __vmalloc(c->block_size, gfp_mask, PAGE_KERNEL);
>  		memalloc_noio_restore(noio_flag);
> +	} else {
> +		ptr = __vmalloc(c->block_size, gfp_mask, PAGE_KERNEL);
> +	}
>  
>  	return ptr;
>  }

Mikulas already sent a fix for this:
https://patchwork.kernel.org/patch/10211631/

But I like yours a bit better, though I'll likely move the declaration
of 'noio_flag' temporary inside the conditional.

Anyway, I'll get this fixed up shortly, thanks.

Mike

WARNING: multiple messages have this Message-ID (diff)
From: Mike Snitzer <snitzer@redhat.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Alasdair Kergon <agk@redhat.com>,
	dm-devel@redhat.com, Mikulas Patocka <mpatocka@redhat.com>,
	Ingo Molnar <mingo@kernel.org>,
	Aliaksei Karaliou <akaraliou.dev@gmail.com>,
	Jens Axboe <axboe@kernel.dk>, Jan Kara <jack@suse.cz>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Eric Biggers <ebiggers@google.com>,
	linux-kernel@vger.kernel.org
Subject: Re: dm-bufio: avoid false-positive Wmaybe-uninitialized warning
Date: Thu, 22 Feb 2018 11:04:32 -0500	[thread overview]
Message-ID: <20180222160432.GA16971@redhat.com> (raw)
In-Reply-To: <20180222155627.1800948-1-arnd@arndb.de>

On Thu, Feb 22 2018 at 10:56am -0500,
Arnd Bergmann <arnd@arndb.de> wrote:

> gcc-6.3 and earlier show a new warning after a seemingly unrelated change
> to the arm64 PAGE_KERNEL definition:
> 
> In file included from drivers/md/dm-bufio.c:14:0:
> drivers/md/dm-bufio.c: In function 'alloc_buffer':
> include/linux/sched/mm.h:182:56: warning: 'noio_flag' may be used uninitialized in this function [-Wmaybe-uninitialized]
>   current->flags = (current->flags & ~PF_MEMALLOC_NOIO) | flags;
>                                                         ^
> 
> The same warning happened earlier on linux-3.18 for MIPS and I did a
> workaround for that, but now it's come back.
> 
> gcc-7 and newer are apparently smart enough to figure this out, and
> other architectures don't show it, so the best I could come up with is
> to rework the caller slightly in a way that makes it obvious enough to
> all arm64 compilers what is happening here.
> 
> Fixes: 41acec624087 ("arm64: kpti: Make use of nG dependent on arm64_kernel_unmapped_at_el0()")
> Link: https://patchwork.kernel.org/patch/9692829/
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/md/dm-bufio.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
> index 414c9af54ded..e7ad6fc6a5ea 100644
> --- a/drivers/md/dm-bufio.c
> +++ b/drivers/md/dm-bufio.c
> @@ -413,13 +413,13 @@ static void *alloc_buffer_data(struct dm_bufio_client *c, gfp_t gfp_mask,
>  	 * as if GFP_NOIO was specified.
>  	 */
>  
> -	if (gfp_mask & __GFP_NORETRY)
> +	if (gfp_mask & __GFP_NORETRY) {
>  		noio_flag = memalloc_noio_save();
> -
> -	ptr = __vmalloc(c->block_size, gfp_mask, PAGE_KERNEL);
> -
> -	if (gfp_mask & __GFP_NORETRY)
> +		ptr = __vmalloc(c->block_size, gfp_mask, PAGE_KERNEL);
>  		memalloc_noio_restore(noio_flag);
> +	} else {
> +		ptr = __vmalloc(c->block_size, gfp_mask, PAGE_KERNEL);
> +	}
>  
>  	return ptr;
>  }

Mikulas already sent a fix for this:
https://patchwork.kernel.org/patch/10211631/

But I like yours a bit better, though I'll likely move the declaration
of 'noio_flag' temporary inside the conditional.

Anyway, I'll get this fixed up shortly, thanks.

Mike

  reply	other threads:[~2018-02-22 16:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-22 15:56 [PATCH] dm-bufio: avoid false-positive Wmaybe-uninitialized warning Arnd Bergmann
2018-02-22 15:56 ` Arnd Bergmann
2018-02-22 16:04 ` Mike Snitzer [this message]
2018-02-22 16:04   ` Mike Snitzer
2018-03-06 21:33   ` Arnd Bergmann
2018-03-07  1:29     ` Mike Snitzer
2018-03-07  8:48       ` Arnd Bergmann

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=20180222160432.GA16971@redhat.com \
    --to=snitzer@redhat.com \
    --cc=agk@redhat.com \
    --cc=akaraliou.dev@gmail.com \
    --cc=arnd@arndb.de \
    --cc=axboe@kernel.dk \
    --cc=dan.carpenter@oracle.com \
    --cc=dm-devel@redhat.com \
    --cc=ebiggers@google.com \
    --cc=jack@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@kernel.org \
    --cc=mpatocka@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.