* [PATCH 4.9] dm bufio: avoid false-positive Wmaybe-uninitialized warning
@ 2018-06-11 16:05 Nathan Chancellor
2018-06-12 16:12 ` Greg Kroah-Hartman
0 siblings, 1 reply; 3+ messages in thread
From: Nathan Chancellor @ 2018-06-11 16:05 UTC (permalink / raw)
To: Greg Kroah-Hartman, stable; +Cc: Arnd Bergmann, Mike Snitzer, Nathan Chancellor
From: Arnd Bergmann <arnd@arndb.de>
commit 590347e4000356f55eb10b03ced2686bd74dab40 upstream.
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/
Cc: stable@vger.kernel.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
[snitzer: moved declarations inside conditional, altered vmalloc return]
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
[nc: Backport to 4.9, adjust context for lack of 19809c2da28a]
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
Hi Greg,
Resending this with a proper prefix and message, in case the other one
fell through the cracks. I came across this warning when building with
Google's stock GCC 4.9 toolchain on the OnePlus 6. Context was adjusted
around lack of commit 19809c2da28a ("mm, vmalloc: use __GFP_HIGHMEM
implicitly") in 4.9. Please apply when you get a chance.
Thanks!
Nathan
drivers/md/dm-bufio.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
index 3ec647e8b9c6..35fd57fdeba9 100644
--- a/drivers/md/dm-bufio.c
+++ b/drivers/md/dm-bufio.c
@@ -373,9 +373,6 @@ static void __cache_size_refresh(void)
static void *alloc_buffer_data(struct dm_bufio_client *c, gfp_t gfp_mask,
enum data_mode *data_mode)
{
- unsigned noio_flag;
- void *ptr;
-
if (c->block_size <= DM_BUFIO_BLOCK_SIZE_SLAB_LIMIT) {
*data_mode = DATA_MODE_SLAB;
return kmem_cache_alloc(DM_BUFIO_CACHE(c), gfp_mask);
@@ -399,16 +396,16 @@ static void *alloc_buffer_data(struct dm_bufio_client *c, gfp_t gfp_mask,
* all allocations done by this process (including pagetables) are done
* as if GFP_NOIO was specified.
*/
+ if (gfp_mask & __GFP_NORETRY) {
+ unsigned noio_flag = memalloc_noio_save();
+ void *ptr = __vmalloc(c->block_size, gfp_mask | __GFP_HIGHMEM,
+ PAGE_KERNEL);
- if (gfp_mask & __GFP_NORETRY)
- noio_flag = memalloc_noio_save();
-
- ptr = __vmalloc(c->block_size, gfp_mask | __GFP_HIGHMEM, PAGE_KERNEL);
-
- if (gfp_mask & __GFP_NORETRY)
memalloc_noio_restore(noio_flag);
+ return ptr;
+ }
- return ptr;
+ return __vmalloc(c->block_size, gfp_mask | __GFP_HIGHMEM, PAGE_KERNEL);
}
/*
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 4.9] dm bufio: avoid false-positive Wmaybe-uninitialized warning
2018-06-11 16:05 [PATCH 4.9] dm bufio: avoid false-positive Wmaybe-uninitialized warning Nathan Chancellor
@ 2018-06-12 16:12 ` Greg Kroah-Hartman
2018-06-12 16:37 ` Nathan Chancellor
0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2018-06-12 16:12 UTC (permalink / raw)
To: Nathan Chancellor; +Cc: stable, Arnd Bergmann, Mike Snitzer
On Mon, Jun 11, 2018 at 09:05:33AM -0700, Nathan Chancellor wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> commit 590347e4000356f55eb10b03ced2686bd74dab40 upstream.
>
> 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/
> Cc: stable@vger.kernel.org
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> [snitzer: moved declarations inside conditional, altered vmalloc return]
> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
> [nc: Backport to 4.9, adjust context for lack of 19809c2da28a]
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>
> Hi Greg,
>
> Resending this with a proper prefix and message, in case the other one
> fell through the cracks. I came across this warning when building with
> Google's stock GCC 4.9 toolchain on the OnePlus 6. Context was adjusted
> around lack of commit 19809c2da28a ("mm, vmalloc: use __GFP_HIGHMEM
> implicitly") in 4.9. Please apply when you get a chance.
Now queued up, thanks. The other one was still in my queue, give me a
chance to catch up :)
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 4.9] dm bufio: avoid false-positive Wmaybe-uninitialized warning
2018-06-12 16:12 ` Greg Kroah-Hartman
@ 2018-06-12 16:37 ` Nathan Chancellor
0 siblings, 0 replies; 3+ messages in thread
From: Nathan Chancellor @ 2018-06-12 16:37 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: stable, Arnd Bergmann, Mike Snitzer
On Tue, Jun 12, 2018 at 06:12:13PM +0200, Greg Kroah-Hartman wrote:
> On Mon, Jun 11, 2018 at 09:05:33AM -0700, Nathan Chancellor wrote:
> > From: Arnd Bergmann <arnd@arndb.de>
> >
> > commit 590347e4000356f55eb10b03ced2686bd74dab40 upstream.
> >
> > 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/
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > [snitzer: moved declarations inside conditional, altered vmalloc return]
> > Signed-off-by: Mike Snitzer <snitzer@redhat.com>
> > [nc: Backport to 4.9, adjust context for lack of 19809c2da28a]
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > ---
> >
> > Hi Greg,
> >
> > Resending this with a proper prefix and message, in case the other one
> > fell through the cracks. I came across this warning when building with
> > Google's stock GCC 4.9 toolchain on the OnePlus 6. Context was adjusted
> > around lack of commit 19809c2da28a ("mm, vmalloc: use __GFP_HIGHMEM
> > implicitly") in 4.9. Please apply when you get a chance.
>
> Now queued up, thanks. The other one was still in my queue, give me a
> chance to catch up :)
>
> greg k-h
Sorry, didn't realize you were behind :/
Thanks for the timely response on this one!
Nathan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-06-12 16:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-11 16:05 [PATCH 4.9] dm bufio: avoid false-positive Wmaybe-uninitialized warning Nathan Chancellor
2018-06-12 16:12 ` Greg Kroah-Hartman
2018-06-12 16:37 ` Nathan Chancellor
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.