From 2d8b420b9f81391ac06624a0a4828f19dc876825 Mon Sep 17 00:00:00 2001 From: Attilio Rao Date: Mon, 9 Aug 2010 00:23:57 +0000 Subject: [PATCH] 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 Tested by: gianni MFC after: 10 days --- sys/kern/subr_smp.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c index 89542f9f209c..711b98382b75 100644 --- a/sys/kern/subr_smp.c +++ b/sys/kern/subr_smp.c @@ -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;