[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] Add CPU topology info (thread/core/socket) in xenpm



2009/3/13 Akio Takebe <takebe_akio@xxxxxxxxxxxxxx>:
> Hi,
>
> Akio Takebe wrote:
>> Hi, Yu
>>
>> Good patch! We wanted this feature.
>>
>>> Add CPU topology info (thread/core/socket) in xenpm
>> Can this patch show thread?
>>
>>> +#define MAX_NR_CPU 512
>>> +
>>> +void cpu_topology_func(int argc, char *argv[])
>>> +{
>>> +    uint32_t cpu_to_core[MAX_NR_CPU];
>>> +    uint32_t cpu_to_socket[MAX_NR_CPU];
>>> +    struct xc_get_cputopo info;
>>> +    int i, ret;
>>> +
>>> +    info.cpu_to_core = cpu_to_core;
>>> +    info.cpu_to_socket = cpu_to_socket;
>>> +    info.max_cpus = MAX_NR_CPU;
>>> +    ret = xc_get_cputopo(xc_fd, &info);
>>> +    if (!ret)
>>> +    {
>>> +        printf("CPU\tcore\tsocket\n");
>>> +        for (i=0; i<info.nr_cpus; i++)
>>> +        {
>>> +            if ( info.cpu_to_core[i] != INVALID_TOPOLOGY_ID &&
>>> +                    info.cpu_to_socket[i] != INVALID_TOPOLOGY_ID )
>>> +            {
>>> +            printf("CPU%d\t %d\t %d\n", i, info.cpu_to_core[i],
>>> +                    info.cpu_to_socket[i]);
>>> +            }
>>> +        }
>>> +    }
>>> +    else
>>> +    {
>>> +        printf("Can not get Xen CPU topology!\n");
>>> +    }
>>> +
>>> +    return ;
>>> +}
>> The function looks like only show core/socket.
>>
> Is the CPU%d means thread?
>
> Best Regards,
>
> Akio Takebe

Yes, you are right :)  thread is the smallest unit, so here just use
CPU for thread.

A thread related example is, in a 2 sockets system, where 4 cores per
socket and 2 threads per core, here is a possible output

# xenpm get-cpu-topology
CPU     core    socket
CPU0     0       0
CPU1     0       1
CPU2     1       0
CPU3     1       1
CPU4     2       0
CPU5     2       1
CPU6     3       0
CPU7     3       1
CPU8     0       0
CPU9     0       1
CPU10    1       0
CPU11    1       1
CPU12    2       0
CPU13    2       1
CPU14    3       0
CPU15    3       1

Indicating the following topology
socket 0:
      core 0: CPU0 CPU8
      core 1: CPU2 CPU10
      core 2: CPU4 CPU12
      core 3: CPU6 CPU14
socket 1:
      core 0: CPU1 CPU9
      core 1: CPU3 CPU11
      core 2: CPU5 CPU13
      core 3: CPU7 CPU15

Probably later I can add one option to make xenpm output the above
more human-readable format.

Best Regards
Ke

Intel Open Source Technology Center

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.