]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: task: remove grq_total and use rq_total instead
authorWilly Tarreau <w@1wt.eu>
Thu, 16 Jun 2022 13:52:49 +0000 (15:52 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 1 Jul 2022 17:15:14 +0000 (19:15 +0200)
grq_total was only used to know how many tasks were being queued in the
global runqueue for stats purposes, and that was transferred to the per
thread rq_total counter once assigned. We don't need this anymore since
we know where they are, so let's just directly update rq_total and drop
that one.

include/haproxy/task.h
src/task.c

index de54b1ce6f5d0a84ff414c5c77c2c702749cb298..4fb1fe31cf0b463f73bb0f9a87015177776447a0 100644 (file)
@@ -90,7 +90,6 @@
 
 /* a few exported variables */
 extern volatile unsigned long global_tasks_mask; /* Mask of threads with tasks in the global runqueue */
-extern unsigned int grq_total;    /* total number of entries in the global run queue, atomic */
 extern unsigned int niced_tasks;  /* number of niced tasks in the run queue */
 
 extern struct pool_head *pool_head_task;
@@ -147,9 +146,6 @@ static inline int total_run_queues()
 {
        int thr, ret = 0;
 
-#ifdef USE_THREAD
-       ret = _HA_ATOMIC_LOAD(&grq_total);
-#endif
        for (thr = 0; thr < global.nbthread; thr++)
                ret += _HA_ATOMIC_LOAD(&ha_thread_ctx[thr].rq_total);
        return ret;
index b7678c15a47dba36f97d91a1a728009a918a5f34..f0ca126ceba4382ee35ec9350afb5dfe277ca5a4 100644 (file)
@@ -42,7 +42,6 @@ __decl_aligned_rwlock(wq_lock);   /* RW lock related to the wait queue */
 
 #ifdef USE_THREAD
 struct eb_root timers;      /* sorted timers tree, global, accessed under wq_lock */
-unsigned int grq_total;     /* total number of entries in the global run queue, atomic */
 #endif
 
 
@@ -233,7 +232,7 @@ void __task_wakeup(struct task *t)
        if (thr != tid) {
                root = &ha_thread_ctx[thr].rqueue_shared;
 
-               _HA_ATOMIC_INC(&grq_total);
+               _HA_ATOMIC_INC(&ha_thread_ctx[thr].rq_total);
                HA_SPIN_LOCK(TASK_RQ_LOCK, &ha_thread_ctx[thr].rqsh_lock);
 
                if (t->tid < 0)
@@ -897,12 +896,6 @@ void process_runnable_tasks()
        if (lpicked + gpicked) {
                tt->tl_class_mask |= 1 << TL_NORMAL;
                _HA_ATOMIC_ADD(&tt->tasks_in_list, lpicked + gpicked);
-#ifdef USE_THREAD
-               if (gpicked) {
-                       _HA_ATOMIC_SUB(&grq_total, gpicked);
-                       _HA_ATOMIC_ADD(&tt->rq_total, gpicked);
-               }
-#endif
                activity[tid].tasksw += lpicked + gpicked;
        }