]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: tasks: Add a flag that tells if we're in the global runqueue.
authorOlivier Houchard <ohouchard@haproxy.com>
Thu, 26 Jul 2018 14:19:58 +0000 (16:19 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 26 Jul 2018 14:33:10 +0000 (16:33 +0200)
How that we have bits available in task->state, add a flag that tells if we're
in the global runqueue or not.

include/proto/task.h
include/types/task.h
src/task.c

index 8aceee508bbf07ccc45d5066c06e23924e5f45ee..3969dc30ce3a6b4e7d036fefffaa59e3cd7ed1b8 100644 (file)
@@ -181,6 +181,8 @@ static inline struct task *__task_unlink_rq(struct task *t)
 {
        HA_ATOMIC_SUB(&tasks_run_queue, 1);
        eb32sc_delete(&t->rq);
+       if (t->state & TASK_GLOBAL)
+               HA_ATOMIC_AND(&t->state, ~TASK_GLOBAL);
        if (likely(t->nice))
                HA_ATOMIC_SUB(&niced_tasks, 1);
        return t;
index c001d45e218a4b956c575294121b25cfce243a49..bc64f43f5820c82e9106926b8afa9cb9b751ae03 100644 (file)
@@ -32,6 +32,7 @@
 /* values for task->state */
 #define TASK_SLEEPING     0x0000  /* task sleeping */
 #define TASK_RUNNING      0x0001  /* the task is currently running */
+#define TASK_GLOBAL       0x0002  /* The task is currently in the global runqueue */
 
 #define TASK_WOKEN_INIT   0x0100  /* woken up for initialisation purposes */
 #define TASK_WOKEN_TIMER  0x0200  /* woken up because of expired timer */
index df2435a713699e0c966389eead555b6c255fb6b4..94482ecf157635e9c329590db44dbe0104a394be 100644 (file)
@@ -143,6 +143,7 @@ redo:
 #ifdef USE_THREAD
        if (root == &rqueue) {
                global_rqueue_size++;
+               HA_ATOMIC_OR(&t->state, TASK_GLOBAL);
                HA_SPIN_UNLOCK(TASK_RQ_LOCK, &rq_lock);
        } else
 #endif