From 4a06846dd668d7f687e6770215c38e8feb5f1740 Mon Sep 17 00:00:00 2001 From: Jon Loeliger Date: Fri, 31 Jan 2020 13:34:56 -0600 Subject: [PATCH] vlib: Skip core 0 if workers are configured. According to the description in the startup.conf, the assignment of worker threads starts with the lcore following the main_lcore. A non-zero skip_cores will correctly achieve this assignment. However, prior to this patch when workers are assigned, the code picks up and assigns core 0 even thought it shouldn't. This patch determins if a non-zero number of workers are desired and if so, marks CPU unavailable for a worker assignment. Type: fix Change-Id: I1fdf73a6f218dcbf146fda2efc90c553f7cd6d20 Signed-off-by: Jon Loeliger --- src/vlib/threads.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/vlib/threads.c b/src/vlib/threads.c index d9d781070a3..b2a2f6939e6 100644 --- a/src/vlib/threads.c +++ b/src/vlib/threads.c @@ -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); -- 2.16.6