]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: quic: rename TID affinity elements
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 11 Jul 2024 12:55:28 +0000 (14:55 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 11 Jul 2024 13:14:06 +0000 (15:14 +0200)
This commit is the renaming counterpart of the previous one, this time
for quic_conn module. Several elements related to TID affinity update
from quic_conn has been renamed : public functions, but also flag
renamed to QUIC_FL_CONN_TID_REBIND and trace event to
QUIC_EV_CONN_BIND_TID.

This should be backported with the same instruction as the previous
commit.

include/haproxy/quic_conn-t.h
include/haproxy/quic_conn.h
include/haproxy/quic_trace-t.h
src/proto_quic.c
src/quic_conn.c
src/quic_rx.c
src/quic_trace.c
src/xprt_quic.c

index 0b33bd0268da27efb973196b4f31af92d4ab8c91..c7006450e8c73f5844fb69793c73b194f729f167 100644 (file)
@@ -436,7 +436,7 @@ struct quic_conn_closed {
 #define QUIC_FL_CONN_RETRANS_NEEDED              (1U << 7)
 #define QUIC_FL_CONN_RETRANS_OLD_DATA            (1U << 8) /* retransmission in progress for probing with already sent data */
 #define QUIC_FL_CONN_TLS_ALERT                   (1U << 9)
-#define QUIC_FL_CONN_AFFINITY_CHANGED            (1U << 10) /* qc_finalize_affinity_rebind() must be called to finalize affinity rebind */
+#define QUIC_FL_CONN_TID_REBIND                  (1U << 10) /* TID rebind in progress, requires qc_finalize_tid_rebind() call */
 #define QUIC_FL_CONN_HALF_OPEN_CNT_DECREMENTED   (1U << 11) /* The half-open connection counter was decremented */
 #define QUIC_FL_CONN_HANDSHAKE_SPEED_UP          (1U << 12) /* Handshake speeding up was done */
 #define QUIC_FL_CONN_ACK_TIMER_FIRED             (1U << 13) /* idle timer triggered for acknowledgements */
@@ -474,7 +474,7 @@ static forceinline char *qc_show_flags(char *buf, size_t len, const char *delim,
        _(QUIC_FL_CONN_RETRANS_NEEDED,
        _(QUIC_FL_CONN_RETRANS_OLD_DATA,
        _(QUIC_FL_CONN_TLS_ALERT,
-       _(QUIC_FL_CONN_AFFINITY_CHANGED,
+       _(QUIC_FL_CONN_TID_REBIND,
        _(QUIC_FL_CONN_HALF_OPEN_CNT_DECREMENTED,
        _(QUIC_FL_CONN_HANDSHAKE_SPEED_UP,
        _(QUIC_FL_CONN_ACK_TIMER_FIRED,
index 7082fa07390df0a92ec746f5817078877ae9f084..212e187ba667c88d54e29a5c04a1a2c724796de3 100644 (file)
@@ -177,10 +177,10 @@ void qc_kill_conn(struct quic_conn *qc);
 int qc_parse_hd_form(struct quic_rx_packet *pkt,
                      unsigned char **buf, const unsigned char *end);
 
-int qc_set_tid_affinity1(struct quic_conn *qc, uint new_tid);
-void qc_set_tid_affinity2(struct quic_conn *qc, struct listener *new_li);
-void qc_reset_tid_affinity(struct quic_conn *qc);
-void qc_finalize_affinity_rebind(struct quic_conn *qc);
+int qc_bind_tid_prep(struct quic_conn *qc, uint new_tid);
+void qc_bind_tid_commit(struct quic_conn *qc, struct listener *new_li);
+void qc_bind_tid_reset(struct quic_conn *qc);
+void qc_finalize_tid_rebind(struct quic_conn *qc);
 
 int qc_handle_conn_migration(struct quic_conn *qc,
                              const struct sockaddr_storage *peer_addr,
index 7ebc8a7f3dc1859b41f2567db8e0418b568e7fa5..1c977b46f383af4c327f958901ade240b1011d87 100644 (file)
@@ -98,6 +98,6 @@ struct quic_rx_crypto_frm {
 #define           QUIC_EV_CONN_KILL      (1ULL << 49)
 #define           QUIC_EV_CONN_KP        (1ULL << 50)
 #define           QUIC_EV_CONN_SSL_COMPAT (1ULL << 51)
-#define           QUIC_EV_CONN_SET_AFFINITY (1ULL << 52)
+#define           QUIC_EV_CONN_BIND_TID  (1ULL << 52)
 
 #endif /* _HAPROXY_QUIC_TRACE_T_H */
index 593209b4d8c9be269f9c185bee5a8925b369ac19..60aad85db5bfaafe32ef07b2eef35c7865cea986 100644 (file)
@@ -700,19 +700,19 @@ static void quic_disable_listener(struct listener *l)
 static int quic_bind_tid_prep(struct connection *conn, int new_tid)
 {
        struct quic_conn *qc = conn->handle.qc;
-       return qc_set_tid_affinity1(qc, new_tid);
+       return qc_bind_tid_prep(qc, new_tid);
 }
 
 static void quic_bind_tid_commit(struct connection *conn)
 {
        struct quic_conn *qc = conn->handle.qc;
-       qc_set_tid_affinity2(qc, objt_listener(conn->target));
+       qc_bind_tid_commit(qc, objt_listener(conn->target));
 }
 
 static void quic_bind_tid_reset(struct connection *conn)
 {
        struct quic_conn *qc = conn->handle.qc;
-       qc_reset_tid_affinity(qc);
+       qc_bind_tid_reset(qc);
 }
 
 static int quic_alloc_dghdlrs(void)
index f04ed727c28a2a011906c3df3efbe4c6afa9cf71..73b6430d2e59d55a6cde12890ebc2873408997c7 100644 (file)
@@ -1315,7 +1315,7 @@ void quic_conn_release(struct quic_conn *qc)
                goto leave;
 
        /* Must not delete a quic_conn if thread affinity rebind in progress. */
-       BUG_ON(qc->flags & QUIC_FL_CONN_AFFINITY_CHANGED);
+       BUG_ON(qc->flags & QUIC_FL_CONN_TID_REBIND);
 
        /* We must not free the quic-conn if the MUX is still allocated. */
        BUG_ON(qc->mux_state == QC_MUX_READY);
@@ -1728,12 +1728,12 @@ void qc_notify_err(struct quic_conn *qc)
  *
  * Returns 0 on success else non-zero.
  */
-int qc_set_tid_affinity1(struct quic_conn *qc, uint new_tid)
+int qc_bind_tid_prep(struct quic_conn *qc, uint new_tid)
 {
        struct task *t1 = NULL, *t2 = NULL;
        struct tasklet *t3 = NULL;
 
-       TRACE_ENTER(QUIC_EV_CONN_SET_AFFINITY, qc);
+       TRACE_ENTER(QUIC_EV_CONN_BIND_TID, qc);
 
        /* Pre-allocate all required resources. This ensures we do not left a
         * connection with only some of its field rebinded.
@@ -1771,13 +1771,13 @@ int qc_set_tid_affinity1(struct quic_conn *qc, uint new_tid)
        qc->wait_event.events = 0;
 
        /* Remove conn from per-thread list instance. It will be hidden from
-        * "show quic" until qc_finalize_affinity_rebind().
+        * "show quic" until qc_finalize_tid_rebind().
         */
        qc_detach_th_ctx_list(qc, 0);
 
-       qc->flags |= QUIC_FL_CONN_AFFINITY_CHANGED;
+       qc->flags |= QUIC_FL_CONN_TID_REBIND;
 
-       TRACE_LEAVE(QUIC_EV_CONN_SET_AFFINITY, qc);
+       TRACE_LEAVE(QUIC_EV_CONN_BIND_TID, qc);
        return 0;
 
  err:
@@ -1785,27 +1785,27 @@ int qc_set_tid_affinity1(struct quic_conn *qc, uint new_tid)
        task_destroy(t2);
        tasklet_free(t3);
 
-       TRACE_DEVEL("leaving on error", QUIC_EV_CONN_SET_AFFINITY, qc);
+       TRACE_DEVEL("leaving on error", QUIC_EV_CONN_BIND_TID, qc);
        return 1;
 }
 
-/* Complete <qc> rebiding to an already selected new thread and associate it
+/* Complete <qc> rebinding to an already selected new thread and associate it
  * to <new_li> if necessary as required when migrating to a new thread group.
  *
  * After this function, <qc> instance must only be accessed via its newly
- * associated thread. qc_finalize_affinity_rebind() must be called to
+ * associated thread. qc_finalize_tid_rebind() must be called to
  * reactivate quic_conn elements.
  */
-void qc_set_tid_affinity2(struct quic_conn *qc, struct listener *new_li)
+void qc_bind_tid_commit(struct quic_conn *qc, struct listener *new_li)
 {
        const uint new_tid = qc->wait_event.tasklet->tid;
        struct quic_connection_id *conn_id;
        struct eb64_node *node;
 
-       TRACE_ENTER(QUIC_EV_CONN_SET_AFFINITY, qc);
+       TRACE_ENTER(QUIC_EV_CONN_BIND_TID, qc);
 
-       /* Must only be called after qc_set_tid_affinity1(). */
-       BUG_ON(!(qc->flags & QUIC_FL_CONN_AFFINITY_CHANGED));
+       /* Must only be called after qc_bind_tid_prep(). */
+       BUG_ON(!(qc->flags & QUIC_FL_CONN_TID_REBIND));
 
        /* At this point no connection was accounted for yet on this
         * listener so it's OK to just swap the pointer.
@@ -1836,39 +1836,38 @@ void qc_set_tid_affinity2(struct quic_conn *qc, struct listener *new_li)
        HA_ATOMIC_STORE(&conn_id->tid, new_tid);
        qc = NULL;
 
-       TRACE_LEAVE(QUIC_EV_CONN_SET_AFFINITY, NULL);
+       TRACE_LEAVE(QUIC_EV_CONN_BIND_TID, NULL);
 }
 
 /* Interrupt <qc> thread migration and stick to the current tid.
- * qc_finalize_affinity_rebind() must be called to reactivate quic_conn
- * elements.
+ * qc_finalize_tid_rebind() must be called to reactivate quic_conn elements.
  */
-void qc_reset_tid_affinity(struct quic_conn *qc)
+void qc_bind_tid_reset(struct quic_conn *qc)
 {
-       TRACE_ENTER(QUIC_EV_CONN_SET_AFFINITY, qc);
+       TRACE_ENTER(QUIC_EV_CONN_BIND_TID, qc);
 
-       /* Must only be called after qc_set_tid_affinity1(). */
-       BUG_ON(!(qc->flags & QUIC_FL_CONN_AFFINITY_CHANGED));
+       /* Must only be called after qc_bind_tid_prep(). */
+       BUG_ON(!(qc->flags & QUIC_FL_CONN_TID_REBIND));
 
        /* Reset tasks affinity to the current thread. quic_conn will remain
-        * inactive until qc_finalize_affinity_rebind().
+        * inactive until qc_finalize_tid_rebind().
         */
        task_set_thread(qc->idle_timer_task, tid);
        if (qc->timer_task)
                task_set_thread(qc->timer_task, tid);
        tasklet_set_tid(qc->wait_event.tasklet, tid);
 
-       TRACE_LEAVE(QUIC_EV_CONN_SET_AFFINITY, qc);
+       TRACE_LEAVE(QUIC_EV_CONN_BIND_TID, qc);
 }
 
-/* Must be called after qc_set_tid_affinity() on the new thread. */
-void qc_finalize_affinity_rebind(struct quic_conn *qc)
+/* Must be called after TID rebind commit or reset on the new thread. */
+void qc_finalize_tid_rebind(struct quic_conn *qc)
 {
-       TRACE_ENTER(QUIC_EV_CONN_SET_AFFINITY, qc);
+       TRACE_ENTER(QUIC_EV_CONN_BIND_TID, qc);
 
        /* This function must not be called twice after an affinity rebind. */
-       BUG_ON(!(qc->flags & QUIC_FL_CONN_AFFINITY_CHANGED));
-       qc->flags &= ~QUIC_FL_CONN_AFFINITY_CHANGED;
+       BUG_ON(!(qc->flags & QUIC_FL_CONN_TID_REBIND));
+       qc->flags &= ~QUIC_FL_CONN_TID_REBIND;
 
        /* If quic_conn is closing it is unnecessary to migrate it as it will
         * be soon released. Besides, special care must be taken for CLOSING
@@ -1897,7 +1896,7 @@ void qc_finalize_affinity_rebind(struct quic_conn *qc)
                qc->flags &= ~QUIC_FL_CONN_IO_TO_REQUEUE;
        }
 
-       TRACE_LEAVE(QUIC_EV_CONN_SET_AFFINITY, qc);
+       TRACE_LEAVE(QUIC_EV_CONN_BIND_TID, qc);
 }
 
 /*
index abf89f1d776e1568ee926fdeb2ec6193d6d78b29..036e5d30f2d9e425f6bd7af9d5c2dae2a7f5a5d3 100644 (file)
@@ -2169,8 +2169,8 @@ int quic_dgram_parse(struct quic_dgram *dgram, struct quic_conn *from_qc,
                               eb64_entry(eb64_first(qc->cids), struct quic_connection_id, seq_num))->tid != tid);
 
                /* Ensure thread connection migration is finalized ASAP. */
-               if (qc->flags & QUIC_FL_CONN_AFFINITY_CHANGED)
-                       qc_finalize_affinity_rebind(qc);
+               if (qc->flags & QUIC_FL_CONN_TID_REBIND)
+                       qc_finalize_tid_rebind(qc);
 
                if (qc_rx_check_closing(qc, pkt)) {
                        /* Skip the entire datagram. */
index 9ab9626d7dae177e4f4edad76e8bd1b02e4bd618..bd7a8861073cdcdeb6f1c81b8e9e0f064a9f2161 100644 (file)
@@ -68,7 +68,7 @@ static const struct trace_event quic_trace_events[] = {
        { .mask = QUIC_EV_CONN_IDLE_TIMER, .name = "idle_timer",     .desc = "idle timer task"},
        { .mask = QUIC_EV_CONN_SUB,      .name = "xprt_sub",         .desc = "RX/TX subscription or unsubscription to QUIC xprt"},
        { .mask = QUIC_EV_CONN_RCV,      .name = "conn_recv",        .desc = "RX on connection" },
-       { .mask = QUIC_EV_CONN_SET_AFFINITY, .name = "conn_set_affinity", .desc = "set connection thread affinity" },
+       { .mask = QUIC_EV_CONN_BIND_TID, .name = "conn_bind_tid",    .desc = "change connection thread affinity" },
        { /* end */ }
 };
 
index b83b6340c47bdd132c3b3bcdfaa01d81f22bbf1f..558d1a5975219745e3d5c3492c4e1725dd262a70 100644 (file)
@@ -113,8 +113,8 @@ static int qc_conn_init(struct connection *conn, void **xprt_ctx)
        TRACE_ENTER(QUIC_EV_CONN_NEW, qc);
 
        /* Ensure thread connection migration is finalized ASAP. */
-       if (qc->flags & QUIC_FL_CONN_AFFINITY_CHANGED)
-               qc_finalize_affinity_rebind(qc);
+       if (qc->flags & QUIC_FL_CONN_TID_REBIND)
+               qc_finalize_tid_rebind(qc);
 
        /* do not store the context if already set */
        if (*xprt_ctx)