node: ensure that vlib_node_runtime_t is cacheline sized 45/3645/1
authorDamjan Marion <damarion@cisco.com>
Tue, 1 Nov 2016 00:26:01 +0000 (01:26 +0100)
committerDamjan Marion <damarion@cisco.com>
Tue, 1 Nov 2016 00:28:00 +0000 (01:28 +0100)
Change-Id: Ib14ba63d09212a172fe52b01131404bf50cc494d
Signed-off-by: Damjan Marion <damarion@cisco.com>
vlib/vlib/node.c
vlib/vlib/node.h
vlib/vlib/node_funcs.h

index 69bb07f..fccc37a 100644 (file)
@@ -433,7 +433,10 @@ register_node (vlib_main_t * vm, vlib_node_registration_t * r)
     for (i = 0; i < vec_len (rt->errors); i++)
       rt->errors[i] = vlib_error_set (n->index, i);
 
     for (i = 0; i < vec_len (rt->errors); i++)
       rt->errors[i] = vlib_error_set (n->index, i);
 
-    ASSERT (vec_len (n->runtime_data) <= sizeof (rt->runtime_data));
+    ASSERT (sizeof (vlib_node_runtime_t) == 2 * CLIB_CACHE_LINE_BYTES);
+    ASSERT (vec_len (n->runtime_data) <= sizeof (vlib_node_runtime_t) -
+           STRUCT_OFFSET_OF (vlib_node_runtime_t, runtime_data));
+
     if (vec_len (n->runtime_data) > 0)
       clib_memcpy (rt->runtime_data, n->runtime_data,
                   vec_len (n->runtime_data));
     if (vec_len (n->runtime_data) > 0)
       clib_memcpy (rt->runtime_data, n->runtime_data,
                   vec_len (n->runtime_data));
index 795856e..b624e9d 100644 (file)
@@ -411,6 +411,7 @@ typedef struct
 
 typedef struct vlib_node_runtime_t
 {
 
 typedef struct vlib_node_runtime_t
 {
+  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
   /* Node function to call. */
   vlib_node_function_t *function;
 
   /* Node function to call. */
   vlib_node_function_t *function;
 
@@ -465,11 +466,7 @@ typedef struct vlib_node_runtime_t
   u16 cpu_index;
 
   /* Function dependent node-runtime. */
   u16 cpu_index;
 
   /* Function dependent node-runtime. */
-  uword runtime_data[(128
-                     - 1 * sizeof (vlib_node_function_t *)
-                     - 1 * sizeof (vlib_error_t *)
-                     - 11 * sizeof (u32)
-                     - 5 * sizeof (u16)) / sizeof (uword)];
+  u8 runtime_data[0];
 }
 vlib_node_runtime_t;
 
 }
 vlib_node_runtime_t;
 
index bd199fa..2116739 100644 (file)
@@ -130,7 +130,9 @@ vlib_node_set_runtime_data (vlib_main_t * vm, u32 node_index,
   vec_free (n->runtime_data);
   vec_add (n->runtime_data, runtime_data, n_runtime_data_bytes);
 
   vec_free (n->runtime_data);
   vec_add (n->runtime_data, runtime_data, n_runtime_data_bytes);
 
-  ASSERT (vec_len (n->runtime_data) <= sizeof (r->runtime_data));
+  ASSERT (vec_len (n->runtime_data) <= sizeof (vlib_node_runtime_t) -
+         STRUCT_OFFSET_OF (vlib_node_runtime_t, runtime_data));
+
   if (vec_len (n->runtime_data) > 0)
     clib_memcpy (r->runtime_data, n->runtime_data, vec_len (n->runtime_data));
 }
   if (vec_len (n->runtime_data) > 0)
     clib_memcpy (r->runtime_data, n->runtime_data, vec_len (n->runtime_data));
 }