Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7789486imu; Thu, 15 Nov 2018 01:20:57 -0800 (PST) X-Google-Smtp-Source: AJdET5fyI+x5f4NL7gT/THXWYiku0tLFYGokPR1GOSKasnANj8QwGhuIAE2O3h9ylIsgBW41kHcH X-Received: by 2002:a17:902:f24:: with SMTP id 33-v6mr5650479ply.228.1542273657325; Thu, 15 Nov 2018 01:20:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542273657; cv=none; d=google.com; s=arc-20160816; b=gx+kby16dEOoOsquL0v/4MI5K5sxOdgzXXI8bbESqi7oM5I62S6FhuLe0MuXk6WqEz k+8UIzNOiGEBceAWxal2ZP/+TMGcHxXItaAtX1YjMVP2Ug7POXnH2j2Asbt2+C+s49Ou XExUkFspGecTv4vMx9Nok054p+i4lPdAUiEJaZe2w0e8atPhC8t2ORspd/S4osrK4kBM zy0qCUrRnoXAG83MDRUT1I1+OZivN5ryqgezUcRx75QiQx/c0dNMLZMogf37vug3dt6i R0RK+jVRNVlaB52wXoGbdk9EG5VpDe2MRhrFCPFRtaZTvbkiyQ6k4w/gQdb+fASPDgwP kFdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:subject:cc:to :from:date; bh=+Xp7U16qtUDXv7xFApgtiPhpHLWC/3jUV1jOGkP4OFw=; b=hD/4iujbQ6u2IAqRBJt2uoqRtC18pCmpDYREL1wkNisMRH/GcNagkWY/acjTtBXJPz lT0cMhboKMKDbVlUX6diBAdSZam8ItEec0I+4zE+BfvUgdvZc29CnQBguegQv06+mDzL aEnRPDC4gRMBxm1JRDm+OI5EWg4iOyO3sz9UmKLJqvo6ufp8i9d5reqzpsGE51p/w6+1 fHgoTQYReENPInWuTBvOMWii2HRWpdkSN++JeFkOzfIHnwgHjLLjfLrLh8/YStbtgrw6 2iPYmlWwx8RATKHDHV/1leoYu37GEjay5zwGSn4T9cEphYU/rbM+hhgyT2j7bxfE3U9+ RVQg== 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=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y191si25519277pgd.4.2018.11.15.01.20.42; Thu, 15 Nov 2018 01:20:57 -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=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729114AbeKOT1B (ORCPT + 99 others); Thu, 15 Nov 2018 14:27:01 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:37588 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728719AbeKOT1B (ORCPT ); Thu, 15 Nov 2018 14:27:01 -0500 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wAF9JHT5078351 for ; Thu, 15 Nov 2018 04:20:01 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0b-001b2d01.pphosted.com with ESMTP id 2ns2yq865r-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 15 Nov 2018 04:20:01 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 15 Nov 2018 09:20:00 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 15 Nov 2018 09:19:57 -0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wAF9JuoI52035660 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 15 Nov 2018 09:19:56 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4FF88A405C; Thu, 15 Nov 2018 09:19:56 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D67A7A405B; Thu, 15 Nov 2018 09:19:54 +0000 (GMT) Received: from dhcp-9-193-110-205.in.ibm.com (unknown [9.122.211.233]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Thu, 15 Nov 2018 09:19:54 +0000 (GMT) Date: Thu, 15 Nov 2018 14:49:48 +0530 From: Satheesh Rajendran To: Laurent Vivier Cc: Michael Ellerman , Satheesh Rajendran , linux-kernel@vger.kernel.org, Michael Bringmann , Nathan Fontenot , linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH] powerpc/numa: fix hot-added CPU on memory-less node Reply-To: Satheesh Rajendran References: <20181114170319.24828-1-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181114170319.24828-1-lvivier@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-TM-AS-GCONF: 00 x-cbid: 18111509-0028-0000-0000-0000031A403E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18111509-0029-0000-0000-000023D6AFBE Message-Id: <20181115091948.GA14462@dhcp-9-193-110-205.in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-11-15_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811150085 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >