aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlib
diff options
context:
space:
mode:
authorLijian.Zhang <Lijian.Zhang@arm.com>2020-02-14 15:16:49 +0800
committerLijian.Zhang <Lijian.Zhang@arm.com>2020-02-17 17:05:17 +0800
commit4fbb9daa90b53e0abaa060cf6db7762e708ce5b6 (patch)
tree73f34e6e31d095cff79c4d785e1c41dbec2ec426 /src/vlib
parent2d59f59fb9551aa1f5862529c08376e245867d18 (diff)
vlib: fix code of getting numa node with specific cpu_id
Use below sysfs files to check which numa node a specific cpu_id belongs to. /sys/devices/system/node/online /sys/devices/system/node/node0/cpulist /sys/devices/system/node/node1/cpulist Type: fix Change-Id: I124b80b1fd4a20dd7bd76f0ae27d5ab23a3a8ff1 Signed-off-by: Lijian Zhang <Lijian.Zhang@arm.com>
Diffstat (limited to 'src/vlib')
-rw-r--r--src/vlib/threads.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/vlib/threads.c b/src/vlib/threads.c
index 1ce4dc15613..3f090542118 100644
--- a/src/vlib/threads.c
+++ b/src/vlib/threads.c
@@ -598,15 +598,30 @@ void
vlib_get_thread_core_numa (vlib_worker_thread_t * w, unsigned cpu_id)
{
const char *sys_cpu_path = "/sys/devices/system/cpu/cpu";
+ const char *sys_node_path = "/sys/devices/system/node/node";
+ clib_bitmap_t *nbmp = 0, *cbmp = 0;
+ u32 node;
u8 *p = 0;
int core_id = -1, numa_id = -1;
p = format (p, "%s%u/topology/core_id%c", sys_cpu_path, cpu_id, 0);
clib_sysfs_read ((char *) p, "%d", &core_id);
vec_reset_length (p);
- p = format (p, "%s%u/topology/physical_package_id%c", sys_cpu_path,
- cpu_id, 0);
- clib_sysfs_read ((char *) p, "%d", &numa_id);
+
+ /* *INDENT-OFF* */
+ clib_sysfs_read ("/sys/devices/system/node/online", "%U",
+ unformat_bitmap_list, &nbmp);
+ clib_bitmap_foreach (node, nbmp, ({
+ p = format (p, "%s%u/cpulist%c", sys_node_path, node, 0);
+ clib_sysfs_read ((char *) p, "%U", unformat_bitmap_list, &cbmp);
+ if (clib_bitmap_get (cbmp, cpu_id))
+ numa_id = node;
+ vec_reset_length (cbmp);
+ vec_reset_length (p);
+ }));
+ /* *INDENT-ON* */
+ vec_free (nbmp);
+ vec_free (cbmp);
vec_free (p);
w->core_id = core_id;