Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6930760imu; Wed, 14 Nov 2018 09:05:33 -0800 (PST) X-Google-Smtp-Source: AJdET5ck+U5dcWhH21zcWSR7RmiDM3nVNvms0nOY7ESy6P9VT4sg2Be4YpurFfbdUJv3/lTmfFIL X-Received: by 2002:a63:2744:: with SMTP id n65mr2449760pgn.65.1542215133866; Wed, 14 Nov 2018 09:05:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542215133; cv=none; d=google.com; s=arc-20160816; b=NObPa8zClojMemP8+lg8+fbpYL12D7+n7iOBGA0nAoC0Oh2fFf2yn9ouZQlVeA4XlB cjPOBETyLlaWc90VaM531yJcKN88IPCEAxDX5464JsjQU9+wKALnLppGDrlKjuqjYdbx QJMNTAGnDKsaweTzIwppWuq+IOdEBhY8sxX+Hx4UVIGzVYU2wsscGAuMMq1iERH1ymB8 RehekofmB6BScYh0D4lsQQWKIE52cP6SzhtxU4xqg2XmEI4YTcFkqj1KFUHu89n5Dncb ZftSFs16EoHomF8BKj5XrvJ0Z7HQW8v+KNHf56q9brtNR7dyAFAoKyBG7xwblZPKAexg Wd8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=3nBzECE3h/jS7hw347ZGjMmyWVeEmTUaAC7Az9WowIU=; b=i74aOzQoopA6/MN3cJMXWDdw5vDAjR7gN7Nev9KS0+PPTf9tuJ0PgFsht6SU+tSnW1 j+m6vY5fRh51c1V4nDcHBYjXy9Z5bZnR8QUX6fiH9MUvZW6/GGXxi4Sh/gGoA9UQZfKf c3WHzQgo0V3OA+vmsjmgh3qYGNG6pMa4uTSNrDK3BfyaJzm3jvste8Wx+iYb5Z28FVC/ Bg4z0JI2GTC/HVnoW6v8i8/kgfYRQlH3mPiYpE9b8FfHLlSM56w8P2b1TU63KbMczoPy lTJWXb4WUKfFuPKNluGQs6S+RCNMIFYJadN4EzUr8Z4nitj0F/ssJxd52jl10Joyxk3q 903Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g18-v6si25974391pfb.278.2018.11.14.09.05.00; Wed, 14 Nov 2018 09:05:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732527AbeKODHX (ORCPT + 99 others); Wed, 14 Nov 2018 22:07:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:31553 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725759AbeKODHX (ORCPT ); Wed, 14 Nov 2018 22:07:23 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1270A315487B; Wed, 14 Nov 2018 17:03:23 +0000 (UTC) Received: from thinkpad.redhat.com (ovpn-204-52.brq.redhat.com [10.40.204.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id EBB9160BF6; Wed, 14 Nov 2018 17:03:20 +0000 (UTC) From: Laurent Vivier To: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, Satheesh Rajendran , Michael Bringmann , Nathan Fontenot , linux-kernel@vger.kernel.org, Laurent Vivier Subject: [PATCH] powerpc/numa: fix hot-added CPU on memory-less node Date: Wed, 14 Nov 2018 18:03:19 +0100 Message-Id: <20181114170319.24828-1-lvivier@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 14 Nov 2018 17:03:23 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Trying to hotplug a CPU on an empty NUMA node (without memory or CPU) crashes the kernel when the CPU is onlined. During the onlining process, the kernel calls start_secondary() that ends by calling set_numa_mem(local_memory_node(numa_cpu_lookup_table[cpu])) that relies on NODE_DATA(nid)->node_zonelists and in our case NODE_DATA(nid) is NULL. To fix that, add the same checking as we already have in find_and_online_cpu_nid(): if NODE_DATA() is NULL, use the first online node. Bug: https://github.com/linuxppc/linux/issues/184 Fixes: ea05ba7c559c8e5a5946c3a94a2a266e9a6680a6 (powerpc/numa: Ensure nodes initialized for hotplug) Signed-off-by: Laurent Vivier --- arch/powerpc/mm/numa.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c index 3a048e98a132..1b2d25a3c984 100644 --- a/arch/powerpc/mm/numa.c +++ b/arch/powerpc/mm/numa.c @@ -483,6 +483,15 @@ static int numa_setup_cpu(unsigned long lcpu) if (nid < 0 || !node_possible(nid)) nid = first_online_node; + if (NODE_DATA(nid) == NULL) { + /* + * Default to using the nearest node that has memory installed. + * Otherwise, it would be necessary to patch the kernel MM code + * to deal with more memoryless-node error conditions. + */ + nid = first_online_node; + } + map_cpu_to_node(lcpu, nid); of_node_put(cpu); out: -- 2.17.2