MEDIUM: tasklets: Make the tasklet list a struct mt_list.

Change the tasklet code so that the tasklet list is now a mt_list.
That means that tasklet now do have an associated tid, for the thread it
is expected to run on, and any thread can now call tasklet_wakeup() for
that tasklet.
One can change the associated tid with tasklet_set_tid().
diff --git a/src/checks.c b/src/checks.c
index b879100..6bde412 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -1638,6 +1638,8 @@
 	conn = cs->conn;
 	/* Maybe there were an older connection we were waiting on */
 	check->wait_list.events = 0;
+	tasklet_set_tid(check->wait_list.tasklet, tid);
+
 
 	if (!sockaddr_alloc(&conn->dst))
 		return SF_ERR_RESOURCE;
@@ -2891,6 +2893,8 @@
 				cs_destroy(check->cs);
 			}
 
+			tasklet_set_tid(check->wait_list.tasklet, tid);
+
 			check->cs = cs;
 			conn = cs->conn;
 			/* Maybe there were an older connection we were waiting on */
diff --git a/src/debug.c b/src/debug.c
index 409bd2c..a2b99c9 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -57,7 +57,7 @@
 	              !!(global_tasks_mask & thr_bit),
 	              !eb_is_empty(&task_per_thread[thr].timers),
 	              !eb_is_empty(&task_per_thread[thr].rqueue),
-	              !LIST_ISEMPTY(&task_per_thread[thr].task_list),
+	              !MT_LIST_ISEMPTY(&task_per_thread[thr].task_list),
 	              task_per_thread[thr].task_list_size,
 	              task_per_thread[thr].rqueue_size,
 	              stuck,
diff --git a/src/task.c b/src/task.c
index dfec419..9aa7646 100644
--- a/src/task.c
+++ b/src/task.c
@@ -368,9 +368,11 @@
 		}
 #endif
 
+		/* Make sure the entry doesn't appear to be in a list */
+		MT_LIST_INIT(&((struct tasklet *)t)->list);
 		/* And add it to the local task list */
 		tasklet_insert_into_tasklet_list((struct tasklet *)t);
-		task_per_thread[tid].task_list_size++;
+		HA_ATOMIC_ADD(&task_per_thread[tid].task_list_size, 1);
 		activity[tid].tasksw++;
 	}
 
@@ -380,18 +382,19 @@
 		grq = NULL;
 	}
 
-	while (max_processed > 0 && !LIST_ISEMPTY(&task_per_thread[tid].task_list)) {
+	while (max_processed > 0 && !MT_LIST_ISEMPTY(&task_per_thread[tid].task_list)) {
 		struct task *t;
 		unsigned short state;
 		void *ctx;
 		struct task *(*process)(struct task *t, void *ctx, unsigned short state);
 
-		t = (struct task *)LIST_ELEM(task_per_thread[tid].task_list.n, struct tasklet *, list);
+		t = (struct task *)MT_LIST_POP(&task_per_thread[tid].task_list, struct tasklet *, list);
+		if (!t)
+			break;
 		state = _HA_ATOMIC_XCHG(&t->state, TASK_RUNNING);
 		__ha_barrier_atomic_store();
-		__tasklet_remove_from_tasklet_list((struct tasklet *)t);
 		if (!TASK_IS_TASKLET(t))
-			task_per_thread[tid].task_list_size--;
+			_HA_ATOMIC_SUB(&task_per_thread[tid].task_list_size, 1);
 
 		ti->flags &= ~TI_FL_STUCK; // this thread is still running
 		activity[tid].ctxsw++;
@@ -443,7 +446,7 @@
 		max_processed--;
 	}
 
-	if (!LIST_ISEMPTY(&task_per_thread[tid].task_list))
+	if (!MT_LIST_ISEMPTY(&task_per_thread[tid].task_list))
 		activity[tid].long_rq++;
 }
 
@@ -547,7 +550,7 @@
 #endif
 	memset(&task_per_thread, 0, sizeof(task_per_thread));
 	for (i = 0; i < MAX_THREADS; i++) {
-		LIST_INIT(&task_per_thread[i].task_list);
+		MT_LIST_INIT(&task_per_thread[i].task_list);
 	}
 }