From patchwork Tue Oct 25 21:31:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Daney X-Patchwork-Id: 9395565 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 79DE460235 for ; Tue, 25 Oct 2016 21:33:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 566E329751 for ; Tue, 25 Oct 2016 21:33:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B34F29777; Tue, 25 Oct 2016 21:33:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D0AE529751 for ; Tue, 25 Oct 2016 21:33:26 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bz9KE-0003DX-7v; Tue, 25 Oct 2016 21:32:02 +0000 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bz9Jj-00032w-8Y for linux-arm-kernel@lists.infradead.org; Tue, 25 Oct 2016 21:31:36 +0000 Received: by mail-pf0-x242.google.com with SMTP id s8so20612602pfj.2 for ; Tue, 25 Oct 2016 14:31:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=q45MZh6RRCG7SJTP3/6quk6sqHAPArZaY6iBwJCYt9U=; b=ADWCY7kextqjpRxT7tnb7qryz9h5aXW45iRjh+5w8uOsirelS3Xd8YvILWwGgKcmme lEtDTVUR2hZpkNxq1tteLSWVK4AY/QktSzZyKlDO2S8aYFBcr5rluayVOlrD1S+MBYDQ q+msdiDHD0CEIdFE7xKIVZkxTIRzF1LDLQxZvwDSqpxjNTv4lMxGqpkRUzv+7mU9nMwU MFZGCKiXLf9IGKiomKwy6JKoz0RjyaI2LKaZB9GH4m1QC+jxbYEwowxhj+3CMoObDtbQ M+Yld7VL//7Rt/3m2CVBgXQxz8PZfqIKov4Z69P4y/Y1TQvAIc7wf5Il31q6SMZ0lWJG A6gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=q45MZh6RRCG7SJTP3/6quk6sqHAPArZaY6iBwJCYt9U=; b=gsrgYail968RfmS3BzCe8B3ajlt/yAv1uZ0281eUXvrsBXo+k6JbbLlKLR1gCMx69T jwYklJkRrdlaF0wo3k6DxpiJLN65VEvQiPycKP27AjnXq5S+0k4opF13geLvlP6/FLZK 7ULrf/sa/LX/yyQNCFeos04Vq1x9zPnzYDQSBozx/UklUSiB3Vf+WwhPBCpmCrE7+fNY iP/nD5Du4rKO/U3r7CR3t8YOXAtHJPyehdX9jpIwtvI6L7K/GMdUjyDIKC3X2n3puVKX YRE8qM234uPV1thLa45LWIfOkGxJgPaXkXZeiiPFiaVOvx7bzvkiMXAdw6Gp9eIlSTXp zkpA== X-Gm-Message-State: ABUngvdAw4nVnwidv4Meh7ID+nEAvZr69n5hg9XjEdlUq+ejIOcQ7icBhtFjpQvwHEKbMw== X-Received: by 10.98.74.147 with SMTP id c19mr42772632pfj.16.1477431070355; Tue, 25 Oct 2016 14:31:10 -0700 (PDT) Received: from dl.caveonetworks.com (50-233-148-156-static.hfc.comcastbusiness.net. [50.233.148.156]) by smtp.gmail.com with ESMTPSA id d89sm35584740pfe.32.2016.10.25.14.31.08 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 25 Oct 2016 14:31:09 -0700 (PDT) Received: from dl.caveonetworks.com (localhost.localdomain [127.0.0.1]) by dl.caveonetworks.com (8.14.5/8.14.5) with ESMTP id u9PLV74U007297; Tue, 25 Oct 2016 14:31:07 -0700 Received: (from ddaney@localhost) by dl.caveonetworks.com (8.14.5/8.14.5/Submit) id u9PLV74U007296; Tue, 25 Oct 2016 14:31:07 -0700 From: David Daney To: linux-kernel@vger.kernel.org, Rob Herring , Frank Rowand , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Will Deacon , Catalin Marinas Subject: [PATCH 1/2] of, numa: Add function to disable of_node_to_nid(). Date: Tue, 25 Oct 2016 14:31:00 -0700 Message-Id: <1477431061-7258-2-git-send-email-ddaney.cavm@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1477431061-7258-1-git-send-email-ddaney.cavm@gmail.com> References: <1477431061-7258-1-git-send-email-ddaney.cavm@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161025_143131_422785_B345FC46 X-CRM114-Status: GOOD ( 15.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Daney , Ganapatrao Kulkarni , Robert Richter , Hanjun Guo , Gilbert Netzer MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: David Daney On arm64 NUMA kernels we can pass "numa=off" on the command line to disable NUMA. A side effect of this is that kmalloc_node() calls to non-zero nodes will crash the system with an OOPS: [ 0.000000] [] __alloc_pages_nodemask+0xa4/0xe68 [ 0.000000] [] new_slab+0xd0/0x57c [ 0.000000] [] ___slab_alloc+0x2e4/0x514 [ 0.000000] [] __slab_alloc+0x48/0x58 [ 0.000000] [] __kmalloc_node+0xd0/0x2e0 [ 0.000000] [] __irq_domain_add+0x7c/0x164 [ 0.000000] [] its_probe+0x784/0x81c [ 0.000000] [] its_init+0x48/0x1b0 . . . This is caused by code like this in kernel/irq/irqdomain.c domain = kzalloc_node(sizeof(*domain) + (sizeof(unsigned int) * size), GFP_KERNEL, of_node_to_nid(of_node)); When NUMA is disabled, the concept of a node is really undefined, so of_node_to_nid() should unconditionally return NUMA_NO_NODE. Add __of_force_no_numa() to allow of_node_to_nid() to be forced to return NUMA_NO_NODE. The follow on patch will call this new function from the arm64 numa code. Reported-by: Gilbert Netzer Signed-off-by: David Daney --- drivers/of/of_numa.c | 15 +++++++++++++++ include/linux/of.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/drivers/of/of_numa.c b/drivers/of/of_numa.c index f63d4b0d..2212299 100644 --- a/drivers/of/of_numa.c +++ b/drivers/of/of_numa.c @@ -150,12 +150,27 @@ static int __init of_numa_parse_distance_map(void) return ret; } +static bool of_force_no_numa; + +void __of_force_no_numa(void) +{ + of_force_no_numa = true; +} + int of_node_to_nid(struct device_node *device) { struct device_node *np; u32 nid; int r = -ENODATA; + /* + * If NUMA forced off, nodes are meaningless. Return + * NUMA_NO_NODE so that any node specific memory allocations + * can succeed from the default pool. + */ + if (of_force_no_numa) + return NUMA_NO_NODE; + np = of_node_get(device); while (np) { diff --git a/include/linux/of.h b/include/linux/of.h index 299aeb1..6f6244e 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -850,11 +850,13 @@ static inline void of_property_clear_flag(struct property *p, unsigned long flag #if defined(CONFIG_OF) && defined(CONFIG_NUMA) extern int of_node_to_nid(struct device_node *np); +extern void __of_force_no_numa(void); #else static inline int of_node_to_nid(struct device_node *device) { return NUMA_NO_NODE; } +static inline void __of_force_no_numa(void) { /* Empty */ } #endif #ifdef CONFIG_OF_NUMA