From owner-freebsd-stable@FreeBSD.ORG Fri Aug 27 20:18:06 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 0C3711065693; Fri, 27 Aug 2010 20:18:06 +0000 (UTC) (envelope-from pluknet@gmail.com) Received: from mail-qw0-f54.google.com (mail-qw0-f54.google.com [209.85.216.54]) by mx1.freebsd.org (Postfix) with ESMTP id 9B8628FC20; Fri, 27 Aug 2010 20:18:05 +0000 (UTC) Received: by qwg5 with SMTP id 5so3477281qwg.13 for ; Fri, 27 Aug 2010 13:18:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=HTPIZ4SSVFAmYcuf/Ry688ilr9dyPguc0WHpXVLdg9c=; b=lzj0Gv4l9YnvauWzEBNgI6fURBb5WyxZCfz5jplKOcezLhu4YPnDA0w8Q6aZQZ+P4b f+Ha4v4mKJu2GROG2hL0p3VvfQN1f1J1kloofEEW8DZL65PdGesSsn2eZA0BkfWZZS5z ScewuDNXFDXafDnnfjxQhDSobd3J48H+GGcq4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=Ei0DHhWazSZV3exUMxQiaTexNUyWb5djwlEVwLqb2pZH6PuPH848GvhxH+smnMFwVm ywyhaSSWI+QfrcxJ9Z1bq/8S0Gri9PD3T/DJUE1BTypMjSKpyXcSbofveRw9EZ0ShPMU L7ilSwb0MM2vIAtnAZFLU20XmwbV5o+MHJTCE= MIME-Version: 1.0 Received: by 10.229.182.141 with SMTP id cc13mr920581qcb.56.1282940284782; Fri, 27 Aug 2010 13:18:04 -0700 (PDT) Received: by 10.229.26.81 with HTTP; Fri, 27 Aug 2010 13:18:04 -0700 (PDT) In-Reply-To: References: <201007141414.o6EEEUx9014690@lurza.secnetix.de> <201007141755.04690.jkim@FreeBSD.org> <4C3FB73F.7070502@freebsd.org> <201007161147.56242.jkim@FreeBSD.org> <4C6D5E31.9000701@icyb.net.ua> Date: Sat, 28 Aug 2010 00:18:04 +0400 Message-ID: From: pluknet To: Andriy Gapon Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-stable@freebsd.org, Jung-uk Kim 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: Fri, 27 Aug 2010 20:18:06 -0000 On 19 August 2010 20:56, pluknet wrote: > On 19 August 2010 20:39, Andriy Gapon wrote: >> on 10/08/2010 19:55 pluknet said the following: >>> On 16 July 2010 19:47, Jung-uk Kim wrote: >>>> The patch should apply fine on both sys/amd64/amd64/mp_machdep.c and >>>> sys/i386/i386/mp_machdep.c. >>>> >>>> http://people.freebsd.org/~jkim/mp_machdep2.diff >>>> >>> >>> >>> Hi. >>> >>> Just checked on Xen HVM with 3 cores. >>> 1) 8.1 unmodified: >>> FreeBSD/SMP: Multiprocessor System Detected: 3 CPUs >>> FreeBSD/SMP: 1 package(s) x 3 core(s) >>> >>> 2) 8.1 + patch >>> FreeBSD/SMP: Multiprocessor System Detected: 3 CPUs >>> FreeBSD/SMP: 0 package(s) x 1 core(s) x 32 HTT threads >>> WARNING: Non-uniform processors. >>> WARNING: Using suboptimal topology. >> >> Can you debug, e.g. with printfs, what exactly goes wrong? >> I wonder if in this case code follows some unusual/unexpected path. > > Sorry, I'm a bit busy right now. > I hope to debug this somewhere in the next week. First, sorry for late replay, and thanks Andriy for kicking me ;) Something really weird there . topo_probe_0xb() falls early on 1st iteration back to topo_probe_0x4(). topo_probe_0x4() returns incorrect data as well. topo_probe: cpu_high =3D b topo_probe: cpu_vendor_id =3D 8086 topo_probe_0xb: i =3D 0, p[1] =3D 0 topo_probe_0x4: cpu_procinfo =3D 200800 topo_probe_0x4: cpu_logical =3D 32 topo_probe_0x4: i =3D 0, type =3D 1 topo_probe_0x4: i =3D 0, level =3D 1 topo_probe_0x4: i =3D 0, logical =3D 1 topo_probe_0x4: i =3D 0, cores =3D 16 topo_probe_0x4: i =3D 1, type =3D 2 topo_probe_0x4: i =3D 1, level =3D 1 topo_probe_0x4: i =3D 1, logical =3D 1 topo_probe_0x4: i =3D 1, cores =3D 16 topo_probe_0x4: i =3D 2, type =3D 3 topo_probe_0x4: i =3D 2, level =3D 2 topo_probe_0x4: i =3D 2, logical =3D 1 topo_probe_0x4: i =3D 2, cores =3D 16 topo_probe#1: mp_ncpus =3D 3 topo_probe#1: cpu_cores =3D 1 topo_probe#1: cpu_logical =3D 32 topo_probe#1: hyperthreading_cpus =3D 32 topo_probe#2: mp_ncpus =3D 3 topo_probe#2: cpu_cores =3D 1 topo_probe#2: cpu_logical =3D 32 topo_probe#2: hyperthreading_cpus =3D 32 %%% static void topo_probe_0x4(void) { u_int p[4]; int cores; int i; int level; int logical; int type; cpu_logical =3D (cpu_feature & CPUID_HTT) !=3D 0 ? (cpu_procinfo & CPUID_HTT_CORES) >> 16 : 1; printf("topo_probe_0x4: cpu_procinfo =3D %x\n", cpu_procinfo); printf("topo_probe_0x4: cpu_logical =3D %d\n", cpu_logical); if (cpu_logical =3D=3D 1) { cpu_cores =3D 1; return; } /* We only support three levels for now. */ for (i =3D 0; i < 3; i++) { cpuid_count(0x04, i, p); type =3D p[0] & 0x1f; printf("topo_probe_0x4: i =3D %d, type =3D %d\n", i, type); level =3D (p[0] >> 5) & 0x7; printf("topo_probe_0x4: i =3D %d, level =3D %d\n", i, level= ); logical =3D ((p[0] >> 14) & 0xfff) + 1; printf("topo_probe_0x4: i =3D %d, logical =3D %d\n", i, log= ical); cores =3D ((p[0] >> 26) & 0x3f) + 1; printf("topo_probe_0x4: i =3D %d, cores =3D %d\n", i, cores= ); if (type =3D=3D 0) break; if (level =3D=3D 1 && cpu_logical =3D=3D logical * cores) { cpu_cores =3D cores; cpu_logical =3D logical; break; } } if (cpu_cores =3D=3D 0) cpu_cores =3D 1; if (cpu_logical > 1) hyperthreading_cpus =3D logical_cpus =3D cpu_logical; } static void topo_probe_0xb(void) { u_int p[4]; int bits; int cnt; int i; int logical; int type; int x; /* We only support three levels for now. */ for (i =3D 0; i < 3; i++) { cpuid_count(0x0b, i, p); /* * Fall back if it is not really supported. */ if (i =3D=3D 0 && p[1] =3D=3D 0) { printf("topo_probe_0xb: i =3D %d, p[1] =3D %d\n", i= , p[1]); topo_probe_0x4(); return; } [...] } static void topo_probe(void) { static int cpu_topo_probed =3D 0; if (cpu_topo_probed) return; printf("topo_probe: cpu_high =3D %x\n", cpu_high); printf("topo_probe: cpu_vendor_id =3D %x\n", cpu_vendor_id); logical_cpus =3D logical_cpus_mask =3D 0; if (cpu_vendor_id =3D=3D CPU_VENDOR_AMD) topo_probe_amd(); else if (cpu_vendor_id =3D=3D CPU_VENDOR_INTEL) { if (cpu_high >=3D 0xb) topo_probe_0xb(); else if (cpu_high >=3D 0x4) topo_probe_0x4(); } printf("topo_probe#1: mp_ncpus =3D %d\n", mp_ncpus); printf("topo_probe#1: cpu_cores =3D %d\n", cpu_cores); printf("topo_probe#1: cpu_logical =3D %d\n", cpu_logical); printf("topo_probe#1: hyperthreading_cpus =3D %d\n", hyperthreading= _cpus); if (cpu_cores =3D=3D 0) cpu_cores =3D mp_ncpus > 0 ? mp_ncpus : 1; if (cpu_logical =3D=3D 0) cpu_logical =3D 1; cpu_topo_probed =3D 1; printf("topo_probe#2: mp_ncpus =3D %d\n", mp_ncpus); printf("topo_probe#2: cpu_cores =3D %d\n", cpu_cores); printf("topo_probe#2: cpu_logical =3D %d\n", cpu_logical); printf("topo_probe#2: hyperthreading_cpus =3D %d\n", hyperthreading= _cpus); } > >> BTW, could you please also provide CPU name/model/features as detected b= y the kernel? > > Sure. > CPU: Intel(R) Xeon(R) CPU =A0 =A0 =A0 =A0 =A0 E5520 =A0@ 2.27GHz (2763.12= -MHz 686-class CPU) > =A0Origin =3D "GenuineIntel" =A0Id =3D 0x106a5 =A0Family =3D 6 =A0Model = =3D 1a =A0Stepping =3D 5 > =A0Features=3D0x1781fbbf > =A0Features2=3D0x80982201> > =A0TSC: P-state invariant > real memory =A0=3D 4194304000 (4000 MB) > avail memory =3D 3932786688 (3750 MB) > ACPI APIC Table: > FreeBSD/SMP: Multiprocessor System Detected: 3 CPUs > FreeBSD/SMP: 0 package(s) x 1 core(s) x 32 HTT threads > =A0cpu0 (BSP): APIC ID: =A00 > =A0cpu1 (AP/HT): APIC ID: =A02 > =A0cpu2 (AP/HT): APIC ID: =A04 --=20 wbr, pluknet