All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/compaction: Fix warning of 'flags' may be used uninitialized
@ 2014-09-10  6:12 Xiubo Li
  2014-09-10 18:50 ` David Rientjes
  0 siblings, 1 reply; 5+ messages in thread
From: Xiubo Li @ 2014-09-10  6:12 UTC (permalink / raw)
  To: akpm, vbabka, mgorman, rientjes, minchan, linux-mm; +Cc: Xiubo Li

C      mm/compaction.o
mm/compaction.c: In function isolate_freepages_block:
mm/compaction.c:364:37: warning: flags may be used uninitialized in
this function [-Wmaybe-uninitialized]
       && compact_unlock_should_abort(&cc->zone->lock, flags,
                                     ^
In file included from include/linux/irqflags.h:15:0,
                 from ./arch/arm/include/asm/bitops.h:27,
                 from include/linux/bitops.h:33,
                 from include/linux/kernel.h:10,
                 from include/linux/list.h:8,
                 from include/linux/preempt.h:10,
                 from include/linux/spinlock.h:50,
                 from include/linux/swap.h:4,
                 from mm/compaction.c:10:
mm/compaction.c: In function isolate_migratepages_block:
./arch/arm/include/asm/irqflags.h:152:2: warning: flags may be used
uninitialized in this function [-Wmaybe-uninitialized]
  asm volatile(
  ^
mm/compaction.c:576:16: note: flags as declared here
  unsigned long flags;
                ^

Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
---
 mm/compaction.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/compaction.c b/mm/compaction.c
index 7d9d92e..fb28d85 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -344,7 +344,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
 {
 	int nr_scanned = 0, total_isolated = 0;
 	struct page *cursor, *valid_page = NULL;
-	unsigned long flags;
+	unsigned long flags = 0;
 	bool locked = false;
 	unsigned long blockpfn = *start_pfn;
 
@@ -573,7 +573,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
 	unsigned long nr_scanned = 0, nr_isolated = 0;
 	struct list_head *migratelist = &cc->migratepages;
 	struct lruvec *lruvec;
-	unsigned long flags;
+	unsigned long flags = 0;
 	bool locked = false;
 	struct page *page = NULL, *valid_page = NULL;
 
-- 
2.1.0.27.g96db324

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm/compaction: Fix warning of 'flags' may be used uninitialized
  2014-09-10  6:12 [PATCH] mm/compaction: Fix warning of 'flags' may be used uninitialized Xiubo Li
@ 2014-09-10 18:50 ` David Rientjes
  2014-09-11  8:04   ` Michal Hocko
  2014-09-11  9:02   ` Arnd Bergmann
  0 siblings, 2 replies; 5+ messages in thread
From: David Rientjes @ 2014-09-10 18:50 UTC (permalink / raw)
  To: Xiubo Li; +Cc: Andrew Morton, Arnd Bergmann, vbabka, mgorman, minchan, linux-mm

On Wed, 10 Sep 2014, Xiubo Li wrote:

