From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: x86@kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
Borislav Petkov <bp@suse.de>, Prarit Bhargava <prarit@redhat.com>,
linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org
Subject: [PATCH RFC] x86/smpboot: Set safer __max_logical_packages limit
Date: Thu, 20 Apr 2017 15:24:53 +0200 [thread overview]
Message-ID: <20170420132453.19652-1-vkuznets@redhat.com> (raw)
Recent changes in logical package management (Commit 9d85eb9119f4
("x86/smpboot: Make logical package management more robust") and its
predecessor) caused boot failures for some Xen guests. E.g. I'm trying to
boot 10 CPU guest on AMD Opteron 4284 system and I see the following crash:
[ 0.116104] smpboot: Max logical packages: 1
...
[ 0.590068] #8
[ 0.001000] smpboot: Package 1 of CPU 8 exceeds BIOS package data 1.
[ 0.001000] ------------[ cut here ]------------
[ 0.001000] kernel BUG at arch/x86/kernel/cpu/common.c:1020!
This is happening because total_cpus is 10 and x86_max_cores is 16(!).
Turns out, the number of CPUs (vCPUs in our case) in each logical package
doesn't have to be exactly x86_max_cores, we can have any number of CPUs
<= x86_max_cores and they also don't have to match for all logical
packages. This breaks the current concept of __max_logical_packages.
In this patch I suggest we set __max_logical_packages based on the
max_physical_pkg_id and total_cpus, this should be safe and cover all
possible cases. Alternatively, we may think about eliminating the concept
of __max_logical_packages completely and relying on max_physical_pkg_id/
total_cpus where we currently use topology_max_packages().
The issue could've been solved in Xen too I guess. CPUID returning
x86_max_cores can be tweaked to be the lowerest(?) possible number of
all logical packages of the guest.
Fixes: 9d85eb9119f4 ("x86/smpboot: Make logical package management more robust")
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
arch/x86/kernel/smpboot.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index bd1f1ad..85f41cd 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -359,7 +359,6 @@ static void __init smp_init_package_map(struct cpuinfo_x86 *c, unsigned int cpu)
ncpus = 1;
}
- __max_logical_packages = DIV_ROUND_UP(total_cpus, ncpus);
logical_packages = 0;
/*
@@ -367,6 +366,15 @@ static void __init smp_init_package_map(struct cpuinfo_x86 *c, unsigned int cpu)
* package can be smaller than the actual used apic ids.
*/
max_physical_pkg_id = DIV_ROUND_UP(MAX_LOCAL_APIC, ncpus);
+
+ /*
+ * Each logical package has not more than x86_max_cores CPUs but
+ * it can happen that it has less, e.g. we may have 1 CPU per logical
+ * package regardless of what's in x86_max_cores. This is seen on some
+ * Xen setups with AMD processors.
+ */
+ __max_logical_packages = min(max_physical_pkg_id, total_cpus);
+
size = max_physical_pkg_id * sizeof(unsigned int);
physical_to_logical_pkg = kmalloc(size, GFP_KERNEL);
memset(physical_to_logical_pkg, 0xff, size);
--
2.9.3
next reply other threads:[~2017-04-20 13:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-20 13:24 Vitaly Kuznetsov [this message]
2017-04-20 15:06 ` [PATCH RFC] x86/smpboot: Set safer __max_logical_packages limit Peter Zijlstra
2017-04-20 15:40 ` Vitaly Kuznetsov
2017-04-20 16:01 ` [Xen-devel] " Boris Ostrovsky
2017-04-20 16:21 ` Vitaly Kuznetsov
2017-04-20 16:15 ` Peter Zijlstra
2017-04-20 17:09 ` [Xen-devel] " Boris Ostrovsky
2017-04-20 17:04 ` Andrew Cooper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170420132453.19652-1-vkuznets@redhat.com \
--to=vkuznets@redhat.com \
--cc=bp@suse.de \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=prarit@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox