]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: applets: Use a bitfield to track applets activity per-thread
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 14 Nov 2017 10:28:52 +0000 (11:28 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 16 Nov 2017 10:19:46 +0000 (11:19 +0100)
a bitfield has been added to know if there are runnable applets for a
thread. When an applet is woken up, the bits corresponding to its thread_mask
are set. When all active applets for a thread is get to be processed, the thread
is removed from active ones by unsetting its tid_bit from the bitfield.

include/proto/applet.h
src/applet.c

index 914b496f52aaabf515340b3350b670f3f00ed8fc..8024981e6ab65c231f5fe9dd72f2f22adc7363b9 100644 (file)
@@ -30,6 +30,7 @@
 #include <proto/connection.h>
 
 extern unsigned int nb_applets;
+extern unsigned long active_applets_mask;
 extern unsigned int applets_active_queue;
 __decl_hathreads(extern HA_SPINLOCK_T applet_active_lock);
 extern struct list applet_active_queue;
@@ -113,6 +114,7 @@ static inline void __appctx_wakeup(struct appctx *appctx)
        if (LIST_ISEMPTY(&appctx->runq)) {
                LIST_ADDQ(&applet_active_queue, &appctx->runq);
                applets_active_queue++;
+               active_applets_mask |= appctx->thread_mask;
        }
 }
 
index 1df6b091ea0af7f062713af4e35ba3380b33ceca..e24f66d05c01b13117a3fdf267ed385924a8b8f0 100644 (file)
@@ -21,6 +21,7 @@
 #include <proto/stream_interface.h>
 
 unsigned int nb_applets = 0;
+unsigned long active_applets_mask = 0;
 unsigned int applets_active_queue = 0;
 __decl_hathreads(HA_SPINLOCK_T applet_active_lock);  /* spin lock related to applet active queue */
 
@@ -48,7 +49,7 @@ void applet_run_active()
                }
                curr = next;
        }
-
+       active_applets_mask &= ~tid_bit;
        HA_SPIN_UNLOCK(APPLETS_LOCK, &applet_active_lock);
 
        /* The list is only scanned from the head. This guarantees that if any