| Summary: | [panic] Panic at boot due to integer overflow computing top->cg_mask in smp_topo_none() when mp_ncpus == 32 | ||
|---|---|---|---|
| Product: | Base System | Reporter: | Joe Landers <jlanders> |
| Component: | kern | Assignee: | attilio |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | Unspecified | ||
| Hardware: | Any | ||
| OS: | Any | ||
|
Description
Joe Landers
2010-07-17 00:10:07 UTC
State Changed From-To: open->suspended I think the answer right now is "unfortunately, you're right". IIRC there are people working on code to handle > 32 CPUs, but it's not ready to commit yet. But take this with a grain of salt -- I'm wearing a bugmeister hat as I type this, not a source developer hat. We understand that > 32 CPUs isn't possible with the current code structure= . However, it is trivial to make the case of mp_ncpus =3D=3D 32 work. Assuming no error checking, simply change the computation of top->cg_mask f= rom: top->cg_mask =3D (1 << mp_ncpus) - 1; to: top->cg_mask =3D ~0U >> (32 - mp_ncpus); in subr_smp.c:smp_topo_none(). FreeBSD will then boot fine with 32 or fewer CPUs: ... FreeBSD/SMP: Multiprocessor System Detected: 32 CPUs FreeBSD/SMP: 32 package(s) x 1 core(s) cpu0 (BSP): APIC ID: 0 cpu1 (AP): APIC ID: 1 cpu2 (AP): APIC ID: 2 cpu3 (AP): APIC ID: 3 cpu4 (AP): APIC ID: 4 cpu5 (AP): APIC ID: 5 cpu6 (AP): APIC ID: 6 cpu7 (AP): APIC ID: 7 cpu8 (AP): APIC ID: 8 cpu9 (AP): APIC ID: 9 cpu10 (AP): APIC ID: 10 cpu11 (AP): APIC ID: 11 cpu12 (AP): APIC ID: 12 cpu13 (AP): APIC ID: 13 cpu14 (AP): APIC ID: 14 cpu15 (AP): APIC ID: 15 cpu16 (AP): APIC ID: 16 cpu17 (AP): APIC ID: 17 cpu18 (AP): APIC ID: 18 cpu19 (AP): APIC ID: 19 cpu20 (AP): APIC ID: 20 cpu21 (AP): APIC ID: 21 cpu22 (AP): APIC ID: 22 cpu23 (AP): APIC ID: 23 cpu24 (AP): APIC ID: 24 cpu25 (AP): APIC ID: 25 cpu26 (AP): APIC ID: 26 cpu27 (AP): APIC ID: 27 cpu28 (AP): APIC ID: 28 cpu29 (AP): APIC ID: 29 cpu30 (AP): APIC ID: 30 cpu31 (AP): APIC ID: 31 ioapic0: Changing APIC ID to 32 ... SMP: AP CPU #28 Launched! SMP: AP CPU #27 Launched! SMP: AP CPU #1 Launched! SMP: AP CPU #2 Launched! SMP: AP CPU #31 Launched! SMP: AP CPU #3 Launched! SMP: AP CPU #13 Launched! SMP: AP CPU #23 Launched! SMP: AP CPU #4 Launched! SMP: AP CPU #9 Launched! SMP: AP CPU #20 Launched! SMP: AP CPU #21 Launched! SMP: AP CPU #5 Launched! SMP: AP CPU #12 Launched! SMP: AP CPU #15 Launched! SMP: AP CPU #16 Launched! SMP: AP CPU #7 Launched! SMP: AP CPU #26 Launched! SMP: AP CPU #29 Launched! SMP: AP CPU #17 Launched! SMP: AP CPU #25 Launched! SMP: AP CPU #6 Launched! SMP: AP CPU #11 Launched! SMP: AP CPU #19 Launched! SMP: AP CPU #14 Launched! SMP: AP CPU #18 Launched! SMP: AP CPU #22 Launched! SMP: AP CPU #10 Launched! SMP: AP CPU #24 Launched! SMP: AP CPU #8 Launched! SMP: AP CPU #30 Launched! ... We verified this fix on both physical and virtual hardware. Thanks, Joe Landers jlanders@vmware.com Author: attilio Date: Mon Aug 9 00:23:57 2010 New Revision: 211087 URL: http://svn.freebsd.org/changeset/base/211087 Log: The r208165 fixed a bug related to unsigned integer overflowing for the number of CPUs detection. However, that was not mention at all, the problem was not reported, the patch has not been MFCed and the fix is mostly improper. Fix the original overflow (caused when 32 CPUs must be detected) by just using a different mathematical computation (it also makes more explicit the size of operands involved, which is good in the moment waiting for a more complete support for a large number of CPUs). PR: kern/148698 Submitted by: Joe Landers <jlanders at vmware dot com> Tested by: gianni MFC after: 10 days Modified: head/sys/kern/subr_smp.c Modified: head/sys/kern/subr_smp.c ============================================================================== --- head/sys/kern/subr_smp.c Sun Aug 8 23:24:23 2010 (r211086) +++ head/sys/kern/subr_smp.c Mon Aug 9 00:23:57 2010 (r211087) @@ -504,10 +504,7 @@ smp_topo_none(void) top = &group[0]; top->cg_parent = NULL; top->cg_child = NULL; - if (mp_ncpus == sizeof(top->cg_mask) * 8) - top->cg_mask = -1; - else - top->cg_mask = (1 << mp_ncpus) - 1; + top->cg_mask = ~0U >> (32 - mp_ncpus); top->cg_count = mp_ncpus; top->cg_children = 0; top->cg_level = CG_SHARE_NONE; _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org" State Changed From-To: suspended->patched Patch committed; set as MFC reminder. Responsible Changed From-To: freebsd-bugs->attilio State Changed From-To: patched->closed Merged to 8 (as svn r215938). |