]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: tasks: automatically requeue into the bulk queue an already running tasklet
authorWilly Tarreau <w@1wt.eu>
Thu, 30 Jan 2020 17:59:43 +0000 (18:59 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 30 Jan 2020 18:03:31 +0000 (19:03 +0100)
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

index 24bc01688bd9c0a6c1e9a49dbf8e957184ab74c4..ca963a1d36991e771911d4fb78a68ac68652e94b 100644 (file)
@@ -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 {