From nobody@FreeBSD.org  Sun Apr 23 14:01:35 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id F355816A402
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 23 Apr 2006 14:01:34 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 75BF743D53
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 23 Apr 2006 14:01:34 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k3NE1XlJ042482
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 23 Apr 2006 14:01:33 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id k3NE1XwE042481;
	Sun, 23 Apr 2006 14:01:33 GMT
	(envelope-from nobody)
Message-Id: <200604231401.k3NE1XwE042481@www.freebsd.org>
Date: Sun, 23 Apr 2006 14:01:33 GMT
From: Attila Nagy <bra@fsn.hu>
To: freebsd-gnats-submit@FreeBSD.org
Subject: FreeBSD recognizes Intel LV dual core Xeon (sossaman) as a one core CPU with a hyperthread virtual CPU
X-Send-Pr-Version: www-2.3

>Number:         96203
>Category:       i386
>Synopsis:       FreeBSD recognizes Intel LV dual core Xeon (sossaman) as a one core CPU with a hyperthread virtual CPU
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    jkim
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Apr 23 14:10:12 GMT 2006
>Closed-Date:    Tue Apr 25 15:48:51 GMT 2006
>Last-Modified:  Tue Apr 25 15:48:51 GMT 2006
>Originator:     Attila Nagy
>Release:        6.1-RC
>Organization:
>Environment:
FreeBSD 6.1-RC #0: Fri Apr 21 23:29:17 CEST 2006
>Description:
FreeBSD recognizes Intel's dual core, low voltage Xeon processors (sossaman) as a single core processor with a virtual CPU. Because hyperthreading is disabled by default, there are no processes scheduled to the extra cores.

Copyright (c) 1992-2006 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD 6.1-RC #0: Fri Apr 21 23:29:17 CEST 2006
    root@sossaman:/usr/obj/usr/src/sys/SMP
Timecounter "i8254" frequency 1193182 Hz quality 0
CPU: Intel(R) Dual Pentium(R) M CPU   000  @ 2.00GHz (2000.15-MHz 686-class CPU)
  Origin = "GenuineIntel"  Id = 0x6e4  Stepping = 4
  Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,C
MOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
  Features2=0x41a9<SSE3,MON,VMX,EST,TM2,<b14>>
  AMD Features=0x100000<NX>
  Hyperthreading: 2 logical CPUs
real memory  = 2147352576 (2047 MB)
avail memory = 2096332800 (1999 MB)
ACPI APIC Table: <A M I  OEMAPIC >
FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs
 cpu0 (BSP): APIC ID:  0
 cpu1 (AP): APIC ID:  1
 cpu2 (AP): APIC ID:  6
 cpu3 (AP): APIC ID:  7
ioapic0 <Version 2.0> irqs 0-23 on motherboard
ioapic1 <Version 2.0> irqs 24-47 on motherboard
kbd1 at kbdmux0
npx0: [FAST]
npx0: <math processor> on motherboard
npx0: INT 16 interface
acpi0: <A M I OEMRSDT> on motherboard
acpi0: Power Button (fixed)
Timecounter "ACPI-fast" frequency 3579545 Hz quality 1000
acpi_timer0: <24-bit timer at 3.579545MHz> port 0x408-0x40b on acpi0
cpu0: <ACPI CPU> on acpi0
acpi_throttle0: <ACPI CPU Throttling> on cpu0
cpu1: <ACPI CPU> on acpi0
    ACPI-0438: *** Error: Looking up [TYPE] in namespace, AE_NOT_FOUND
SearchNode 0xc63c6c20 StartNode 0xc63c6c20 ReturnNode 0
    ACPI-1304: *** Error: Method execution failed [\\_PR_.CPU2._PDC] (Node 0xc63
c6c20), AE_NOT_FOUND
cpu2: <ACPI CPU> on acpi0
cpu3: <ACPI CPU> on acpi0


>How-To-Repeat:

>Fix:
machdep.hyperthreading_allowed=1
but it would be better to not to think this is a HT capable processor. (HT is not available in these, or at least it is disabled)
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-i386->jkim 
Responsible-Changed-By: jkim 
Responsible-Changed-When: Mon Apr 24 19:57:36 UTC 2006 
Responsible-Changed-Why:  
I'll take this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=96203 

