From b068e758fbc77e28c4a65275813c49059f6c21e5 Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Fri, 8 Mar 2024 17:40:16 +0100 Subject: [PATCH] MINOR: quic: simplify rescheduling for handshake On CRYPTO frames reception, tasklet is rescheduled with TASK_HEAVY to limit CPU consumption. This commit slighly simplifies this by regrouping TASK_HEAVY setting and tasklet_wakeup() instructions in a single location in qc_handle_crypto_frm(). All other unnecessary tasklet_wakeup() are removed. --- src/quic_conn.c | 7 +------ src/quic_rx.c | 14 ++++---------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/quic_conn.c b/src/quic_conn.c index 8c7d5aaf32..538715b407 100644 --- a/src/quic_conn.c +++ b/src/quic_conn.c @@ -753,8 +753,8 @@ struct task *quic_conn_io_cb(struct task *t, void *context, unsigned int state) TRACE_PROTO("connection state", QUIC_EV_CONN_IO_CB, qc, &st); if (HA_ATOMIC_LOAD(&tl->state) & TASK_HEAVY) { - HA_ATOMIC_AND(&tl->state, ~TASK_HEAVY); qc_ssl_provide_all_quic_data(qc, qc->xprt_ctx); + HA_ATOMIC_AND(&tl->state, ~TASK_HEAVY); } /* Retranmissions */ @@ -771,11 +771,6 @@ struct task *quic_conn_io_cb(struct task *t, void *context, unsigned int state) if (!qc_treat_rx_pkts(qc)) goto out; - if (HA_ATOMIC_LOAD(&tl->state) & TASK_HEAVY) { - tasklet_wakeup(tl); - goto out; - } - if (qc->flags & QUIC_FL_CONN_TO_KILL) { TRACE_DEVEL("connection to be killed", QUIC_EV_CONN_PHPKTS, qc); goto out; diff --git a/src/quic_rx.c b/src/quic_rx.c index 502f7c4d1a..433e6ae5c8 100644 --- a/src/quic_rx.c +++ b/src/quic_rx.c @@ -740,8 +740,11 @@ static int qc_handle_crypto_frm(struct quic_conn *qc, goto leave; } - if (ncb_data(ncbuf, 0)) + /* Reschedule with TASK_HEAVY if CRYPTO data ready for decoding. */ + if (ncb_data(ncbuf, 0)) { HA_ATOMIC_OR(&qc->wait_event.tasklet->state, TASK_HEAVY); + tasklet_wakeup(qc->wait_event.tasklet); + } done: ret = 1; @@ -1325,15 +1328,6 @@ int qc_treat_rx_pkts(struct quic_conn *qc) qel->pktns->flags |= QUIC_FL_PKTNS_NEW_LARGEST_PN; } - if (qel->cstream) { - struct ncbuf *ncbuf = &qel->cstream->rx.ncbuf; - - if (!ncb_is_null(ncbuf) && ncb_data(ncbuf, 0)) { - /* Some in order CRYPTO data were bufferized. */ - HA_ATOMIC_OR(&qc->wait_event.tasklet->state, TASK_HEAVY); - } - } - /* Release the Initial encryption level and packet number space. */ if ((qc->flags & QUIC_FL_CONN_IPKTNS_DCD) && qel == qc->iel) { qc_enc_level_free(qc, &qc->iel); -- 2.39.5