MINOR: task: move the niced_tasks counter to the thread group context
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
diff --git a/include/haproxy/task.h b/include/haproxy/task.h
index 9bb09a4..2f3fe3d 100644
--- a/include/haproxy/task.h
+++ b/include/haproxy/task.h
@@ -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;
diff --git a/include/haproxy/tinfo-t.h b/include/haproxy/tinfo-t.h
index 6df31f1..3a6570e 100644
--- a/include/haproxy/tinfo-t.h
+++ b/include/haproxy/tinfo-t.h
@@ -73,6 +73,8 @@
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)));
diff --git a/src/task.c b/src/task.c
index 11a1b2c..0399a71 100644
--- a/src/task.c
+++ b/src/task.c
@@ -34,8 +34,6 @@
*/
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 @@
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 @@
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 @@
}
#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);