]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: sched: make sched->task_list_size atomic
authorWilly Tarreau <w@1wt.eu>
Tue, 30 Jun 2020 09:48:48 +0000 (11:48 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 1 Jul 2020 14:35:41 +0000 (16:35 +0200)
We'll need to update it from foreign threads in order to throw killed
tasks and maintain correct accounting, so let's make it atomic.

src/task.c

index 9f2e9d5df6cf4bf49208b1db8d50521f34a4040b..b65000b8f3a6e1d79e18b155f56802a22411fc0e 100644 (file)
@@ -405,7 +405,7 @@ unsigned int run_tasks_from_lists(unsigned int budgets[])
 
                /* OK then this is a regular task */
 
-               task_per_thread[tid].task_list_size--;
+               _HA_ATOMIC_SUB(&task_per_thread[tid].task_list_size, 1);
                if (unlikely(t->call_date)) {
                        uint64_t now_ns = now_mono_time();
 
@@ -585,7 +585,7 @@ void process_runnable_tasks()
                /* And add it to the local task list */
                tasklet_insert_into_tasklet_list(&tt->tasklets[TL_NORMAL], (struct tasklet *)t);
                tt->tl_class_mask |= 1 << TL_NORMAL;
-               tt->task_list_size++;
+               _HA_ATOMIC_ADD(&tt->task_list_size, 1);
                activity[tid].tasksw++;
        }