vlib: Skip core 0 if workers are configured.
[vpp.git] / src / vlib / threads.c
index d9d7810..b2a2f69 100644 (file)
@@ -255,6 +255,21 @@ vlib_thread_init (vlib_main_t * vm)
     }
   avail_cpu = clib_bitmap_set (avail_cpu, tm->main_lcore, 0);
 
+  /*
+   * Determine if the number of workers is greater than 0.
+   * If so, mark CPU 0 unavailable so workers will be numbered after main.
+   */
+  u32 n_workers = 0;
+  uword *p = hash_get_mem (tm->thread_registrations_by_name, "workers");
+  if (p != 0)
+    {
+      vlib_thread_registration_t *tr = (vlib_thread_registration_t *) p[0];
+      int worker_thread_count = tr->count;
+      n_workers = worker_thread_count;
+    }
+  if (tm->skip_cores == 0 && n_workers)
+    avail_cpu = clib_bitmap_set (avail_cpu, 0, 0);
+
   /* assume that there is socket 0 only if there is no data from sysfs */
   if (!tm->cpu_socket_bitmap)
     tm->cpu_socket_bitmap = clib_bitmap_set (0, 0, 1);