aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra/unix-misc.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2024-02-29 16:14:27 +0100
committerBeno�t Ganne <bganne@cisco.com>2024-03-04 08:53:08 +0000
commit4b6614030f384f7c8d847360cacf5c7f7560c6be (patch)
treeb560c46a2cda2bf6b16e147a52a70ed83c3ce1ce /src/vppinfra/unix-misc.c
parent2921e0234185f615d7530343b340573e2cb5caec (diff)
vppinfra: add os_get_online_cpu_core() and os_get_online_cpu_node()
Type: improvement Change-Id: I6f99f09c7724ce656a4f41a1d5f9c88d74c00faf Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vppinfra/unix-misc.c')
-rw-r--r--src/vppinfra/unix-misc.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/vppinfra/unix-misc.c b/src/vppinfra/unix-misc.c
index 6a7328bd873..623b2e98555 100644
--- a/src/vppinfra/unix-misc.c
+++ b/src/vppinfra/unix-misc.c
@@ -37,8 +37,12 @@
#include <vppinfra/error.h>
#include <vppinfra/os.h>
+#include <vppinfra/bitmap.h>
#include <vppinfra/unix.h>
#include <vppinfra/format.h>
+#ifdef __linux__
+#include <vppinfra/linux/sysfs.h>
+#endif
#include <sys/stat.h>
#include <sys/types.h>
@@ -260,6 +264,26 @@ os_get_nthreads (void)
return 1;
}
+__clib_export clib_bitmap_t *
+os_get_online_cpu_core_bitmap ()
+{
+#if __linux__
+ return clib_sysfs_list_to_bitmap ("/sys/devices/system/cpu/online");
+#else
+ return 0;
+#endif
+}
+
+__clib_export clib_bitmap_t *
+os_get_online_cpu_node_bitmap ()
+{
+#if __linux__
+ return clib_sysfs_list_to_bitmap ("/sys/devices/system/node/online");
+#else
+ return 0;
+#endif
+}
+
/*
* fd.io coding-style-patch-verification: ON
*