From: Jung-uk Kim <jkim@FreeBSD.org>
To: bug-followup@FreeBSD.org, bra@fsn.hu
Cc: John Baldwin <jhb@FreeBSD.org>
Subject: Re: i386/96203: FreeBSD recognizes Intel LV dual core Xeon (sossaman) as a one core CPU with a hyperthread virtual CPU
Date: Mon, 24 Apr 2006 15:56:26 -0400

 --Boundary-00=_u1STEQ2M5OJaZbb
 Content-Type: text/plain;
   charset="iso-8859-1"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline
 
 Can you update your kernel source and try the attached patch?
 
 Thanks,
 
 Jung-uk Kim
 
 --Boundary-00=_u1STEQ2M5OJaZbb
 Content-Type: text/x-diff;
   charset="iso-8859-1";
   name="mp_machdep.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
 	filename="mp_machdep.diff"
 
 Index: sys/amd64/amd64/mp_machdep.c
 ===================================================================
 RCS file: /home/ncvs/src/sys/amd64/amd64/mp_machdep.c,v
 retrieving revision 1.271
 diff -u -r1.271 mp_machdep.c
 --- sys/amd64/amd64/mp_machdep.c	18 Mar 2006 19:32:46 -0000	1.271
 +++ sys/amd64/amd64/mp_machdep.c	24 Apr 2006 19:39:55 -0000
 @@ -183,6 +183,7 @@
  mp_topology(void)
  {
  	struct cpu_group *group;
 +	u_int regs[4];
  	int logical_cpus;
  	int apic_id;
  	int groups;
 @@ -195,6 +196,12 @@
  	logical_cpus = (cpu_procinfo & CPUID_HTT_CORES) >> 16;
  	if (logical_cpus <= 1)
  		return;
 +	/* Nothing to do if reported cores are physical cores. */
 +	if (strcmp(cpu_vendor, "GenuineIntel") == 0 && cpu_high >= 4) {
 +		cpuid_count(4, 0, regs);
 +		if (logical_cpus <= ((regs[0] & 0xfc000000) >> 26) + 1)
 +			return;
 +	}
  	group = &mp_groups[0];
  	groups = 1;
  	for (cpu = 0, apic_id = 0; apic_id < MAXCPU; apic_id++) {
 Index: sys/i386/i386/mp_machdep.c
 ===================================================================
 RCS file: /home/ncvs/src/sys/i386/i386/mp_machdep.c,v
 retrieving revision 1.264
 diff -u -r1.264 mp_machdep.c
 --- sys/i386/i386/mp_machdep.c	9 Mar 2006 16:38:52 -0000	1.264
 +++ sys/i386/i386/mp_machdep.c	24 Apr 2006 19:39:55 -0000
 @@ -240,6 +240,7 @@
  mp_topology(void)
  {
  	struct cpu_group *group;
 +	u_int regs[4];
  	int logical_cpus;
  	int apic_id;
  	int groups;
 @@ -252,6 +253,12 @@
  	logical_cpus = (cpu_procinfo & CPUID_HTT_CORES) >> 16;
  	if (logical_cpus <= 1)
  		return;
 +	/* Nothing to do if reported cores are physical cores. */
 +	if (strcmp(cpu_vendor, "GenuineIntel") == 0 && cpu_high >= 4) {
 +		cpuid_count(4, 0, regs);
 +		if (logical_cpus <= ((regs[0] & 0xfc000000) >> 26) + 1)
 +			return;
 +	}
  	group = &mp_groups[0];
  	groups = 1;
  	for (cpu = 0, apic_id = 0; apic_id < MAXCPU; apic_id++) {
 
 --Boundary-00=_u1STEQ2M5OJaZbb--

From: John Baldwin <jhb@freebsd.org>
To: Jung-uk Kim <jkim@freebsd.org>
Cc: bug-followup@freebsd.org, bra@fsn.hu
Subject: Re: i386/96203: FreeBSD recognizes Intel LV dual core Xeon (sossaman) as a one core CPU with a hyperthread virtual CPU
Date: Mon, 24 Apr 2006 16:35:44 -0400

 On Monday 24 April 2006 15:56, Jung-uk Kim wrote:
 > Can you update your kernel source and try the attached patch?
 > 
 > Thanks,
 > 
 > Jung-uk Kim
 
 I'm not sure this is quite right as you need to handle the
 multi-core with HTT case (i.e. 1 physical process with 2
 cores each of which has 2 threads).
 
 -- 
 John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
 "Power Users Use the Power to Serve"  =  http://www.FreeBSD.org

From: Jung-uk Kim <jkim@FreeBSD.org>
To: John Baldwin <jhb@FreeBSD.org>
Cc: bug-followup@FreeBSD.org, bra@fsn.hu
Subject: Re: i386/96203: FreeBSD recognizes Intel LV dual core Xeon (sossaman) as a one core CPU with a hyperthread virtual CPU
Date: Mon, 24 Apr 2006 16:53:44 -0400

 On Monday 24 April 2006 04:35 pm, John Baldwin wrote:
 > On Monday 24 April 2006 15:56, Jung-uk Kim wrote:
 > > Can you update your kernel source and try the attached patch?
 >
 > I'm not sure this is quite right as you need to handle the
 > multi-core with HTT case (i.e. 1 physical process with 2
 > cores each of which has 2 threads).
 
 It is 'number of physical cores per processor package' while 
 CPUID_HTT_CORES is 'number of logical cores per processor package'.  
 In your example, 'logical_cpus' should be 4 and '((regs[0] & 
 0xfc000000) >> 26) + 1' should be 2.  I think that is correct.  
 However, you can test my theory with the following simple test:
 
 http://people.freebsd.org/~jkim/cpuid.c
 
 I really love to see one of these beasts and see what it says but I am 
 just a poor developer. ;-)
 
 BTW, like I said, the actual hyperthreading core test is done by 
 cpu_mp_start() and I am working on it now.
 
 Jung-uk Kim

From: John Baldwin <jhb@freebsd.org>
To: Jung-uk Kim <jkim@freebsd.org>
Cc: bug-followup@freebsd.org, bra@fsn.hu
Subject: Re: i386/96203: FreeBSD recognizes Intel LV dual core Xeon (sossaman) as a one core CPU with a hyperthread virtual CPU
Date: Mon, 24 Apr 2006 17:08:06 -0400

 On Monday 24 April 2006 16:53, Jung-uk Kim wrote:
 > On Monday 24 April 2006 04:35 pm, John Baldwin wrote:
 > > On Monday 24 April 2006 15:56, Jung-uk Kim wrote:
 > > > Can you update your kernel source and try the attached patch?
 > >
 > > I'm not sure this is quite right as you need to handle the
 > > multi-core with HTT case (i.e. 1 physical process with 2
 > > cores each of which has 2 threads).
 > 
 > It is 'number of physical cores per processor package' while 
 > CPUID_HTT_CORES is 'number of logical cores per processor package'.  
 > In your example, 'logical_cpus' should be 4 and '((regs[0] & 
 > 0xfc000000) >> 26) + 1' should be 2.  I think that is correct.  
 > However, you can test my theory with the following simple test:
 > 
 > http://people.freebsd.org/~jkim/cpuid.c
 
 I don't have hardware. :(
 
 -- 
 John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
 "Power Users Use the Power to Serve"  =  http://www.FreeBSD.org

