From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751027AbdAWMS1 (ORCPT ); Mon, 23 Jan 2017 07:18:27 -0500 Received: from mout.kundenserver.de ([212.227.17.24]:55177 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750703AbdAWMSZ (ORCPT ); Mon, 23 Jan 2017 07:18:25 -0500 From: Arnd Bergmann To: Andrew Morton Cc: Arnd Bergmann , Vlastimil Babka , Mel Gorman , Michal Hocko , Johannes Weiner , Joonsoo Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm: ensure alloc_flags in slow path are initialized Date: Mon, 23 Jan 2017 13:16:12 +0100 Message-Id: <20170123121649.3180300-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:sk4KcdRqJb/+88kor1IGGXnFyDEAiT96887p93clj623nNBHz3h sgVPdhDHSXqumLs4osvDBNSsD4fdcVQw/EJ/tdE/eMFJl29hVfgHvncEaIDqU9c7UXum+gA /9XdvvOwySx5MKAU+/WMaSYv26F+u8gOiK3s8Q314Muf1eLmubuOPag8hG0h4HVZdYal8ob flAPhhB4q225LXABa76kA== X-UI-Out-Filterresults: notjunk:1;V01:K0:oC9Zk0DQgyk=:Kq0ULZFiniJiR1RajPs7HV wwGYhCYgA5qh2nVKW7ks7ew2t9Mz+KlAgtl6WXwPGNby5Crz8/dkKYl3jPuR4fg68hh/mY3Nb VaEwUz4Yaw/QMB6m+VOVKVNKFRgztBoWABe1lV3b9mmwyEzjxirbWHAXdN+M/NhbNDaLBJD1c 6RCmicXVfOXtQUWeDY6NYphrWeQ3++LfGtD8GFIPPozHc/fI0hyhpeP2vF2f8ix6iG/jlQCa9 CIrKyXZOY288Rwn+JL4sV1oi8TkqNT6GGPB4CnvwhhATnF4SF6FHpTeG4Q0GDHPvTwWkn0vaX e7/XWAl+Q/bvvifKmGVy82NMQ7CsPcqSnjUYwNSwV4sYRA+lek82PjKnWG0FsuujrLCvAF7IG 0J9FYbZl3kpJMxyTK5c6BJtuRt2TtASQkmT7KmdZ3PiD9qbk6rYwiVnIY64f2r/flslJsSq0T lMjYYeZOQ12G6uxSpNkLDu+GhA1n8P8ucFoXTBOQBvzKrh7o14cm7nZztr3CRZW2wqW3kQNP5 RSDxMjSLyFOrHeGO36ls7nyg2IrJ9chx54K73+fz2tOyVifCDAEczyXxC/+mZ6tmbE9DIfeA7 afUBbpONNqjvwMp2sXykCqsqOyZaP7tZ463p92y8rzFdWzv7y+iXN4ix68yObjW3OrfDROAN8 /eTXFj3Ndf+ncka02qZjjk708ZXRgiLkXxflVD5O0oXtzzWv8xJAEYUIzx0jG8tAa8f4= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The __alloc_pages_slowpath() has gotten rather complex and gcc is no longer able to follow the gotos and prove that the alloc_flags variable is initialized at the time it is used: mm/page_alloc.c: In function '__alloc_pages_slowpath': mm/page_alloc.c:3565:15: error: 'alloc_flags' may be used uninitialized in this function [-Werror=maybe-uninitialized] To be honest, I can't figure that out either, maybe it is or maybe not, but moving the existing initialization up a little higher looks safe and makes it obvious to both me and gcc that the initialization comes before the first use. Fixes: 74eaa4a97e8e ("mm: consolidate GFP_NOFAIL checks in the allocator slowpath") Signed-off-by: Arnd Bergmann --- mm/page_alloc.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index cf641932c015..d9fa4564524f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3591,6 +3591,13 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, (__GFP_ATOMIC|__GFP_DIRECT_RECLAIM))) gfp_mask &= ~__GFP_ATOMIC; + /* + * The fast path uses conservative alloc_flags to succeed only until + * kswapd needs to be woken up, and to avoid the cost of setting up + * alloc_flags precisely. So we do that now. + */ + alloc_flags = gfp_to_alloc_flags(gfp_mask); + retry_cpuset: compaction_retries = 0; no_progress_loops = 0; @@ -3607,14 +3614,6 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, if (!ac->preferred_zoneref->zone) goto nopage; - - /* - * The fast path uses conservative alloc_flags to succeed only until - * kswapd needs to be woken up, and to avoid the cost of setting up - * alloc_flags precisely. So we do that now. - */ - alloc_flags = gfp_to_alloc_flags(gfp_mask); - if (gfp_mask & __GFP_KSWAPD_RECLAIM) wake_all_kswapds(order, ac); -- 2.9.0