]> git.proxmox.com Git - mirror_frr.git/commitdiff
*: Convert thread_should_yield and thread_set_yield_time
authorDonald Sharp <sharpd@nvidia.com>
Sun, 11 Dec 2022 15:39:12 +0000 (10:39 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Fri, 24 Mar 2023 12:32:17 +0000 (08:32 -0400)
Convert thread_should_yield and thread_set_yield_time
to event_should_yield and event_set_yield_time

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
lib/event.c
lib/event.h
lib/workqueue.c
ospfd/ospf_lsa.c
tests/lib/test_heavy_thread.c
zebra/zebra_fpm.c

index 8355b3cdd4de63e848fd72c8e2c2013dda1446d6..59f8928d1b2a1033ffee3d735d4ba5097aac4440 100644 (file)
@@ -1910,7 +1910,7 @@ unsigned long thread_consumed_time(RUSAGE_T *now, RUSAGE_T *start,
    for CPU time.  On balance, wall clock time seems to make sense.
    Plus it has the added benefit that gettimeofday should be faster
    than calling getrusage. */
-int thread_should_yield(struct event *thread)
+int event_should_yield(struct event *thread)
 {
        int result;
        frr_with_mutex (&thread->mtx) {
@@ -1920,7 +1920,7 @@ int thread_should_yield(struct event *thread)
        return result;
 }
 
-void thread_set_yield_time(struct event *thread, unsigned long yield_time)
+void event_set_yield_time(struct event *thread, unsigned long yield_time)
 {
        frr_with_mutex (&thread->mtx) {
                thread->yield = yield_time;
index 68f97bb8524b0a9117721d000aef9801313e4a3f..03d7d6d192c82b1d739b9019599e20ea6c834546 100644 (file)
@@ -254,9 +254,9 @@ extern void event_call(struct event *event);
 extern unsigned long event_timer_remain_second(struct event *event);
 extern struct timeval event_timer_remain(struct event *event);
 extern unsigned long event_timer_remain_msec(struct event *event);
-extern int thread_should_yield(struct event *event);
+extern int event_should_yield(struct event *event);
 /* set yield time for thread */
-extern void thread_set_yield_time(struct event *event, unsigned long);
+extern void event_set_yield_time(struct event *event, unsigned long);
 
 /* Internal libfrr exports */
 extern void thread_getrusage(RUSAGE_T *);
index b63dafd7e9a854cc1bf135a6815ae3c29075b3fd..7660663449a655f09e144c7208a6424a092cd06f 100644 (file)
@@ -128,7 +128,7 @@ static int work_queue_schedule(struct work_queue *wq, unsigned int delay)
                /* set thread yield time, if needed */
                if (thread_is_scheduled(wq->thread) &&
                    wq->spec.yield != EVENT_YIELD_TIME_SLOT)
-                       thread_set_yield_time(wq->thread, wq->spec.yield);
+                       event_set_yield_time(wq->thread, wq->spec.yield);
                return 1;
        } else
                return 0;
@@ -311,8 +311,8 @@ void work_queue_run(struct event *thread)
                cycles++;
 
                /* test if we should yield */
-               if (!(cycles % wq->cycles.granularity)
-                   && thread_should_yield(thread)) {
+               if (!(cycles % wq->cycles.granularity) &&
+                   event_should_yield(thread)) {
                        yielded = 1;
                        goto stats;
                }
index ea5dc651acd0646611b44b88002bb5f480d6b41f..1c5d1bddf82f1bb410dc681c7f8311bcc984ad3a 100644 (file)
@@ -3074,7 +3074,7 @@ void ospf_maxage_lsa_remover(struct event *thread)
                        }
 
                        /* TODO: maybe convert this function to a work-queue */
-                       if (thread_should_yield(thread)) {
+                       if (event_should_yield(thread)) {
                                OSPF_TIMER_ON(ospf->t_maxage,
                                              ospf_maxage_lsa_remover, 0);
                                route_unlock_node(
index 9084bf55eb258ef63ecabf1d4872455a9621aaab..fd8e910fd5d076e1aab0f03cb1f25450f1b8fe20 100644 (file)
@@ -67,7 +67,7 @@ static void clear_something(struct event *thread)
        while (ws->i < ITERS_MAX) {
                slow_func(ws->vty, ws->str, ws->i);
                ws->i++;
-               if (thread_should_yield(thread)) {
+               if (event_should_yield(thread)) {
                        event_add_timer_msec(master, clear_something, ws, 0,
                                             NULL);
                        return;
index a97873c3848344dd6e6b6fa416d7841d81d6f764..d453c6f25c20a43e667d0f32fc62177735ca738b 100644 (file)
@@ -285,7 +285,7 @@ union g_addr ipv4ll_gateway;
  */
 static inline int zfpm_thread_should_yield(struct event *t)
 {
-       return thread_should_yield(t);
+       return event_should_yield(t);
 }
 
 /*