summaryrefslogtreecommitdiffstats
path: root/src/vppinfra/vec_bootstrap.h
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2020-01-21 12:34:55 -0500
committerFlorin Coras <florin.coras@gmail.com>2020-02-05 23:38:56 +0000
commita690fdbfe179e0ea65818c03b52535bf9210efd0 (patch)
tree345200955b873dbc2f5bb6857b1acc7966ffed90 /src/vppinfra/vec_bootstrap.h
parent86e8bce44f43c1f3c50a3397f9ab850f484f4cad (diff)
vppinfra: numa vector placement support
Type: feature Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: I7e7d95a089dd849c1f01ecea84529d8dbf239f21
Diffstat (limited to 'src/vppinfra/vec_bootstrap.h')
-rw-r--r--src/vppinfra/vec_bootstrap.h32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/vppinfra/vec_bootstrap.h b/src/vppinfra/vec_bootstrap.h
index fbb01b685ca..879703c8f6a 100644
--- a/src/vppinfra/vec_bootstrap.h
+++ b/src/vppinfra/vec_bootstrap.h
@@ -58,11 +58,14 @@ typedef struct
u64 len;
#else
u32 len; /**< Number of elements in vector (NOT its allocated length). */
- u32 dlmalloc_header_offset; /**< offset to memory allocator offset */
+ u8 numa_id; /**< NUMA id */
+ u8 vpad[3]; /**< pad to 8 bytes */
#endif
u8 vector_data[0]; /**< Vector data . */
} vec_header_t;
+#define VEC_NUMA_UNSPECIFIED (0xFF)
+
/** \brief Find the vector header
Given the user's pointer to a vector, find the corresponding
@@ -128,7 +131,7 @@ vec_aligned_header_end (void *v, uword header_bytes, uword align)
/** \brief Number of elements in vector (lvalue-capable)
- _vec_len (v) does not check for null, but can be used as a lvalue
+ _vec_len (v) does not check for null, but can be used as an lvalue
(e.g. _vec_len (v) = 99).
*/
@@ -142,6 +145,20 @@ vec_aligned_header_end (void *v, uword header_bytes, uword align)
#define vec_len(v) ((v) ? _vec_len(v) : 0)
+/** \brief Vector's NUMA id (lvalue-capable)
+
+ _vec_numa(v) does not check for null, but can be used as an lvalue
+ (e.g. _vec_numa(v) = 1).
+*/
+
+#define _vec_numa(v) (_vec_find(v)->numa_id)
+
+/** \brief Return vector's NUMA ID (rvalue-only, NULL tolerant)
+ vec_numa(v) checks for NULL, but cannot be used as an lvalue.
+*/
+#define vec_numa(v) ((v) ? _vec_numa(v) : 0)
+
+
/** \brief Number of data bytes in vector. */
#define vec_bytes(v) (vec_len (v) * sizeof (v[0]))
@@ -208,6 +225,17 @@ for (var = vec_end (vec) - 1; var >= (vec); var--)
#define vec_foreach_index_backwards(var,v) \
for ((var) = vec_len((v)) - 1; (var) >= 0; (var)--)
+/** \brief return the NUMA index for a vector */
+always_inline uword
+vec_get_numa (void *v)
+{
+ vec_header_t *vh;
+ if (v == 0)
+ return 0;
+ vh = _vec_find (v);
+ return vh->numa_id;
+}
+
#endif /* included_clib_vec_bootstrap_h */
/*