On 19 August 2010 20:56, pluknet <pluk...@gmail.com> wrote:
> On 19 August 2010 20:39, Andriy Gapon <a...@icyb.net.ua> wrote:
>> on 10/08/2010 19:55 pluknet said the following:
>>> On 16 July 2010 19:47, Jung-uk Kim <j...@freebsd.org> 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 = b
topo_probe: cpu_vendor_id = 8086
topo_probe_0xb: i = 0, p[1] = 0
topo_probe_0x4: cpu_procinfo = 200800
topo_probe_0x4: cpu_logical = 32
topo_probe_0x4: i = 0, type = 1
topo_probe_0x4: i = 0, level = 1
topo_probe_0x4: i = 0, logical = 1
topo_probe_0x4: i = 0, cores = 16
topo_probe_0x4: i = 1, type = 2
topo_probe_0x4: i = 1, level = 1
topo_probe_0x4: i = 1, logical = 1
topo_probe_0x4: i = 1, cores = 16
topo_probe_0x4: i = 2, type = 3
topo_probe_0x4: i = 2, level = 2
topo_probe_0x4: i = 2, logical = 1
topo_probe_0x4: i = 2, cores = 16
topo_probe#1: mp_ncpus = 3
topo_probe#1: cpu_cores = 1
topo_probe#1: cpu_logical = 32
topo_probe#1: hyperthreading_cpus = 32
topo_probe#2: mp_ncpus = 3
topo_probe#2: cpu_cores = 1
topo_probe#2: cpu_logical = 32
topo_probe#2: hyperthreading_cpus = 32


%%%
static void
topo_probe_0x4(void)
{
        u_int p[4];
        int cores;
        int i;
        int level;
        int logical;
        int type;

        cpu_logical = (cpu_feature & CPUID_HTT) != 0 ?
            (cpu_procinfo & CPUID_HTT_CORES) >> 16 : 1;
        printf("topo_probe_0x4: cpu_procinfo = %x\n", cpu_procinfo);
        printf("topo_probe_0x4: cpu_logical = %d\n", cpu_logical);
        if (cpu_logical == 1) {
                cpu_cores = 1;
                return;
        }

        /* We only support three levels for now. */
        for (i = 0; i < 3; i++) {
                cpuid_count(0x04, i, p);
                type = p[0] & 0x1f;
                printf("topo_probe_0x4: i = %d, type = %d\n", i, type);
                level = (p[0] >> 5) & 0x7;
                printf("topo_probe_0x4: i = %d, level = %d\n", i, level);
                logical = ((p[0] >> 14) & 0xfff) + 1;
                printf("topo_probe_0x4: i = %d, logical = %d\n", i, logical);
                cores = ((p[0] >> 26) & 0x3f) + 1;
                printf("topo_probe_0x4: i = %d, cores = %d\n", i, cores);
                if (type == 0)
                        break;
                if (level == 1 && cpu_logical == logical * cores) {
                        cpu_cores = cores;
                        cpu_logical = logical;
                        break;
                }
        }
        if (cpu_cores == 0)
                cpu_cores = 1;
        if (cpu_logical > 1)
                hyperthreading_cpus = logical_cpus = 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 = 0; i < 3; i++) {
                cpuid_count(0x0b, i, p);

                /*
                 * Fall back if it is not really supported.
                 */
                if (i == 0 && p[1] == 0) {
                        printf("topo_probe_0xb: i = %d, p[1] = %d\n", i, p[1]);
                        topo_probe_0x4();
                        return;
                }
[...]
}

static void
topo_probe(void)
{
        static int cpu_topo_probed = 0;

        if (cpu_topo_probed)
                return;

        printf("topo_probe: cpu_high = %x\n", cpu_high);
        printf("topo_probe: cpu_vendor_id = %x\n", cpu_vendor_id);
        logical_cpus = logical_cpus_mask = 0;
        if (cpu_vendor_id == CPU_VENDOR_AMD)
                topo_probe_amd();
        else if (cpu_vendor_id == CPU_VENDOR_INTEL) {
                if (cpu_high >= 0xb)
                        topo_probe_0xb();
                else if (cpu_high >= 0x4)
                        topo_probe_0x4();
        }
        printf("topo_probe#1: mp_ncpus = %d\n", mp_ncpus);
        printf("topo_probe#1: cpu_cores = %d\n", cpu_cores);
        printf("topo_probe#1: cpu_logical = %d\n", cpu_logical);
        printf("topo_probe#1: hyperthreading_cpus = %d\n", hyperthreading_cpus);
        if (cpu_cores == 0)
                cpu_cores = mp_ncpus > 0 ? mp_ncpus : 1;
        if (cpu_logical == 0)
                cpu_logical = 1;
        cpu_topo_probed = 1;
        printf("topo_probe#2: mp_ncpus = %d\n", mp_ncpus);
        printf("topo_probe#2: cpu_cores = %d\n", cpu_cores);
        printf("topo_probe#2: cpu_logical = %d\n", cpu_logical);
        printf("topo_probe#2: hyperthreading_cpus = %d\n", hyperthreading_cpus);
}


>
>> BTW, could you please also provide CPU name/model/features as detected by 
>> the kernel?
>
> Sure.
> CPU: Intel(R) Xeon(R) CPU           E5520  @ 2.27GHz (2763.12-MHz 686-class 
> CPU)
>  Origin = "GenuineIntel"  Id = 0x106a5  Family = 6  Model = 1a  Stepping = 5
>  Features=0x1781fbbf<FPU,VME,DE,PSE,TSC,MSR,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,MMX,FXSR,SSE,SSE2,HTT>
>  Features2=0x80982201<SSE3,SSSE3,CX16,SSE4.1,SSE4.2,POPCNT,<b31>>
>  TSC: P-state invariant
> real memory  = 4194304000 (4000 MB)
> avail memory = 3932786688 (3750 MB)
> ACPI APIC Table: <Xen HVM>
> FreeBSD/SMP: Multiprocessor System Detected: 3 CPUs
> FreeBSD/SMP: 0 package(s) x 1 core(s) x 32 HTT threads
>  cpu0 (BSP): APIC ID:  0
>  cpu1 (AP/HT): APIC ID:  2
>  cpu2 (AP/HT): APIC ID:  4

-- 
wbr,
pluknet
_______________________________________________
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "freebsd-stable-unsubscr...@freebsd.org"

Reply via email to