]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: task: move the niced_tasks counter to the thread group context
authorWilly Tarreau <w@1wt.eu>
Thu, 7 Jul 2022 13:25:40 +0000 (15:25 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 15 Jul 2022 17:43:10 +0000 (19:43 +0200)
This one is only used as a hint to improve scheduling latency, so there
is no more point in keeping it global since each thread group handles
its own run q

include/haproxy/task.h
include/haproxy/tinfo-t.h
src/task.c

index 9bb09a486431e548ddb8d24c68fa31bfc86682a7..2f3fe3d2994d35cc1c2b462d5d07f90709b6a5d5 100644 (file)
@@ -88,8 +88,6 @@
 
 
 /* a few exported variables */
-extern unsigned int niced_tasks;  /* number of niced tasks in the run queue */
-
 extern struct pool_head *pool_head_task;
 extern struct pool_head *pool_head_tasklet;
 extern struct pool_head *pool_head_notification;
index 6df31f117a84b1817ade0082f1a2a632e070b96f..3a6570e48da5836e0020dc18054c7a945da2348c 100644 (file)
@@ -73,6 +73,8 @@ struct tgroup_ctx {
        HA_RWLOCK_T wq_lock;              /* RW lock related to the wait queue below */
        struct eb_root timers;            /* wait queue (sorted timers tree, global, accessed under wq_lock) */
 
+       uint niced_tasks;                 /* number of niced tasks in this group's run queues */
+
        /* pad to cache line (64B) */
        char __pad[0];                    /* unused except to check remaining room */
        char __end[0] __attribute__((aligned(64)));
index 11a1b2ccd2c6b70b104b9d0348de4e28dc537d3c..0399a711014bb2c9ecb06547c271dab6aa257a2e 100644 (file)
@@ -34,8 +34,6 @@ DECLARE_POOL(pool_head_tasklet, "tasklet", sizeof(struct tasklet));
  */
 DECLARE_POOL(pool_head_notification, "notification", sizeof(struct notification));
 
-unsigned int niced_tasks = 0;      /* number of niced tasks in the run queue */
-
 
 /* Flags the task <t> for immediate destruction and puts it into its first
  * thread's shared tasklet list if not yet queued/running. This will bypass
@@ -229,7 +227,7 @@ void __task_wakeup(struct task *t)
        if (likely(t->nice)) {
                int offset;
 
-               _HA_ATOMIC_INC(&niced_tasks);
+               _HA_ATOMIC_INC(&tg_ctx->niced_tasks);
                offset = t->nice * (int)global.tune.runqueue_depth;
                t->rq.key += offset;
        }
@@ -736,7 +734,7 @@ void process_runnable_tasks()
 
        max_processed = global.tune.runqueue_depth;
 
-       if (likely(niced_tasks))
+       if (likely(tg_ctx->niced_tasks))
                max_processed = (max_processed + 3) / 4;
 
        if (max_processed < th_ctx->rq_total && th_ctx->rq_total <= 2*max_processed) {
@@ -849,7 +847,7 @@ void process_runnable_tasks()
                }
 #endif
                if (t->nice)
-                       _HA_ATOMIC_DEC(&niced_tasks);
+                       _HA_ATOMIC_DEC(&tg_ctx->niced_tasks);
 
                /* Add it to the local task list */
                LIST_APPEND(&tt->tasklets[TL_NORMAL], &((struct tasklet *)t)->list);