Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp19899imu; Wed, 21 Nov 2018 14:36:35 -0800 (PST) X-Google-Smtp-Source: AJdET5f9oqEhn+1eQ7K95v3vwI0OK4+ZqQFUuWblUx8kqUF/GsBYAVjWg3tkX/vnLUZOVhJr4lSQ X-Received: by 2002:a62:25c2:: with SMTP id l185-v6mr9058324pfl.64.1542839795550; Wed, 21 Nov 2018 14:36:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542839795; cv=none; d=google.com; s=arc-20160816; b=kttfgeml3v/1rzMP+1aQ8INd3ShixjUReQ7QTQAsfdr+fUmqyihaXP4wJS60xouazW tc8fe7UF21R2QCuuqvU+WvSbtpKp4V3WOAG5bo+mdCGLeWvJQuGkmx8zL+5oYD2vwRFv IpkfqhCMmqxWgG7+7ZPD2OLndkxMYof/NDvTXUsUdExuomHbYDAWuJJuyEC+ykyUKEnY 1zopC5KYb1fnXIsISDxeZ/iXJD4ZjvKX5v2/BRRPE6xfzLnKo4UMFYWHQjoQcx3e3Yjv clvu+WH71hliDaxXz6kgutMlncSWAmxMGDFGbDfdUEh8/RI7SynKUfXy4I4LrGcjNpwb oh5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject; bh=O9ijWp8fhZwHt6OhdxzpHvyIxZ+dE2t8GxZZK8Ni+Pg=; b=llOt5WjduhEyHlri39zqQcMWd51ziWhFv0xq2e0aAi/YeRE/xpP1FoTe4SH+muwNvP +drMjLOTwICc2FPtFOijsh/MRg8NW+098Ndh2ZUgVONpl10bzcferO+JFE2EfMFr52YB yl1zaYtZLFXRhYZQr75Yq2FSB8+f3LAKsOhoVaHita6xZpaqVfyOz9aiiXiswZLgFeUC nb/4SR1k0G/eOoeYpOi+nXaToU79u9zEF8FiB8CpQSE0dGERqVFlmzruzMyi2wUutDbi a/iIkV2dTup8cVwLQntpwjHhdxDeGsDWr/Ip7pEHXMkv4hT/8J4WMo8odKuyo9k+UbUX yOSA== 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 f14si35516984pln.289.2018.11.21.14.36.20; Wed, 21 Nov 2018 14:36:35 -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 S2387594AbeKVFmZ (ORCPT + 99 others); Thu, 22 Nov 2018 00:42:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38096 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730172AbeKVFmY (ORCPT ); Thu, 22 Nov 2018 00:42:24 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 85C4630DDBA1; Wed, 21 Nov 2018 19:06:51 +0000 (UTC) Received: from [10.40.204.241] (ovpn-204-241.brq.redhat.com [10.40.204.241]) by smtp.corp.redhat.com (Postfix) with ESMTP id 185794530; Wed, 21 Nov 2018 19:06:48 +0000 (UTC) Subject: Re: [PATCH] powerpc/numa: fix hot-added CPU on memory-less node To: Satheesh Rajendran , Michael Bringmann Cc: Michael Ellerman , Satheesh Rajendran , linux-kernel@vger.kernel.org, Nathan Fontenot , linuxppc-dev@lists.ozlabs.org References: <20181114170319.24828-1-lvivier@redhat.com> <20181115091948.GA14462@dhcp-9-193-110-205.in.ibm.com> From: Laurent Vivier Openpgp: preference=signencrypt Autocrypt: addr=lvivier@redhat.com; prefer-encrypt=mutual; keydata= xsFNBFYFJhkBEAC2me7w2+RizYOKZM+vZCx69GTewOwqzHrrHSG07MUAxJ6AY29/+HYf6EY2 WoeuLWDmXE7A3oJoIsRecD6BXHTb0OYS20lS608anr3B0xn5g0BX7es9Mw+hV/pL+63EOCVm SUVTEQwbGQN62guOKnJJJfphbbv82glIC/Ei4Ky8BwZkUuXd7d5NFJKC9/GDrbWdj75cDNQx UZ9XXbXEKY9MHX83Uy7JFoiFDMOVHn55HnncflUncO0zDzY7CxFeQFwYRbsCXOUL9yBtqLer Ky8/yjBskIlNrp0uQSt9LMoMsdSjYLYhvk1StsNPg74+s4u0Q6z45+l8RAsgLw5OLtTa+ePM JyS7OIGNYxAX6eZk1+91a6tnqfyPcMbduxyBaYXn94HUG162BeuyBkbNoIDkB7pCByed1A7q q9/FbuTDwgVGVLYthYSfTtN0Y60OgNkWCMtFwKxRaXt1WFA5ceqinN/XkgA+vf2Ch72zBkJL RBIhfOPFv5f2Hkkj0MvsUXpOWaOjatiu0fpPo6Hw14UEpywke1zN4NKubApQOlNKZZC4hu6/ 8pv2t4HRi7s0K88jQYBRPObjrN5+owtI51xMaYzvPitHQ2053LmgsOdN9EKOqZeHAYG2SmRW LOxYWKX14YkZI5j/TXfKlTpwSMvXho+efN4kgFvFmP6WT+tPnwARAQABzSNMYXVyZW50IFZp dmllciA8bHZpdmllckByZWRoYXQuY29tPsLBeAQTAQIAIgUCVgVQgAIbAwYLCQgHAwIGFQgC CQoLBBYCAwECHgECF4AACgkQ8ww4vT8vvjwpgg//fSGy0Rs/t8cPFuzoY1cex4limJQfRe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Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <20181115091948.GA14462@dhcp-9-193-110-205.in.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 21 Nov 2018 19:06:51 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 15/11/2018 10:19, Satheesh Rajendran wrote: > On Wed, Nov 14, 2018 at 06:03:19PM +0100, Laurent Vivier wrote: >> 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(+) > > This patch causes regression for cold plug numa case(Case 1) and > hotplug case + reboot(Case 2) with adding all vcpus into node 0. > > > Env: HW: Power8 Host. > Kernel: 4.20-rc2 + this patch > > Case 1: > 1. boot a guest with 8 vcpus(all available), spreadout in 4 numa nodes. > 8 > ... > > > > > > > > 2. Check lscpu --- all vcpus are added to node0 --> NOK > > # lscpu > Architecture: ppc64le > Byte Order: Little Endian > CPU(s): 8 > On-line CPU(s) list: 0-7 > Thread(s) per core: 1 > Core(s) per socket: 8 > Socket(s): 1 > NUMA node(s): 4 > Model: 2.1 (pvr 004b 0201) > Model name: POWER8 (architected), altivec supported > Hypervisor vendor: KVM > Virtualization type: para > L1d cache: 64K > L1i cache: 32K > NUMA node0 CPU(s): 0-7 > NUMA node1 CPU(s): > NUMA node2 CPU(s): > NUMA node3 CPU(s): > > without this patch it was working fine. > # lscpu > Architecture: ppc64le > Byte Order: Little Endian > CPU(s): 8 > On-line CPU(s) list: 0-7 > Thread(s) per core: 1 > Core(s) per socket: 8 > Socket(s): 1 > NUMA node(s): 4 > Model: 2.1 (pvr 004b 0201) > Model name: POWER8 (architected), altivec supported > Hypervisor vendor: KVM > Virtualization type: para > L1d cache: 64K > L1i cache: 32K > NUMA node0 CPU(s): 0,1 > NUMA node1 CPU(s): 2,3 > NUMA node2 CPU(s): 4,5 > NUMA node3 CPU(s): 6,7 > > > Case 2: > 1. boot a guest with 8 vcpus(2 available, 6 possible), spreadout in 4 numa nodes. > 8 > ... > > > > > > > > 2. Hotplug all vcpus > # lscpu > Architecture: ppc64le > Byte Order: Little Endian > CPU(s): 8 > On-line CPU(s) list: 0-7 > Thread(s) per core: 1 > Core(s) per socket: 8 > Socket(s): 1 > NUMA node(s): 2 > Model: 2.1 (pvr 004b 0201) > Model name: POWER8 (architected), altivec supported > Hypervisor vendor: KVM > Virtualization type: para > L1d cache: 64K > L1i cache: 32K > NUMA node0 CPU(s): 0,1,4-7 > NUMA node1 CPU(s): 2,3 > > > 3. reboot the guest > # lscpu > Architecture: ppc64le > Byte Order: Little Endian > CPU(s): 8 > On-line CPU(s) list: 0-7 > Thread(s) per core: 1 > Core(s) per socket: 8 > Socket(s): 1 > NUMA node(s): 4 > Model: 2.1 (pvr 004b 0201) > Model name: POWER8 (architected), altivec supported > Hypervisor vendor: KVM > Virtualization type: para > L1d cache: 64K > L1i cache: 32K > NUMA node0 CPU(s): 0-7 > NUMA node1 CPU(s): > NUMA node2 CPU(s): > NUMA node3 CPU(s): > > > Without this patch, Case 2 crashes the guest during hotplug, i.e > issue reported in https://github.com/linuxppc/linux/issues/184 > > Regards, > -Satheesh. > >> >> 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 >> > I have worked a while on this problem, and I don't see any easy fix for that. It seems kernel is not ready to online a memory-less/cpu-less node when someone hotplug a CPU in it. I think we have to fix several areas to be able to do that. Perhaps someone from IBM could have a better view on what we need? Michael? Nathan? Thanks, Laurent