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

[libvirt] Add hyperthreaded sibling info to virsh capabilities



Hi,

Would it be possible to augment the output produced in virsh
capabilities to also provide the hyperthreaded sibling of a processor?
For example the information would look something like:


    <topology>

      <cells num='2'>
        <cell id='0'>
          <cpus num='8'>
            <cpu id='1' sibling='9'/>
            <cpu id='3' sibling='11'/>
            <cpu id='5' sibling='13'/>
            <cpu id='7' sibling='15'/>
            <cpu id='9' sibling='`1'/>
            <cpu id='11' sibling='3'/>
            <cpu id='13' sibling='5'/>
            <cpu id='15' sibling='7'/>
          </cpus>
        </cell>
        <cell id='1'>
          <cpus num='8'>
            <cpu id='0' sibling='8'/>
            <cpu id='2' sibling='10'/>
            <cpu id='4' sibling='12'/>
            <cpu id='6' sibling='14'/>
            <cpu id='8' sibling='0'/>
            <cpu id='10' sibling='2'/>
            <cpu id='12' sibling='4'/>
            <cpu id='14' sibling='6'/>
          </cpus>
        </cell>
      </cells>
    </topology>


I notice that you guys are actually using some of the numactl stuff
(numa.h) to query for the cpus on a given node and I have combed
through that code to see if it provided any info about hyperthreaded
siblings but from what I can tell it does not. I have tinkered around
with the hwloc libraries (http://www.open-mpi.org/projects/hwloc/) and
have written a short program to print out each logical cpu and its
hyperthreaded sibling (see attached)


The output from it looks like so:

[root hostname ~]# ./a.out
*** PU:  0    Hyperthreaded Sibling:  8
*** PU:  8    Hyperthreaded Sibling:  0
*** PU:  2    Hyperthreaded Sibling: 10
*** PU: 10    Hyperthreaded Sibling:  2
*** PU:  4    Hyperthreaded Sibling: 12
*** PU: 12    Hyperthreaded Sibling:  4
*** PU:  6    Hyperthreaded Sibling: 14
*** PU: 14    Hyperthreaded Sibling:  6
*** PU:  1    Hyperthreaded Sibling:  9
*** PU:  9    Hyperthreaded Sibling:  1
*** PU:  3    Hyperthreaded Sibling: 11
*** PU: 11    Hyperthreaded Sibling:  3
*** PU:  5    Hyperthreaded Sibling: 13
*** PU: 13    Hyperthreaded Sibling:  5
*** PU:  7    Hyperthreaded Sibling: 15
*** PU: 15    Hyperthreaded Sibling:  7

Would you guys ever consider adding something like this? I would be
willing to help create a patch if I had some guidance.


Thanks for your time,


Dusty Mabe
#include <hwloc.h>

// My system: 
// # rpm -qa hwloc hwloc-devel
// hwloc-1.1-0.1.el6.x86_64
// hwloc-devel-1.1-0.1.el6.x86_64
//
// Command used to build
// gcc -g file.c -lhwloc

int main(void)
{
    hwloc_topology_t topology;
    hwloc_obj_t obj, obj2;
    hwloc_topology_init(&topology);
    hwloc_topology_load(topology);


    // Get first PU in system
    obj = hwloc_get_obj_by_type(topology, HWLOC_OBJ_PU, 0);

    // Iterate through all PUs
    while (obj) {
        printf("*** PU: %2u PU", obj->os_index); 
    
        // Get the hyperthreaded sibling
        obj2 = obj->next_sibling;
        if (!obj2)
            obj2 = obj->prev_sibling; 

        //Print the number of the sibling 
        printf("\t Hyperthreaded Sibling: %2u \n", obj2->os_index); 

        // Get the next PU in the system
        obj = hwloc_get_next_obj_by_type(topology, HWLOC_OBJ_PU, obj);
    }


    /* Destroy topology object. */
    hwloc_topology_destroy(topology);

    return 0;
}

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