Re: [PATCH v14 049/138] mm/memcg: Add folio_lruvec_relock_irq() and folio_lruvec_relock_irqsave()

From: Matthew Wilcox
Date: Thu Jul 29 2021 - 09:39:54 EST


On Thu, Jul 29, 2021 at 09:36:44AM +0100, Mel Gorman wrote:
> On Thu, Jul 15, 2021 at 04:35:35AM +0100, Matthew Wilcox (Oracle) wrote:
> > These are the folio equivalents of relock_page_lruvec_irq() and
> > folio_lruvec_relock_irqsave(). Also convert page_matches_lruvec()
> > to folio_matches_lruvec().
> >
> > Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
> > Reviewed-by: Christoph Hellwig <hch@xxxxxx>
>
> When build testing what you had in your for-next branch, I got a new
> warning for powerpc defconfig
>
> In file included from ./include/linux/mmzone.h:8,
> from ./include/linux/gfp.h:6,
> from ./include/linux/mm.h:10,
> from mm/swap.c:17:
> mm/swap.c: In function 'release_pages':
> ./include/linux/spinlock.h:290:3: warning: 'flags' may be used uninitialized in this function [-Wmaybe-uninitialized]
> 290 | _raw_spin_unlock_irqrestore(lock, flags); \
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
> mm/swap.c:906:16: note: 'flags' was declared here
> 906 | unsigned long flags;
> | ^~~~~
>
> I'm fairly sure it's a false positive and the compiler just cannot figure
> out that flags are only accessed when lruvec is !NULL and once lruvec is
> !NULL, flags are valid

Yes, I read it over carefully and I can't see a way in which this
can happen. Weird that this change made the compiler unable to figure
that out. Pushed out a new for-next with your patch included. Thanks!