From: Jung-uk Kim <jkim@FreeBSD.org>
To: bug-followup@FreeBSD.org, bra@fsn.hu
Cc: John Baldwin <jhb@FreeBSD.org>
Subject: Re: i386/96203: FreeBSD recognizes Intel LV dual core Xeon (sossaman) as a one core CPU with a hyperthread virtual CPU
Date: Mon, 24 Apr 2006 19:37:16 -0400

 I re-read Intel's 'AP-485: Intel Processor Identification and the 
 CPUID Instruction':
 
 http://download.intel.com/design/Xeon/applnots/24161830.pdf
 
 I am quite convinced that this is the right thing to do.  Both 
 assembly and C examples show the idea is correct.
 
 Note shared L1 cache detection is already corrected by cperciva@.
 
 Jung-uk Kim
State-Changed-From-To: open->feedback 
State-Changed-By: jkim 
State-Changed-When: Tue Apr 25 00:17:19 UTC 2006 
State-Changed-Why:  
Refined patch committed to HEAD.  Please test the following patches: 

http://docs.freebsd.org/cgi/mid.cgi?200604241824.k3OIOVPD024705 
http://docs.freebsd.org/cgi/mid.cgi?200604242117.k3OLH2RG032117 
http://docs.freebsd.org/cgi/mid.cgi?200604250006.k3P06c7R027070 

