From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752488AbcEKOxL (ORCPT ); Wed, 11 May 2016 10:53:11 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:61027 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751400AbcEKOxJ (ORCPT ); Wed, 11 May 2016 10:53:09 -0400 From: Arnd Bergmann To: Michal Hocko Cc: Andrew Morton , Mel Gorman , Vlastimil Babka , David Rientjes , Joonsoo Kim , Taku Izumi , Johannes Weiner , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm, compaction: avoid uninitialized variable use Date: Wed, 11 May 2016 16:52:41 +0200 Message-ID: <2695751.e2s15gCWav@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <20160511144407.GA21503@dhcp22.suse.cz> References: <1462973126-1183468-1-git-send-email-arnd@arndb.de> <20160511144407.GA21503@dhcp22.suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:r5txUIo3kVMNHkWlKarRLPmJEhmt7b1T+BPN2YMWksrGi9rIuB3 q6Syf93BcKl8GblEpzx3YyasNgqSdvELGJNDBJL+C1GHrxoifug3HbIGdCVLEy2ErXuGAbf c59HoG89SMNHV6mpGkdVE+k4+YR+itqrFVCMeduw3TDWJ8EFFrcXEuWUxy0ECnE0ZGaSHzV jH2IkEMO6Ly8LUhHOVqww== X-UI-Out-Filterresults: notjunk:1;V01:K0:hnwWMQO96Y8=:AIH5W7bQH4MHSs5pIL22Ub l3TGVraQqNYMLd4k4ifAqYxahZKOpGN8jfhLowkJS+vsr4Jc3pv2BJu8t/I9Rypi/fjTYFmjp 6Tlfhg2sIigtqKcxxG22iKJsamaUWdp/DXUcHblLMA639hYpqVbOjLyYid1O2Hiq6rsLtSqx9 U7NiBgmo3CO8YHQxB/GDm83ZDN2Q7mJcddQSZWnwJ9l3Wn/EIaQCMB6ms0jV933PXC9B46wyI fTIq6oh7bxzh2KwHDYgjbqK3i4ulI//v6+lYcA0rxQjt/gLCuDvnydE8SNYDqSvZKGtA/7OPa uIo57vDed++ClhpSRQFNpoUiITa93kDcUiAi9dkay4aSjQ1iQJ/3vYbsAKj2biqAxMeo3SEPO /kGRedL8+JaOhGwHPnhKeCyoF9UNtrszA1h3OfHS1IXwJhfyGt/ov/doapo6XYB1Hb1c/tmBj SYolErtwdgU+z7T62AboF6amXfqcmxpj81nrxLYB7kd9GahLcjiF+quhVopXYqUlD6GajLqBE Cha1bIEmXG062qLfC4qStaYeb9k3wQkkz/UbEgespQPKfhbksoiS4GR38EFg4GFawB189NKUy GXbL+DDLYPqi7kydDwJdda4TvsrVnStS1yDYJGeYWJgYEqyydMSos1FC5+tLb6W3rh//pU6+O 7AqixPhjLTOtZTufsdNqsCbYHrMsAs4rAR1GlWHVUsiY+DhYI0hSVYdghh5Knuw4I+j/5UCsl s2JEjAiFpM+m2s5c Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Arnd