[dpdk-dev] Get the socket id

Stephen Hemminger stephen at networkplumber.org
Wed Aug 7 17:52:41 CEST 2013


On Wed, 7 Aug 2013 14:14:19 +0800 (CST)
dvr <jinxiu.1006 at 163.com> wrote:

> hi,
>    all
>    I'm confused with the following code(Eal_memory.c in lib\librte_eal\linuxapp\eal directory, LINE 373):
>  
>    nodestr = strstr(buf," N");
>    if(nodestr == NULL) {...}
>    nodestr += 2;
>    end = strstr(nodestr,"=");
>    if(end == NULL) {...}
>    // here nodestr = "0=1"
>    end[0] = '\0';
>    end = NULL;
>   // here nodestr = "0"
>    socket_id = strtoul(nodestr,&end,0);
>  
>    Through "printf", I know that:
>    buf = "00200000 default file=/mnt/dpdk/huge/rtemap_1 huge dirty=1 N0=1"
>    And finally socket_id=0
>    My question is :why we get the socket_id before "=" instead of after "=" ?
>    and if we want to get the character after "N", isn't this code too complex?
>  
>    I will be very appreciate for any help.
>    Regards!
>  
> Maria
>   

Good question.

The best reference for the kernel proc files is usually in the Linux
kernel source Documentation directory. But can't find any documentation
on numa_maps in detail.

Inside kernel VM, there is an array of numa_maps for each process.
The two parts of NX=Y are:
   X => the numa map index
   Y => the numa node associated with that map

Therefore it is possible to have multiple entries, like:
 "00200000 default file=/myfile dirty=1 N0=1 N1=2"
if the the memory region crosses multiple NUMA nodes.
Since huge pages are pinned to numa node, you won't see that for them.
Basically if "huge" is in the line only one NX=Y entry will be present;
and the X part is unimportant.



More information about the dev mailing list