www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3798] New: core.cpuid locks systems with Xeon E5530 CPU

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3798

           Summary: core.cpuid locks systems with Xeon E5530 CPU
           Product: D
           Version: 2.040
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: dsimcha yahoo.com



At my workplace, we've got a bunch of Linux boxes around.  On the ones with the
following cpuinfo, importing core.cpuid causes any D program to hang with 100%
CPU usage during execution of static this() before main() is even called:

processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 26
model name      : Intel(R) Xeon(R) CPU           E5530    2.40GHz
stepping        : 5
cpu MHz         : 2393.863
cache size      : 8192 KB
physical id     : 1
siblings        : 8
core id         : 0
cpu cores       : 4
apicid          : 16
initial apicid  : 16
fpu             : yes
fpu_exception   : yes
cpuid level     : 11
wp              : yes
flags           : 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 ht tm pbe syscall nx rdtscp lm
constant_tsc arch_perfmon pebs bts rep_good xtopology tsc_reliable nonstop_tsc
pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2
popcnt lahf_lm ida tpr_shadow vnmi flexpriority ept vpid
bogomips        : 4787.72
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:


According to GDB, the function where the program hangs is
core.cpuid.getCpuInfo0B().

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 12 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3798




ASsa  temporary workaround, I'm using:

    if (0) { //max_cpuid >=0x0B) {
        // For Intel i7 and later, use function 0x0B to determine
        // cores and hyperthreads.
        getCpuInfo0B();    
    } else {
        if (hyperThreadingBit) maxThreads = (apic>>>16) & 0xFF;
        else maxThreads = maxCores;
    }

The problem appears to be that the termination condition for the following loop
never becomes true:

    do {
        asm {
            mov EAX, 0x0B;
            mov ECX, level;
            cpuid;
            mov a, EAX;
            mov b, EAX;
            mov c, ECX;
            mov d, EDX;        
        }
        if (b!=0) {
           // I'm not sure about this. The docs state that there
           // are 2 hyperthreads per core if HT is factory enabled.
            if (level==0) maxThreads = b & 0xFFFF;
            else if (level==1) maxCores = b & 0xFFFF;

        }
    } while (a!=0 || b!=0);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 12 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3798


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au




 The problem appears to be that the termination condition for the following loop
 never becomes true:
 
     do {
         asm {
             mov EAX, 0x0B;
             mov ECX, level;
             cpuid;
             mov a, EAX;
             mov b, EAX;
             mov c, ECX;
             mov d, EDX;        
         }
         if (b!=0) {
            // I'm not sure about this. The docs state that there
            // are 2 hyperthreads per core if HT is factory enabled.
             if (level==0) maxThreads = b & 0xFFFF;
             else if (level==1) maxCores = b & 0xFFFF;
 
         }
     } while (a!=0 || b!=0);
Please add ++level; as the last line of that loop, so that it ends as: ++level; } while (a!=0 || b!=0); Does that fix it? I don't have access to a Core i7, so I'm flying blind based on the Intel manuals. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 12 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3798




 Please add ++level;  as the last line of that loop, so that it ends as:
         ++level;
     } while (a!=0 || b!=0);
 
 Does that fix it? I don't have access to a Core i7, so I'm flying blind based
 on the Intel manuals.
Yep, that fixes it. Please fold into druntime for the next release. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 13 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3798





 Please add ++level;  as the last line of that loop, so that it ends as:
         ++level;
     } while (a!=0 || b!=0);
 
 Does that fix it? I don't have access to a Core i7, so I'm flying blind based
 on the Intel manuals.
Yep, that fixes it. Please fold into druntime for the next release.
Excellent! Druntime svn 245. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 13 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3798


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



Fixed DMD2.041.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 10 2010