aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlib
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2024-02-12 19:44:58 +0000
committerMohammed HAWARI <momohawari@gmail.com>2024-03-18 16:01:35 +0000
commit3eb6cbec50a5cbe4c3465d60ba6aea7bf2845cd1 (patch)
tree0f45044087400911e213048c1967ac96a9f8ea29 /src/vlib
parent8799bf6ca6b78321049bbc397256dd8b3884d829 (diff)
vppinfra: os agnostic api for getting CPU information
Avoid direct sysfs reads when possible... Type: improvement Change-Id: I2b84cd18f3da47925d068951f24b79b5b6e20bb1 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vlib')
-rw-r--r--src/vlib/buffer.c6
-rw-r--r--src/vlib/physmem.c1
-rw-r--r--src/vlib/threads.c24
3 files changed, 8 insertions, 23 deletions
diff --git a/src/vlib/buffer.c b/src/vlib/buffer.c
index b43c1dace97..674f15d5dc6 100644
--- a/src/vlib/buffer.c
+++ b/src/vlib/buffer.c
@@ -43,7 +43,6 @@
* Allocate/free network buffers.
*/
-#include <vppinfra/linux/sysfs.h>
#include <vppinfra/bitmap.h>
#include <vppinfra/unix.h>
#include <vlib/vlib.h>
@@ -837,10 +836,7 @@ vlib_buffer_main_init (struct vlib_main_t * vm)
clib_spinlock_init (&bm->buffer_known_hash_lockp);
bmp = os_get_online_cpu_node_bitmap ();
-
- if ((err = clib_sysfs_read ("/sys/devices/system/node/has_memory", "%U",
- unformat_bitmap_list, &bmp_has_memory)))
- clib_error_free (err);
+ bmp_has_memory = os_get_cpu_with_memory_bitmap ();
if (bmp && bmp_has_memory)
bmp = clib_bitmap_and (bmp, bmp_has_memory);
diff --git a/src/vlib/physmem.c b/src/vlib/physmem.c
index c6727bb92cb..84c61d2a44f 100644
--- a/src/vlib/physmem.c
+++ b/src/vlib/physmem.c
@@ -22,7 +22,6 @@
#include <unistd.h>
#include <vppinfra/clib.h>
-#include <vppinfra/linux/sysfs.h>
#include <vlib/vlib.h>
#include <vlib/physmem.h>
#include <vlib/unix/unix.h>
diff --git a/src/vlib/threads.c b/src/vlib/threads.c
index f0cb69b3400..713e1927d1f 100644
--- a/src/vlib/threads.c
+++ b/src/vlib/threads.c
@@ -19,7 +19,6 @@
#include <vppinfra/format.h>
#include <vppinfra/time_range.h>
#include <vppinfra/interrupt.h>
-#include <vppinfra/linux/sysfs.h>
#include <vppinfra/bitmap.h>
#include <vppinfra/unix.h>
#include <vlib/vlib.h>
@@ -427,30 +426,21 @@ vlib_worker_thread_bootstrap_fn (void *arg)
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);
+ int node, core_id = -1, numa_id = -1;
+ core_id = os_get_cpu_phys_core_id (cpu_id);
nbmp = os_get_online_cpu_node_bitmap ();
+
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);
+ cbmp = os_get_cpu_on_node_bitmap (node);
+ if (clib_bitmap_get (cbmp, cpu_id))
+ numa_id = node;
+ vec_reset_length (cbmp);
}
vec_free (nbmp);
vec_free (cbmp);
- vec_free (p);
w->core_id = core_id;
w->numa_id = numa_id;