linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@kernel.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Mel Gorman <mgorman@techsingularity.net>,
	Vlastimil Babka <vbabka@suse.cz>,
	David Rientjes <rientjes@google.com>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	Taku Izumi <izumi.taku@jp.fujitsu.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm, compaction: avoid uninitialized variable use
Date: Wed, 11 May 2016 18:13:18 +0200	[thread overview]
Message-ID: <20160511161318.GA24901@dhcp22.suse.cz> (raw)
In-Reply-To: <2695751.e2s15gCWav@wuerfel>

On Wed 11-05-16 16:52:41, Arnd Bergmann wrote:
> On Wednesday 11 May 2016 16:44:07 Michal Hocko wrote:
> > On Wed 11-05-16 15:24:44, Arnd Bergmann wrote:
> > > A recent rework of the compaction code introduced a warning about
> > > an uninitialized variable when CONFIG_COMPACTION is disabled and
> > > __alloc_pages_direct_compact() does not set its 'compact_result'
> > > output argument:
> > > 
> > > mm/page_alloc.c: In function '__alloc_pages_nodemask':
> > > mm/page_alloc.c:3651:6: error: 'compact_result' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> > > 
> > > This adds another check for CONFIG_COMPACTION to ensure we never
> > > evaluate the uninitialized variable in this configuration, which
> > > is probably the simplest way to avoid the warning.
> > 
> > I think that hiding this into __alloc_pages_direct_compact is a better
> > idea. See the diff below
> 
> Ok, sounds good.
> 
> > --- 
> > diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> > index 4950d01ff935..14e3b4d93adc 100644
> > --- a/mm/page_alloc.c
> > +++ b/mm/page_alloc.c
> > @@ -3300,6 +3300,7 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order,
> >                 unsigned int alloc_flags, const struct alloc_context *ac,
> >                 enum migrate_mode mode, enum compact_result *compact_result)
> >  {
> > +       *compact_result = COMPACT_DEFERRED;
> >         return NULL;
> >  }
> > 
> 
> I thought about this but didn't know which COMPACT_* value was appropriate here.
> 
> The behavior then changes a bit with your approach compared to mine,
> because 
> 
>                 if (compact_result == COMPACT_DEFERRED)
>                         goto nopage;
> 
> is true now. I assume this is what we want though.

No, we actually want to try to reclaim, that's why COMPACT_SKIPPED is
more appropriate. COMPACT_SKIPPED is even correct semantically because
the compaction wasn't invoked.

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

  reply	other threads:[~2016-05-11 16:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-11 13:24 Arnd Bergmann
2016-05-11 14:44 ` Michal Hocko
2016-05-11 14:52   ` Arnd Bergmann
2016-05-11 16:13     ` Michal Hocko [this message]
2016-05-11 14:53   ` Michal Hocko
2016-05-12  6:16 ` Michal Hocko
2016-05-12 12:00   ` Vlastimil Babka
2016-05-12 12:04   ` 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=20160511161318.GA24901@dhcp22.suse.cz \
    --to=mhocko@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=hannes@cmpxchg.org \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=izumi.taku@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=rientjes@google.com \
    --cc=vbabka@suse.cz \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox