From: Maria Matejka Date: Sat, 8 Jun 2024 22:43:14 +0000 (+0200) Subject: IO loop picker fixed X-Git-Tag: v3.0.0~160 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ad9c946e133c58573f153dad59bdf1f797f4000;p=thirdparty%2Fbird.git IO loop picker fixed Now if the thread finds out that it actually isn't busy, it unsets the business status and picks something up right away. --- diff --git a/sysdep/unix/io-loop.c b/sysdep/unix/io-loop.c index 9d0fa138f..236272a73 100644 --- a/sysdep/unix/io-loop.c +++ b/sysdep/unix/io-loop.c @@ -573,6 +573,7 @@ sockets_fire(struct birdloop *loop) */ static void bird_thread_start_event(void *_data); +static void bird_thread_busy_update(struct bird_thread *thr, int timeout_ms); struct birdloop_pickup_group { DOMAIN(attrs) domain; @@ -671,18 +672,16 @@ birdloop_take(struct birdloop_pickup_group *group) struct birdloop *loop = NULL; LOCK_DOMAIN(attrs, group->domain); - int drop = - this_thread->busy_active && - (group->thread_busy_count < group->thread_count) && - (this_thread->loop_count > 1); - int take = !EMPTY_LIST(group->loops); - if (drop) + if (this_thread->busy_active && + (group->thread_busy_count < group->thread_count) && + (this_thread->loop_count > 1)) { THREAD_TRACE(DL_SCHEDULING, "Loop drop requested (tbc=%d, tc=%d, lc=%d)", group->thread_busy_count, group->thread_count, this_thread->loop_count); UNLOCK_DOMAIN(attrs, group->domain); + int dropped = 0; node *n; WALK_LIST2(loop, n, this_thread->loops, n) { @@ -702,15 +701,20 @@ birdloop_take(struct birdloop_pickup_group *group) LOCK_DOMAIN(attrs, group->domain); bird_thread_pickup_next(group); UNLOCK_DOMAIN(attrs, group->domain); + dropped = 1; break; } birdloop_leave(loop); } - return; + if (dropped) + return; + + bird_thread_busy_update(this_thread, -1); + LOCK_DOMAIN(attrs, group->domain); } - if (take) + if (!EMPTY_LIST(group->loops)) { THREAD_TRACE(DL_SCHEDULING, "Loop take requested");