and give us feedback. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=96203 

From: Attila Nagy <bra@fsn.hu>
To: John Baldwin <jhb@freebsd.org>
Cc: Jung-uk Kim <jkim@freebsd.org>,  bug-followup@freebsd.org
Subject: Re: i386/96203: FreeBSD recognizes Intel LV dual core Xeon (sossaman)
 as a one core CPU with a hyperthread virtual CPU
Date: Tue, 25 Apr 2006 11:24:52 +0200

 Hello,
 
 On 04/24/06 23:08, John Baldwin wrote:
 > On Monday 24 April 2006 16:53, Jung-uk Kim wrote:
 >> On Monday 24 April 2006 04:35 pm, John Baldwin wrote:
 >>> On Monday 24 April 2006 15:56, Jung-uk Kim wrote:
 >>>> Can you update your kernel source and try the attached patch?
 >>> I'm not sure this is quite right as you need to handle the
 >>> multi-core with HTT case (i.e. 1 physical process with 2
 >>> cores each of which has 2 threads).
 >> It is 'number of physical cores per processor package' while 
 >> CPUID_HTT_CORES is 'number of logical cores per processor package'.  
 >> In your example, 'logical_cpus' should be 4 and '((regs[0] & 
 >> 0xfc000000) >> 26) + 1' should be 2.  I think that is correct.  
 >> However, you can test my theory with the following simple test:
 >>
 >> http://people.freebsd.org/~jkim/cpuid.c
 > 
 > I don't have hardware. :(
 I've upgraded to CURRENT. dmesg:
 FreeBSD 7.0-CURRENT #0: Tue Apr 25 10:47:59 CEST 2006
 ACPI APIC Table: <A M I  OEMAPIC >
 Timecounter "i8254" frequency 1193182 Hz quality 0
 CPU: Intel(R) Dual Pentium(R) M CPU   000  @ 2.00GHz (2000.15-MHz 
 686-class CPU)
    Origin = "GenuineIntel"  Id = 0x6e4  Stepping = 4
  
 Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
    Features2=0x41a9<SSE3,MON,VMX,EST,TM2,XTPR>
    AMD Features=0x100000<NX>
    Cores per package: 2
 real memory  = 2147352576 (2047 MB)
 avail memory = 2096152576 (1999 MB)
 FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs
   cpu0 (BSP): APIC ID:  0
   cpu1 (AP): APIC ID:  1
   cpu2 (AP): APIC ID:  6
   cpu3 (AP): APIC ID:  7
 ioapic0 <Version 2.0> irqs 0-23 on motherboard
 ioapic1 <Version 2.0> irqs 24-47 on motherboard
 kbd1 at kbdmux0
 acpi0: <A M I OEMRSDT> on motherboard
 acpi0: Power Button (fixed)
 Timecounter "ACPI-safe" frequency 3579545 Hz quality 1000
 acpi_timer0: <24-bit timer at 3.579545MHz> port 0x408-0x40b on acpi0
 cpu0: <ACPI CPU> on acpi0
 acpi_throttle0: <ACPI CPU Throttling> on cpu0
 cpu1: <ACPI CPU> on acpi0
      ACPI-0448: *** Error: Looking up [TYPE] in namespace, AE_NOT_FOUND
 SearchNode 0xc63d6da0 StartNode 0xc63d6da0 ReturnNode 0
      ACPI-0610: *** Error: Method execution failed [\\_PR_.CPU2._PDC] 
 (Node 0xc63d6da0), AE_NOT_FOUND
 cpu2: <ACPI CPU> on acpi0
 cpu3: <ACPI CPU> on acpi0
 
 
 -- 
 Attila Nagy                                   e-mail: Attila.Nagy@fsn.hu
 Free Software Network (FSN.HU)                 phone: +3630 306 6758
 http://www.fsn.hu/
State-Changed-From-To: feedback->closed 
State-Changed-By: jkim 
State-Changed-When: Tue Apr 25 15:46:30 UTC 2006 
State-Changed-Why:  
Closing.  Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=96203 
>Unformatted:
