From patchwork Thu Jul 30 16:34:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 502206 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 068BB1402D1 for ; Fri, 31 Jul 2015 02:36:08 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id C30031A1A5A for ; Fri, 31 Jul 2015 02:36:07 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id D1A7F1A076F; Fri, 31 Jul 2015 02:35:00 +1000 (AEST) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id BE1DBAC25; Thu, 30 Jul 2015 16:34:52 +0000 (UTC) From: Vlastimil Babka To: linux-mm@kvack.org, Andrew Morton Subject: [PATCH v3 2/3] mm: unify checks in alloc_pages_node() and __alloc_pages_node() Date: Thu, 30 Jul 2015 18:34:30 +0200 Message-Id: <1438274071-22551-2-git-send-email-vbabka@suse.cz> X-Mailer: git-send-email 2.4.6 In-Reply-To: <1438274071-22551-1-git-send-email-vbabka@suse.cz> References: <1438274071-22551-1-git-send-email-vbabka@suse.cz> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: cbe-oss-dev@lists.ozlabs.org, linux-ia64@vger.kernel.org, Naoya Horiguchi , kvm@vger.kernel.org, Johannes Weiner , linux-kernel@vger.kernel.org, Pekka Enberg , "Aneesh Kumar K.V" , David Rientjes , Greg Thelen , Christoph Lameter , linuxppc-dev@lists.ozlabs.org, Joonsoo Kim , Vlastimil Babka , Mel Gorman MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Perform the same debug checks in alloc_pages_node() as are done in __alloc_pages_node(), by making the former function a wrapper of the latter one. In addition to better diagnostics in DEBUG_VM builds for situations which have been already fatal (e.g. out-of-bounds node id), there are two visible changes for potential existing buggy callers of alloc_pages_node(): - calling alloc_pages_node() with any negative nid (e.g. due to arithmetic overflow) was treated as passing NUMA_NO_NODE and fallback to local node was applied. This will now be fatal. - calling alloc_pages_node() with an offline node will now be checked for DEBUG_VM builds. Since it's not fatal if the node has been previously online, and this patch may expose some existing buggy callers, change the VM_BUG_ON in __alloc_pages_node() to VM_WARN_ON. Signed-off-by: Vlastimil Babka Acked-by: David Rientjes Acked-by: Johannes Weiner Acked-by: Christoph Lameter --- v3: I think this is enough for what patch 4/4 in v2 tried to provide on top, so there's no patch 4/4 anymore. The DEBUG_VM-only fixup didn't seem justified to me. include/linux/gfp.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/gfp.h b/include/linux/gfp.h index d2c142b..4a12cae2 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -310,23 +310,23 @@ __alloc_pages(gfp_t gfp_mask, unsigned int order, static inline struct page * __alloc_pages_node(int nid, gfp_t gfp_mask, unsigned int order) { - VM_BUG_ON(nid < 0 || nid >= MAX_NUMNODES || !node_online(nid)); + VM_BUG_ON(nid < 0 || nid >= MAX_NUMNODES); + VM_WARN_ON(!node_online(nid)); return __alloc_pages(gfp_mask, order, node_zonelist(nid, gfp_mask)); } /* * Allocate pages, preferring the node given as nid. When nid == NUMA_NO_NODE, - * prefer the current CPU's node. + * prefer the current CPU's node. Otherwise node must be valid and online. */ static inline struct page *alloc_pages_node(int nid, gfp_t gfp_mask, unsigned int order) { - /* Unknown node is current node */ - if (nid < 0) + if (nid == NUMA_NO_NODE) nid = numa_node_id(); - return __alloc_pages(gfp_mask, order, node_zonelist(nid, gfp_mask)); + return __alloc_pages_node(nid, gfp_mask, order); } #ifdef CONFIG_NUMA