From 039d547f6f1b7fe4b96cc22ac5a6ef8d18d5cf97 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 2 Feb 2021 12:56:06 -0500 Subject: lib: Differentiate between real and cpu bound processes When generating SLOW_THREAD warnings let's differentiate between a cpu bound process and a wall bound process. Effectively a slow thread can now be a process in FRR doing lots of work( cpu bound ) or wall bound ( the cpu is heavy load and a FRR process may be pre-empted and never scheduled ). Signed-off-by: Donald Sharp --- lib/thread.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'lib/thread.c') diff --git a/lib/thread.c b/lib/thread.c index 866090341..7a3d50419 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -1850,15 +1850,29 @@ void thread_call(struct thread *thread) memory_order_seq_cst); #ifdef CONSUMED_TIME_CHECK - if (realtime > CONSUMED_TIME_CHECK) { + if (cputime > CONSUMED_TIME_CHECK) { /* - * We have a CPU Hog on our hands. + * We have a CPU Hog on our hands. The time FRR + * has spent doing actual work ( not sleeping ) + * is greater than 5 seconds. * Whinge about it now, so we're aware this is yet another task * to fix. */ flog_warn( - EC_LIB_SLOW_THREAD, - "SLOW THREAD: task %s (%lx) ran for %lums (cpu time %lums)", + EC_LIB_SLOW_THREAD_CPU, + "CPU HOG: task %s (%lx) ran for %lums (cpu time %lums)", + thread->xref->funcname, (unsigned long)thread->func, + realtime / 1000, cputime / 1000); + } else if (realtime > CONSUMED_TIME_CHECK) { + /* + * The runtime for a task is greater than 5 seconds, but + * the cpu time is under 5 seconds. Let's whine + * about this because this could imply some sort of + * scheduling issue. + */ + flog_warn( + EC_LIB_SLOW_THREAD_WALL, + "STARVATION: task %s (%lx) ran for %lums (cpu time %lums)", thread->xref->funcname, (unsigned long)thread->func, realtime / 1000, cputime / 1000); } -- cgit v1.2.3