> C      mm/compaction.o
> mm/compaction.c: In function isolate_freepages_block:
> mm/compaction.c:364:37: warning: flags may be used uninitialized in
> this function [-Wmaybe-uninitialized]
>        && compact_unlock_should_abort(&cc->zone->lock, flags,
>                                      ^
> In file included from include/linux/irqflags.h:15:0,
>                  from ./arch/arm/include/asm/bitops.h:27,
>                  from include/linux/bitops.h:33,
>                  from include/linux/kernel.h:10,
>                  from include/linux/list.h:8,
>                  from include/linux/preempt.h:10,
>                  from include/linux/spinlock.h:50,
>                  from include/linux/swap.h:4,
>                  from mm/compaction.c:10:
> mm/compaction.c: In function isolate_migratepages_block:
> ./arch/arm/include/asm/irqflags.h:152:2: warning: flags may be used
> uninitialized in this function [-Wmaybe-uninitialized]
>   asm volatile(
>   ^
> mm/compaction.c:576:16: note: flags as declared here
>   unsigned long flags;
>                 ^
> 
> Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>

Arnd Bergmann already sent a patch for this to use uninitialized_var() 
privately but it didn't get cc'd to any mailing list, sorry.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm/compaction: Fix warning of 'flags' may be used uninitialized
  2014-09-10 18:50 ` David Rientjes
@ 2014-09-11  8:04   ` Michal Hocko
  2014-09-11  9:27     ` Li.Xiubo
  2014-09-11  9:02   ` Arnd Bergmann
  1 sibling, 1 reply; 5+ messages in thread
From: Michal Hocko @ 2014-09-11  8:04 UTC (permalink / raw)
  To: David Rientjes
  Cc: Xiubo Li, Andrew Morton, Arnd Bergmann, vbabka, mgorman, minchan,
	linux-mm

On Wed 10-09-14 11:50:41, David Rientjes wrote:
> On Wed, 10 Sep 2014, Xiubo Li wrote:
> 
> > C      mm/compaction.o
> > mm/compaction.c: In function isolate_freepages_block:
> > mm/compaction.c:364:37: warning: flags may be used uninitialized in
> > this function [-Wmaybe-uninitialized]
> >        && compact_unlock_should_abort(&cc->zone->lock, flags,
> >                                      ^
> > In file included from include/linux/irqflags.h:15:0,
> >                  from ./arch/arm/include/asm/bitops.h:27,
> >                  from include/linux/bitops.h:33,
> >                  from include/linux/kernel.h:10,
> >                  from include/linux/list.h:8,
> >                  from include/linux/preempt.h:10,
> >                  from include/linux/spinlock.h:50,
> >                  from include/linux/swap.h:4,
> >                  from mm/compaction.c:10:
> > mm/compaction.c: In function isolate_migratepages_block:
> > ./arch/arm/include/asm/irqflags.h:152:2: warning: flags may be used
> > uninitialized in this function [-Wmaybe-uninitialized]
> >   asm volatile(
> >   ^
> > mm/compaction.c:576:16: note: flags as declared here
> >   unsigned long flags;
> >                 ^
> > 
> > Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
> 
> Arnd Bergmann already sent a patch for this to use uninitialized_var() 
> privately but it didn't get cc'd to any mailing list, sorry.

Besides that setting flags to 0 is certainly a misleading way to fix
this issue. uninitialized_var is a correct way because the warning is a
false possitive. compact_unlock_should_abort will not touch the flags if
locked is false and this is true only after a lock has been taken and
flags set. (this should be preferably in the patch description).

-- 
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm/compaction: Fix warning of 'flags' may be used uninitialized
  2014-09-10 18:50 ` David Rientjes
  2014-09-11  8:04   ` Michal Hocko
@ 2014-09-11  9:02   ` Arnd Bergmann
  1 sibling, 0 replies; 5+ messages in thread
From: Arnd Bergmann @ 2014-09-11  9:02 UTC (permalink / raw)
  To: David Rientjes
  Cc: Xiubo Li, Andrew Morton, vbabka, mgorman, minchan, linux-mm

On Wednesday 10 September 2014 11:50:41 David Rientjes wrote:
> On Wed, 10 Sep 2014, Xiubo Li wrote:
> 
> > C      mm/compaction.o
> > mm/compaction.c: In function isolate_freepages_block:
> > mm/compaction.c:364:37: warning: flags may be used uninitialized in
> > this function [-Wmaybe-uninitialized]
> >        && compact_unlock_should_abort(&cc->zone->lock, flags,
> >                                      ^
> > In file included from include/linux/irqflags.h:15:0,
> >                  from ./arch/arm/include/asm/bitops.h:27,
> >                  from include/linux/bitops.h:33,
> >                  from include/linux/kernel.h:10,
> >                  from include/linux/list.h:8,
> >                  from include/linux/preempt.h:10,
> >                  from include/linux/spinlock.h:50,
> >                  from include/linux/swap.h:4,
> >                  from mm/compaction.c:10:
> > mm/compaction.c: In function isolate_migratepages_block:
> > ./arch/arm/include/asm/irqflags.h:152:2: warning: flags may be used
> > uninitialized in this function [-Wmaybe-uninitialized]
> >   asm volatile(
> >   ^
> > mm/compaction.c:576:16: note: flags as declared here
> >   unsigned long flags;
> >                 ^
> > 
> > Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
> 
> Arnd Bergmann already sent a patch for this to use uninitialized_var() 
> privately but it didn't get cc'd to any mailing list, sorry.

Oops, I hadn't noticed that I missed the mailing lists, sorry about that.
For reference, see my patch below.

	Arnd

8<------

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

* RE: [PATCH] mm/compaction: Fix warning of 'flags' may be used uninitialized
  2014-09-11  8:04   ` Michal Hocko
@ 2014-09-11  9:27     ` Li.Xiubo
  0 siblings, 0 replies; 5+ messages in thread
From: Li.Xiubo @ 2014-09-11  9:27 UTC (permalink / raw)
  To: Michal Hocko, David Rientjes
  Cc: Andrew Morton, Arnd Bergmann, vbabka, mgorman, minchan, linux-mm

Hi,

> > Arnd Bergmann already sent a patch for this to use uninitialized_var()
> > privately but it didn't get cc'd to any mailing list, sorry.
> 
> Besides that setting flags to 0 is certainly a misleading way to fix
> this issue. uninitialized_var is a correct way because the warning is a
> false possitive. compact_unlock_should_abort will not touch the flags if
> locked is false and this is true only after a lock has been taken and
> flags set. (this should be preferably in the patch description).
> 

Yes, right.

This should be added to the commit comment with the patch.

Thanks,

BRs
Xiubo

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2014-09-11  9:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-10  6:12 [PATCH] mm/compaction: Fix warning of 'flags' may be used uninitialized Xiubo Li
2014-09-10 18:50 ` David Rientjes
2014-09-11  8:04   ` Michal Hocko
2014-09-11  9:27     ` Li.Xiubo
2014-09-11  9:02   ` Arnd Bergmann

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.