aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra
diff options
context:
space:
mode:
Diffstat (limited to 'src/vppinfra')
-rw-r--r--src/vppinfra/unix-misc.c24
-rw-r--r--src/vppinfra/unix.h6
2 files changed, 30 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
*
diff --git a/src/vppinfra/unix.h b/src/vppinfra/unix.h
index 5b82c23a3c0..b43043a567b 100644
--- a/src/vppinfra/unix.h
+++ b/src/vppinfra/unix.h
@@ -53,6 +53,12 @@ clib_error_t *clib_file_contents (char *file, u8 ** result);
/* As above but for /proc file system on Linux. */
clib_error_t *unix_proc_file_contents (char *file, u8 ** result);
+/* Retrieve bitmap of online cpu cures */
+clib_bitmap_t *os_get_online_cpu_core_bitmap ();
+
+/* Retrieve bitmap of online cpu nodes (sockets) */
+clib_bitmap_t *os_get_online_cpu_node_bitmap ();
+
#endif /* included_clib_unix_h */
/*