From owner-freebsd-stable@FreeBSD.ORG Thu Jul 15 17:56:21 2010 Return-Path: Delivered-To: freebsd-stable@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 611DD1065673; Thu, 15 Jul 2010 17:56:21 +0000 (UTC) (envelope-from avg@icyb.net.ua) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 758A58FC19; Thu, 15 Jul 2010 17:56:20 +0000 (UTC) Received: from odyssey.starpoint.kiev.ua (alpha-e.starpoint.kiev.ua [212.40.38.101]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id UAA05479; Thu, 15 Jul 2010 20:56:12 +0300 (EEST) (envelope-from avg@icyb.net.ua) Message-ID: <4C3F4BBB.30606@icyb.net.ua> Date: Thu, 15 Jul 2010 20:56:11 +0300 From: Andriy Gapon User-Agent: Thunderbird 2.0.0.24 (X11/20100517) MIME-Version: 1.0 To: Oliver Fromme References: <201007151657.o6FGv97V080710@lurza.secnetix.de> In-Reply-To: <201007151657.o6FGv97V080710@lurza.secnetix.de> X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: freebsd-stable@FreeBSD.ORG, jkim@FreeBSD.ORG Subject: Re: 8.1-PRERELEASE: CPU packages not detected correctly X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Jul 2010 17:56:21 -0000 on 15/07/2010 19:57 Oliver Fromme said the following: > In topo_probe(), cpu_high is 0xd, so topo_probe_0xb() is > called. But the cpuid 0xb instruction doesn't seem to > return useful data: All values are zero already in the > first level, so cpu_cores remains 0. > > Back in topo_probe(), there is a fallback if cpu_cores is > stil 0: It assigns mp_ncpu to cpu_cores, so it gets 8 > which is wrong. > > I patched topo_probe() so it calls topo_probe_0x4() after > topo_probe_0xb() if cpu_cores is still 0. I think this > is a better fallback procedure. With this patch, cpu_cores > gets the value 4 which is the correct one, finally: > > FreeBSD/SMP: Multiprocessor System Detected: 8 CPUs > FreeBSD/SMP: 2 package(s) x 4 core(s) Thank you for debugging this issue! Not sure if this is the best patch that there can be, but its direction is definitely correct. As the Intel document says (translated to our x86 mp_machdep.c terms): if cpu_high >= 0xb then we should execute cpuid_count(0xb, 0, p) and examine EBX value (p[1]), only if it's non-zero should we proceed with topo_probe_0xb(), otherwise we should fall back to topo_probe_0x4, etc. I think that your addition achieves this effect, perhaps just not as explicitly as I would preferred. Jung-uk, what do you think? > > This is the patch, it's against jkim's patched version: > @@ -265,7 +268,7 @@ > else if (cpu_vendor_id == CPU_VENDOR_INTEL) { > if (cpu_high >= 0xb) > topo_probe_0xb(); > - else if (cpu_high >= 0x4) > + if (cpu_high >= 0x4 && cpu_cores == 0) > topo_probe_0x4(); > } > if (cpu_cores == 0) -- Andriy Gapon