From a17664d829e4cd08f36224a41061677b855ef5fc Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 30 Jan 2020 18:59:43 +0100 Subject: [PATCH] MEDIUM: tasks: automatically requeue into the bulk queue an already running tasklet When a tasklet re-runs itself such as in this chain: si_cs_io_cb -> si_cs_process -> si_notify -> si_chk_rcv then we know it can easily clobber the run queue and harm latency. Now what the scheduler does when it detects this is that such a tasklet is automatically placed into the bulk list so that it's processed with the remaining CPU bandwidth only. Thanks to this the CLI becomes instantly responsive again even under heavy stress at 50 Gbps over 40kcon and 100% CPU on 16 threads. --- include/proto/task.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/proto/task.h b/include/proto/task.h index 24bc01688b..ca963a1d36 100644 --- a/include/proto/task.h +++ b/include/proto/task.h @@ -245,7 +245,10 @@ static inline void tasklet_wakeup(struct tasklet *tl) if (likely(tl->tid < 0)) { /* this tasklet runs on the caller thread */ if (LIST_ISEMPTY(&tl->list)) { - LIST_ADDQ(&task_per_thread[tid].tasklets[TL_URGENT], &tl->list); + if (tl->state & TASK_RUNNING) + LIST_ADDQ(&task_per_thread[tid].tasklets[TL_BULK], &tl->list); + else + LIST_ADDQ(&task_per_thread[tid].tasklets[TL_URGENT], &tl->list); _HA_ATOMIC_ADD(&tasks_run_queue, 1); } } else { -- 2.39.5