]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: simplify rescheduling for handshake
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 8 Mar 2024 16:40:16 +0000 (17:40 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 11 Mar 2024 13:15:36 +0000 (14:15 +0100)
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
src/quic_rx.c

index 8c7d5aaf3225ef2d2e692f2df960204036583c65..538715b40772960120e1794a442a4af89a02c107 100644 (file)
@@ -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;
index 502f7c4d1a98eae8afec784adfefb5327633747d..433e6ae5c85e0353f2412e2eca9357c5db7f3f29 100644 (file)
@@ -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);