task_wakeup() passes the task through the global run queue under the
global RQ lock, which is expensive when dealing with large amounts of
h1_takeover() calls. Let's use the new task_kill() instead to kill the
task.
By doing so, a scenario involving approximately 130k takeover/s running on
16 threads gained almost 3% performance from 319k req/s to 328k.
static int h1_takeover(struct connection *conn)
{
struct h1c *h1c = conn->ctx;
+ struct task *task;
if (fd_takeover(conn->handle.fd, conn) != 0)
return -1;
*/
h1c->wait_event.tasklet->context = NULL;
tasklet_wakeup(h1c->wait_event.tasklet);
- if (h1c->task) {
- h1c->task->context = NULL;
- /* Wake the task, to let it free itself */
- task_wakeup(h1c->task, TASK_WOKEN_OTHER);
+
+ task = h1c->task;
+ if (task) {
+ task->context = NULL;
+ h1c->task = NULL;
+ __ha_barrier_store();
+ task_kill(task);
h1c->task = task_new(tid_bit);
if (!h1c->task) {