Re: 4.5.0+ panic when setup loop device

From: Thomas Gleixner
Date: Fri Mar 18 2016 - 07:57:29 EST


On Fri, 18 Mar 2016, Mike Galbraith wrote:
> On Thu, 2016-03-17 at 10:52 +0100, Peter Zijlstra wrote:
>
> > Andreas; Borislav said to Cc you since you wrote all this.
> > The issue is that Linux assumes:
> >
> > > nr_logical_cpus = nr_cores * nr_siblings
>
> It also seems to now assume that if SMT is possible, it's enabled.
>
> Below is my 8 socket DL980 G7, which has SMT turned off for RT testing,
> booting NOPREEMPT master tuned for maximum bloat ala distro and getting
> confused by me telling it (as always) nr_cpus=64. Bad juju ensues.

:)

Does the patch below fix the wreckage?

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 643dbdccf4bc..c5ac71276076 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -319,7 +319,7 @@ static void __init smp_init_package_map(void)
* might change in the future....
*/
ncpus = boot_cpu_data.x86_max_cores * smp_num_siblings;
- __max_logical_packages = DIV_ROUND_UP(nr_cpu_ids, ncpus);
+ __max_logical_packages = DIV_ROUND_UP(total_cpus, ncpus);

/*
* Possibly larger than what we need as the number of apic ids per