]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib, zebra: Add ability to tell thread system to ignore late timers 8011/head
authorDonald Sharp <sharpd@nvidia.com>
Wed, 19 Jan 2022 19:56:25 +0000 (14:56 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Thu, 20 Jan 2022 16:58:48 +0000 (11:58 -0500)
Add a thread_ignore_late_timer(struct thread *thread) function
that allows thread.c to ignore when timers are late to the party.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
lib/thread.c
lib/thread.h
lib/workqueue.c
zebra/interface.c

index 73e0e4887c32c6c64130d177b58b5c37d83be66a..376f61c247b578e5b6d691510c6302a62e1fad07 100644 (file)
@@ -787,6 +787,7 @@ static struct thread *thread_get(struct thread_master *m, uint8_t type,
        thread->arg = arg;
        thread->yield = THREAD_YIELD_TIME_SLOT; /* default */
        thread->ref = NULL;
+       thread->ignore_timer_late = false;
 
        /*
         * So if the passed in funcname is not what we have
@@ -1667,12 +1668,12 @@ static unsigned int thread_process_timers(struct thread_master *m,
                 * really getting behind on handling of events.
                 * Let's log it and do the right thing with it.
                 */
-               if (timercmp(timenow, &prev, >)) {
-                       if (!displayed)
-                               flog_warn(
-                                       EC_LIB_STARVE_THREAD,
-                                       "Thread Starvation: %pTHD was scheduled to pop greater than 4s ago",
-                                       thread);
+               if (!displayed && !thread->ignore_timer_late &&
+                   timercmp(timenow, &prev, >)) {
+                       flog_warn(
+                               EC_LIB_STARVE_THREAD,
+                               "Thread Starvation: %pTHD was scheduled to pop greater than 4s ago",
+                               thread);
                        displayed = true;
                }
 
index 49a70696d0d8ad8a27787783f8e117b36bade322..660f8bd28e9d0daf63c140da2ca65aea734ebcea 100644 (file)
@@ -126,6 +126,7 @@ struct thread {
        unsigned long yield;             /* yield time in microseconds */
        const struct xref_threadsched *xref;   /* origin location */
        pthread_mutex_t mtx;   /* mutex for thread.c functions */
+       bool ignore_timer_late;
 };
 
 #ifdef _FRR_ATTRIBUTE_PRINTFRR
@@ -285,6 +286,11 @@ extern bool thread_is_scheduled(struct thread *thread);
 /* Debug signal mask */
 void debug_signals(const sigset_t *sigs);
 
+static inline void thread_ignore_late_timer(struct thread *thread)
+{
+       thread->ignore_timer_late = true;
+}
+
 #ifdef __cplusplus
 }
 #endif
index 2a8326c056d5db34e2f7bc62a8c2646ccbbe25d2..86afe4082ecc9e9c49df4d91e5785ee098351ffe 100644 (file)
@@ -135,10 +135,11 @@ static int work_queue_schedule(struct work_queue *wq, unsigned int delay)
                /* Schedule timer if there's a delay, otherwise just schedule
                 * as an 'event'
                 */
-               if (delay > 0)
+               if (delay > 0) {
                        thread_add_timer_msec(wq->master, work_queue_run, wq,
                                              delay, &wq->thread);
-               else
+                       thread_ignore_late_timer(wq->thread);
+               } else
                        thread_add_event(wq->master, work_queue_run, wq, 0,
                                         &wq->thread);
 
index 8b5dbabb929247cec8406492993acb5c3fbb1310..534953d903ef29b2f31e8fb65c9741d31ae772a0 100644 (file)
@@ -91,9 +91,12 @@ static int if_zebra_speed_update(struct thread *thread)
                changed = true;
        }
 
-       if (changed || new_speed == UINT32_MAX)
+       if (changed || new_speed == UINT32_MAX) {
                thread_add_timer(zrouter.master, if_zebra_speed_update, ifp, 5,
                                 &zif->speed_update);
+               thread_ignore_late_timer(zif->speed_update);
+       }
+
        return 1;
 }
 
@@ -187,6 +190,8 @@ static int if_zebra_new_hook(struct interface *ifp)
         */
        thread_add_timer(zrouter.master, if_zebra_speed_update, ifp, 15,
                         &zebra_if->speed_update);
+       thread_ignore_late_timer(zebra_if->speed_update);
+
        return 0;
 }
 
@@ -1074,6 +1079,7 @@ void if_up(struct interface *ifp)
 
        thread_add_timer(zrouter.master, if_zebra_speed_update, ifp, 0,
                         &zif->speed_update);
+       thread_ignore_late_timer(zif->speed_update);
 }
 
 /* Interface goes down.  We have to manage different behavior of based