Received: by 10.223.176.5 with SMTP id f5csp990848wra; Wed, 7 Feb 2018 10:45:14 -0800 (PST) X-Google-Smtp-Source: AH8x22425mXTY2m0myb1dg6K1wnWnNiCAZugicc/3C5gYluRajwiRji/B1s21+iT+ffW6xY5njIa X-Received: by 2002:a17:902:aa85:: with SMTP id d5-v6mr7180267plr.239.1518029113997; Wed, 07 Feb 2018 10:45:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518029113; cv=none; d=google.com; s=arc-20160816; b=C+zbxJRfu3uncIzGxPIPpEljHdcyRT9fr1yLo6Rs0mUJg8sOKbEH7DV0J5fKX7nA4w bELzPq+PdaFLUlJvEbPhs5g2eXqaIgG+dargr3mCMhYZ6KlxAav3XGO2UTJr30OAbTRc Y51UlGw2j9UvnJ1HN8qrnxJpUPM2xfQzaiO7QY83r27WQjHQI3s3cm9PR5wlmFuChnSD BTh8r4tzc619B38MyRHBXFGwnxmgEh1AO/W0Q9RDjKYuwYlIc872Lt84q7expenNAY7c 8m+vBa4p/lZM/49CrYj8hsi7oIhpU2v4Y+lpQM2d+Y054wTg+8hs/VHmlMJzwvxP2BWq e3lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:mime-version:date:message-id :from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=nT3bjualHhzHvTa2KW5/RIVatuiTH7wbHk3JX8rfgqU=; b=H1U8z4fl7z8qEi7P++HEFT9+AosLLDI1+ObUHKPT0xV48YV5Cuqeb35Zv/4xKi7gD8 zCnOTB+2GCX6z7wLPj+i/U5904Jgq/Y+9H2MPRmrbfDqCnIT745lEmIb0dn7aot8NOGq hJoOXi33igOMqByJVtJ5r0E62OjImVV0scmkxvCwDe7BS/Q9Mxcqt5/AhszJP4mdg2pS vGTP4mnpAiFFAPGV2zhqOFXPl4UvuB191FfuZBIp2cvUE3QQHjPjxbYJaZ7DswK4ZmNR 9HqrFgWzQOAk50yf0eFjBtu/pE2zLr8PErXTkJmaNri7NxFLC4a2Ys5eJgNQx8CPnYpd K6RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=D9bCirgN; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i6-v6si279233plt.26.2018.02.07.10.44.59; Wed, 07 Feb 2018 10:45:13 -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; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=D9bCirgN; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754312AbeBGSoT (ORCPT + 99 others); Wed, 7 Feb 2018 13:44:19 -0500 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:60123 "EHLO out2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753941AbeBGSoS (ORCPT ); Wed, 7 Feb 2018 13:44:18 -0500 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 0C22220E03; Wed, 7 Feb 2018 13:44:17 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute2.internal (MEProxy); Wed, 07 Feb 2018 13:44:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=nT3bjualHhzHvTa2KW5/RIVatuiTH 7wbHk3JX8rfgqU=; b=D9bCirgNb0ieCOMwErabQrjqa0orpq0QMHpySfbf+6BKQ oWvuNzLLsel7Fu5hMDnnl9vh3fgHZD9KkclcMmGQbPmp1dBABFcjR9UmYaHhdGCJ E1Z2MX1yfF64LPsTZjQNhmIv5rGlp08eessIy7CNlEkISrkRx/evd1tL+gPYVZ0N 9qH7ZbHm1ljBJyYcbMkJ8abfUlYKXA1yWoVn/ndD+z0LD8J7dnfGRaOfgwogJTIS epIH6NrTzG2m5Byp9XlXDhpfsCNap1fT8XVIhB73Nlt7mrfKXYNfYxNANspBaT+O qOCBdQz0+CGaSqefcUkWEyYGQznMP6T9Bc5FFFeTQ== X-ME-Sender: Received: from [127.0.0.1] (tor-exit-01.thehappy3.com [178.63.97.34]) by mail.messagingengine.com (Postfix) with ESMTPA id 0174924608; Wed, 7 Feb 2018 13:44:07 -0500 (EST) Subject: Re: [v6,3/3] x86/smpboot: Fix __max_logical_packages estimate To: Prarit Bhargava , xen-devel Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Peter Zijlstra , Andi Kleen , Dave Hansen , Piotr Luc , Kan Liang , Borislav Petkov , Stephane Eranian , Arvind Yadav , Andy Lutomirski , Christian Borntraeger , "Kirill A. Shutemov" , Tom Lendacky , He Chen , Mathias Krause , Tim Chen , Vitaly Kuznetsov References: <20171114124257.22013-4-prarit@redhat.com> From: Simon Gaiser Message-ID: <370a7ab2-8f57-b99b-428b-d0b1dfe401e7@invisiblethingslab.com> Date: Wed, 07 Feb 2018 18:44:00 +0000 MIME-Version: 1.0 In-Reply-To: <20171114124257.22013-4-prarit@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="3efb9065O8vkxnFZIODIk26KHXoub63ev" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --3efb9065O8vkxnFZIODIk26KHXoub63ev Content-Type: multipart/mixed; boundary="Q5yi0aR9gkpLjtYVgq4SInUEcIKZOmO7p"; protected-headers="v1" From: Simon Gaiser To: Prarit Bhargava , xen-devel Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Peter Zijlstra , Andi Kleen , Dave Hansen , Piotr Luc , Kan Liang , Borislav Petkov , Stephane Eranian , Arvind Yadav , Andy Lutomirski , Christian Borntraeger , "Kirill A. Shutemov" , Tom Lendacky , He Chen , Mathias Krause , Tim Chen , Vitaly Kuznetsov Message-ID: <370a7ab2-8f57-b99b-428b-d0b1dfe401e7@invisiblethingslab.com> Subject: Re: [v6,3/3] x86/smpboot: Fix __max_logical_packages estimate References: <20171114124257.22013-4-prarit@redhat.com> In-Reply-To: <20171114124257.22013-4-prarit@redhat.com> --Q5yi0aR9gkpLjtYVgq4SInUEcIKZOmO7p Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Prarit Bhargava: > A system booted with a small number of cores enabled per package > panics because the estimate of __max_logical_packages is too low. > This occurs when the total number of active cores across all packages > is less than the maximum core count for a single package. >=20 > ie) On a 4 package system with 20 cores/package where only 4 cores > are enabled on each package, the value of __max_logical_packages is > calculated as DIV_ROUND_UP(16 / 20) =3D 1 and not 4. >=20 > Calculate __max_logical_packages after the cpu enumeration has complete= d. > Use the boot cpu's data to extrapolate the number of packages. >=20 > Signed-off-by: Prarit Bhargava > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: "H. Peter Anvin" > Cc: x86@kernel.org > Cc: Peter Zijlstra > Cc: Andi Kleen > Cc: Dave Hansen > Cc: Piotr Luc > Cc: Kan Liang > Cc: Borislav Petkov > Cc: Stephane Eranian > Cc: Prarit Bhargava > Cc: Arvind Yadav > Cc: Andy Lutomirski > Cc: Christian Borntraeger > Cc: "Kirill A. Shutemov" > Cc: Tom Lendacky > Cc: He Chen > Cc: Mathias Krause > Cc: Tim Chen > Cc: Vitaly Kuznetsov > --- > arch/x86/kernel/smpboot.c | 55 +++++++++------------------------------= -------- > 1 file changed, 10 insertions(+), 45 deletions(-) >=20 > diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c > index 838d36ff7ba6..2e3c5a394e79 100644 > --- a/arch/x86/kernel/smpboot.c > +++ b/arch/x86/kernel/smpboot.c > @@ -308,12 +308,6 @@ int topology_update_package_map(unsigned int pkg, = unsigned int cpu) > if (new >=3D 0) > goto found; > =20 > - if (logical_packages >=3D __max_logical_packages) { > - pr_warn("Package %u of CPU %u exceeds BIOS package data %u.\n", > - logical_packages, cpu, __max_logical_packages); > - return -ENOSPC; > - } > - > new =3D logical_packages++; > if (new !=3D pkg) > pr_info("CPU %u Converting physical %u to logical package %u\n", > @@ -323,44 +317,6 @@ int topology_update_package_map(unsigned int pkg, = unsigned int cpu) > return 0; > } > =20 > -static void __init smp_init_package_map(struct cpuinfo_x86 *c, unsigne= d int cpu) > -{ > - unsigned int ncpus; > - > - /* > - * Today neither Intel nor AMD support heterogenous systems. That > - * might change in the future.... > - * > - * While ideally we'd want '* smp_num_siblings' in the below @ncpus > - * computation, this won't actually work since some Intel BIOSes > - * report inconsistent HT data when they disable HT. > - * > - * In particular, they reduce the APIC-IDs to only include the cores,= > - * but leave the CPUID topology to say there are (2) siblings. > - * This means we don't know how many threads there will be until > - * after the APIC enumeration. > - * > - * By not including this we'll sometimes over-estimate the number of > - * logical packages by the amount of !present siblings, but this is > - * still better than MAX_LOCAL_APIC. > - * > - * We use total_cpus not nr_cpu_ids because nr_cpu_ids can be limited= > - * on the command line leading to a similar issue as the HT disable > - * problem because the hyperthreads are usually enumerated after the > - * primary cores. > - */ > - ncpus =3D boot_cpu_data.x86_max_cores; > - if (!ncpus) { > - pr_warn("x86_max_cores =3D=3D zero !?!?"); > - ncpus =3D 1; > - } > - > - __max_logical_packages =3D DIV_ROUND_UP(total_cpus, ncpus); > - pr_info("Max logical packages: %u\n", __max_logical_packages); > - > - topology_update_package_map(c->phys_proc_id, cpu); > -} > - > void __init smp_store_boot_cpu_info(void) > { > int id =3D 0; /* CPU 0 */ > @@ -368,7 +324,7 @@ void __init smp_store_boot_cpu_info(void) > =20 > *c =3D boot_cpu_data; > c->cpu_index =3D id; > - smp_init_package_map(c, id); > + topology_update_package_map(c->phys_proc_id, id); > cpu_data(id).set =3D 1; > } > =20 > @@ -1371,7 +1327,16 @@ void __init native_smp_prepare_boot_cpu(void) > =20 > void __init native_smp_cpus_done(unsigned int max_cpus) > { > + int ncpus; > + > pr_debug("Boot done\n"); > + /* > + * Today neither Intel nor AMD support heterogenous systems so > + * extrapolate the boot cpu's data to all packages. > + */ > + ncpus =3D cpu_data(0).booted_cores * smp_num_siblings; > + __max_logical_packages =3D DIV_ROUND_UP(nr_cpu_ids, ncpus); > + pr_info("Max logical packages: %u\n", __max_logical_packages); > =20 > if (x86_has_numa_in_package) > set_sched_topology(x86_numa_in_package_topology); This breaks booting as Xen PV domain for me. The problem seems to be that native_smp_cpus_done() is never called on a PV domain. So __max_logical_packages is uninitialized and this leads to a NULL pointer dereference in coretemp. --Q5yi0aR9gkpLjtYVgq4SInUEcIKZOmO7p-- --3efb9065O8vkxnFZIODIk26KHXoub63ev Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE3E8ezGzG3N1CTQ//kO9xfO/xly8FAlp7SQsACgkQkO9xfO/x ly8X1xAAyHXliZBRV8Ef4BiAc/f0ELN87JCBJFzBphJp7A64yitWAljLQ0ijjulh O/FDF4aYEgWaG26KbkkNQ9iQb8TheTr4AXLU8HFKGksgfVUxiZamcBTJ/nz5MH/G MxBqC2RScuTvkTWfPO7D/CEN1ZGwE887S5Her2GglJglNi66LncqUihqOfQb9Bx/ WQmq4KvOisyPWZtSpXRD96BV5s7cv2gHCqdiB/nim0BE/+sDAWbzF6HcH+0aSuff 8wvGFExp4nG5ZpDRMKg1+w1N4GnSm0JCId8cs+F3YFahcoOhrApgWJIUfh/Skqnb rdT/M6BMuIH1YaC49hNuhpd2ZEYZNrcI/MMBhqXWVBhZVdRGRgld3Nwnz3YxAXJY DmYct1B3wzRkPxMwjgO8xwTsJzE5oLVUeuV0EvGS2uYBfQQUq6WhmjqTK7AsXhOX /t5h6Tu9FIGhunept+ZH2w4b3Z3T78fjaxOkIF5rMP7Lu2qeO9o2ETbEpWWl1ymV PC7ZMc8reo4K3H6htZHmy27j3d4gM4PfABUYaRprEzqAlQGnoUHL9Ppn81m2LQMt h7AJ7Zg+UZLNTSzogdsqZLFwQ6k1VeHzKkm0EAVgbhQBydLGDcHfn+v4/D0IMRav kt16O7iHmQN7FNUVvwB+FBqNzr3aWi1IWbSCHnfZ8sSY0eT5HIE= =prd9 -----END PGP SIGNATURE----- --3efb9065O8vkxnFZIODIk26KHXoub63ev--