linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dm-bufio: avoid false-positive Wmaybe-uninitialized warning
@ 2018-02-22 15:56 Arnd Bergmann
  2018-02-22 16:04 ` Mike Snitzer
  0 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2018-02-22 15:56 UTC (permalink / raw)
  To: Alasdair Kergon, Mike Snitzer, dm-devel
  Cc: Arnd Bergmann, Mikulas Patocka, Ingo Molnar, Aliaksei Karaliou,
	Jens Axboe, Jan Kara, Dan Carpenter, Mark Rutland, Eric Biggers,
	linux-kernel

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;
 }
-- 
2.9.0

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

* Re: dm-bufio: avoid false-positive Wmaybe-uninitialized warning
  2018-02-22 15:56 [PATCH] dm-bufio: avoid false-positive Wmaybe-uninitialized warning Arnd Bergmann
@ 2018-02-22 16:04 ` Mike Snitzer
  2018-03-06 21:33   ` Arnd Bergmann
  0 siblings, 1 reply; 5+ messages in thread
From: Mike Snitzer @ 2018-02-22 16:04 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Alasdair Kergon, dm-devel, Mikulas Patocka, Ingo Molnar,
	Aliaksei Karaliou, Jens Axboe, Jan Kara, Dan Carpenter,
	Mark Rutland, Eric Biggers, linux-kernel

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

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

* Re: dm-bufio: avoid false-positive Wmaybe-uninitialized warning
  2018-02-22 16:04 ` Mike Snitzer
@ 2018-03-06 21:33   ` Arnd Bergmann
  2018-03-07  1:29     ` Mike Snitzer
  0 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2018-03-06 21:33 UTC (permalink / raw)
  To: Mike Snitzer
  Cc: Alasdair Kergon, dm-devel, Mikulas Patocka, Ingo Molnar,
	Aliaksei Karaliou, Jens Axboe, Jan Kara, Dan Carpenter,
	Mark Rutland, Eric Biggers, Linux Kernel Mailing List, stable

On Thu, Feb 22, 2018 at 5:04 PM, Mike Snitzer <snitzer@redhat.com> wrote:
> On Thu, Feb 22 2018 at 10:56am -0500,
> Arnd Bergmann <arnd@arndb.de> wrote:

>
> 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.

I see the fix made it into linux-next on the same day, but the build bots still
report the warning for mainline kernels and now also for stable kernels
that got a backport of the patch that introduced it on arm64.

I assume you had not planned to send it for mainline, any chance you
could change that and send it as a bugfix with a 'Cc:
stable@vger.kernel.org' tag to restore a clean build?

       Arnd

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

* Re: dm-bufio: avoid false-positive Wmaybe-uninitialized warning
  2018-03-06 21:33   ` Arnd Bergmann
@ 2018-03-07  1:29     ` Mike Snitzer
  2018-03-07  8:48       ` Arnd Bergmann
  0 siblings, 1 reply; 5+ messages in thread
From: Mike Snitzer @ 2018-03-07  1:29 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Alasdair Kergon, dm-devel, Mikulas Patocka, Ingo Molnar,
	Aliaksei Karaliou, Jens Axboe, Jan Kara, Dan Carpenter,
	Mark Rutland, Eric Biggers, Linux Kernel Mailing List, stable

On Tue, Mar 06 2018 at  4:33pm -0500,
Arnd Bergmann <arnd@arndb.de> wrote:

> On Thu, Feb 22, 2018 at 5:04 PM, Mike Snitzer <snitzer@redhat.com> wrote:
> > On Thu, Feb 22 2018 at 10:56am -0500,
> > Arnd Bergmann <arnd@arndb.de> wrote:
> 
> >
> > 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.
> 
> I see the fix made it into linux-next on the same day, but the build bots still
> report the warning for mainline kernels and now also for stable kernels
> that got a backport of the patch that introduced it on arm64.
> 
> I assume you had not planned to send it for mainline, any chance you
> could change that and send it as a bugfix with a 'Cc:
> stable@vger.kernel.org' tag to restore a clean build?

I did/do plan to send to Linus this week.

But I've updated the commit header to include the CC: stable like you
asked.

Thanks,
Mike

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

* Re: dm-bufio: avoid false-positive Wmaybe-uninitialized warning
  2018-03-07  1:29     ` Mike Snitzer
@ 2018-03-07  8:48       ` Arnd Bergmann
  0 siblings, 0 replies; 5+ messages in thread
From: Arnd Bergmann @ 2018-03-07  8:48 UTC (permalink / raw)
  To: Mike Snitzer
  Cc: Alasdair Kergon, dm-devel, Mikulas Patocka, Ingo Molnar,
	Aliaksei Karaliou, Jens Axboe, Jan Kara, Dan Carpenter,
	Mark Rutland, Eric Biggers, Linux Kernel Mailing List, stable

On Wed, Mar 7, 2018 at 2:29 AM, Mike Snitzer <snitzer@redhat.com> wrote:
> On Tue, Mar 06 2018 at  4:33pm -0500,
> Arnd Bergmann <arnd@arndb.de> wrote:
>
>> On Thu, Feb 22, 2018 at 5:04 PM, Mike Snitzer <snitzer@redhat.com> wrote:
>> > On Thu, Feb 22 2018 at 10:56am -0500,
>> > Arnd Bergmann <arnd@arndb.de> wrote:
>>
>> >
>> > 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.
>>
>> I see the fix made it into linux-next on the same day, but the build bots still
>> report the warning for mainline kernels and now also for stable kernels
>> that got a backport of the patch that introduced it on arm64.
>>
>> I assume you had not planned to send it for mainline, any chance you
>> could change that and send it as a bugfix with a 'Cc:
>> stable@vger.kernel.org' tag to restore a clean build?
>
> I did/do plan to send to Linus this week.
>
> But I've updated the commit header to include the CC: stable like you
> asked.

Got it, thanks a lot, that brings us down to two kernelci warnings for 4.16
and one for 4.15-stable then.

      Arnd

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

end of thread, other threads:[~2018-03-07  8:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-22 15:56 [PATCH] dm-bufio: avoid false-positive Wmaybe-uninitialized warning Arnd Bergmann
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

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).