summaryrefslogtreecommitdiffstats
path: root/src/vlib
diff options
context:
space:
mode:
authorhsandid <halsandi@cisco.com>2023-12-20 15:41:54 +0100
committerDamjan Marion <dmarion@0xa5.net>2023-12-22 15:45:07 +0000
commit832342e3a4c25520ea95b4bac9402798832dfaf2 (patch)
treef5649e92c130af41fbd9962faa40b1076e8f3b43 /src/vlib
parentccc17f0a70918ae0f6e94037101718786702295c (diff)
vlib: add error checks to thread pinning
Type: fix Added error checks around pthread_setaffinity_np calls to stop vpp launch if pinning fails. Change-Id: Iec391c485d1832b6c2ff20fbf789608f6bcf7b57 Signed-off-by: hsandid <halsandi@cisco.com>
Diffstat (limited to 'src/vlib')
-rw-r--r--src/vlib/threads.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/vlib/threads.c b/src/vlib/threads.c
index 4b70642d3cb..7e6ac25f109 100644
--- a/src/vlib/threads.c
+++ b/src/vlib/threads.c
@@ -222,7 +222,12 @@ vlib_thread_init (vlib_main_t * vm)
cpu_set_t cpuset;
CPU_ZERO (&cpuset);
CPU_SET (tm->main_lcore, &cpuset);
- pthread_setaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset);
+ if (pthread_setaffinity_np (pthread_self (), sizeof (cpu_set_t),
+ &cpuset))
+ {
+ return clib_error_return (0, "could not pin main thread to cpu %u",
+ tm->main_lcore);
+ }
}
/* Set up thread 0 */
@@ -304,7 +309,8 @@ vlib_thread_init (vlib_main_t * vm)
if (c == ~0)
return clib_error_return (0,
"no available cpus to be used for"
- " the '%s' thread", tr->name);
+ " the '%s' thread #%u",
+ tr->name, tr->count);
avail_cpu = clib_bitmap_set (avail_cpu, 0, avail_c0);
avail_cpu = clib_bitmap_set (avail_cpu, c, 0);
@@ -801,25 +807,26 @@ start_workers (vlib_main_t * vm)
{
for (j = 0; j < tr->count; j++)
{
+
w = vlib_worker_threads + worker_thread_index++;
err = vlib_launch_thread_int (vlib_worker_thread_bootstrap_fn,
w, 0);
if (err)
- clib_error_report (err);
+ clib_unix_error ("%U, thread %s init on cpu %d failed",
+ format_clib_error, err, tr->name, 0);
}
}
else
{
uword c;
- /* *INDENT-OFF* */
clib_bitmap_foreach (c, tr->coremask) {
w = vlib_worker_threads + worker_thread_index++;
err = vlib_launch_thread_int (vlib_worker_thread_bootstrap_fn,
w, c);
if (err)
- clib_error_report (err);
- }
- /* *INDENT-ON* */
+ clib_unix_error ("%U, thread %s init on cpu %d failed",
+ format_clib_error, err, tr->name, c);
+ }
}
}
vlib_worker_thread_barrier_sync (vm);