CLEANUP: quic: rename TID affinity elements

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.
This commit is contained in:
Amaury Denoyelle 2024-07-11 14:55:28 +02:00
parent 9fbe8b0334
commit 3be58fc720
8 changed files with 42 additions and 43 deletions

View File

@ -436,7 +436,7 @@ struct quic_conn_closed {
#define QUIC_FL_CONN_RETRANS_NEEDED (1U << 7) #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_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_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_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_HANDSHAKE_SPEED_UP (1U << 12) /* Handshake speeding up was done */
#define QUIC_FL_CONN_ACK_TIMER_FIRED (1U << 13) /* idle timer triggered for acknowledgements */ #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_NEEDED,
_(QUIC_FL_CONN_RETRANS_OLD_DATA, _(QUIC_FL_CONN_RETRANS_OLD_DATA,
_(QUIC_FL_CONN_TLS_ALERT, _(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_HALF_OPEN_CNT_DECREMENTED,
_(QUIC_FL_CONN_HANDSHAKE_SPEED_UP, _(QUIC_FL_CONN_HANDSHAKE_SPEED_UP,
_(QUIC_FL_CONN_ACK_TIMER_FIRED, _(QUIC_FL_CONN_ACK_TIMER_FIRED,

View File

@ -177,10 +177,10 @@ void qc_kill_conn(struct quic_conn *qc);
int qc_parse_hd_form(struct quic_rx_packet *pkt, int qc_parse_hd_form(struct quic_rx_packet *pkt,
unsigned char **buf, const unsigned char *end); unsigned char **buf, const unsigned char *end);
int qc_set_tid_affinity1(struct quic_conn *qc, uint new_tid); int qc_bind_tid_prep(struct quic_conn *qc, uint new_tid);
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);
void qc_reset_tid_affinity(struct quic_conn *qc); void qc_bind_tid_reset(struct quic_conn *qc);
void qc_finalize_affinity_rebind(struct quic_conn *qc); void qc_finalize_tid_rebind(struct quic_conn *qc);
int qc_handle_conn_migration(struct quic_conn *qc, int qc_handle_conn_migration(struct quic_conn *qc,
const struct sockaddr_storage *peer_addr, const struct sockaddr_storage *peer_addr,

View File

@ -98,6 +98,6 @@ struct quic_rx_crypto_frm {
#define QUIC_EV_CONN_KILL (1ULL << 49) #define QUIC_EV_CONN_KILL (1ULL << 49)
#define QUIC_EV_CONN_KP (1ULL << 50) #define QUIC_EV_CONN_KP (1ULL << 50)
#define QUIC_EV_CONN_SSL_COMPAT (1ULL << 51) #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 */ #endif /* _HAPROXY_QUIC_TRACE_T_H */

View 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) static int quic_bind_tid_prep(struct connection *conn, int new_tid)
{ {
struct quic_conn *qc = conn->handle.qc; 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) static void quic_bind_tid_commit(struct connection *conn)
{ {
struct quic_conn *qc = conn->handle.qc; 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) static void quic_bind_tid_reset(struct connection *conn)
{ {
struct quic_conn *qc = conn->handle.qc; struct quic_conn *qc = conn->handle.qc;
qc_reset_tid_affinity(qc); qc_bind_tid_reset(qc);
} }
static int quic_alloc_dghdlrs(void) static int quic_alloc_dghdlrs(void)

View File

@ -1315,7 +1315,7 @@ void quic_conn_release(struct quic_conn *qc)
goto leave; goto leave;
/* Must not delete a quic_conn if thread affinity rebind in progress. */ /* 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. */ /* We must not free the quic-conn if the MUX is still allocated. */
BUG_ON(qc->mux_state == QC_MUX_READY); 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. * 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 task *t1 = NULL, *t2 = NULL;
struct tasklet *t3 = 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 /* Pre-allocate all required resources. This ensures we do not left a
* connection with only some of its field rebinded. * 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; qc->wait_event.events = 0;
/* Remove conn from per-thread list instance. It will be hidden from /* 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_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; return 0;
err: err:
@ -1785,27 +1785,27 @@ int qc_set_tid_affinity1(struct quic_conn *qc, uint new_tid)
task_destroy(t2); task_destroy(t2);
tasklet_free(t3); 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; 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. * 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 * 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. * 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; const uint new_tid = qc->wait_event.tasklet->tid;
struct quic_connection_id *conn_id; struct quic_connection_id *conn_id;
struct eb64_node *node; 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(). */ /* Must only be called after qc_bind_tid_prep(). */
BUG_ON(!(qc->flags & QUIC_FL_CONN_AFFINITY_CHANGED)); BUG_ON(!(qc->flags & QUIC_FL_CONN_TID_REBIND));
/* At this point no connection was accounted for yet on this /* At this point no connection was accounted for yet on this
* listener so it's OK to just swap the pointer. * 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); HA_ATOMIC_STORE(&conn_id->tid, new_tid);
qc = NULL; 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. /* Interrupt <qc> thread migration and stick to the current tid.
* qc_finalize_affinity_rebind() must be called to reactivate quic_conn * qc_finalize_tid_rebind() must be called to reactivate quic_conn elements.
* 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(). */ /* Must only be called after qc_bind_tid_prep(). */
BUG_ON(!(qc->flags & QUIC_FL_CONN_AFFINITY_CHANGED)); BUG_ON(!(qc->flags & QUIC_FL_CONN_TID_REBIND));
/* Reset tasks affinity to the current thread. quic_conn will remain /* 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); task_set_thread(qc->idle_timer_task, tid);
if (qc->timer_task) if (qc->timer_task)
task_set_thread(qc->timer_task, tid); task_set_thread(qc->timer_task, tid);
tasklet_set_tid(qc->wait_event.tasklet, 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. */ /* Must be called after TID rebind commit or reset on the new thread. */
void qc_finalize_affinity_rebind(struct quic_conn *qc) 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. */ /* This function must not be called twice after an affinity rebind. */
BUG_ON(!(qc->flags & QUIC_FL_CONN_AFFINITY_CHANGED)); BUG_ON(!(qc->flags & QUIC_FL_CONN_TID_REBIND));
qc->flags &= ~QUIC_FL_CONN_AFFINITY_CHANGED; qc->flags &= ~QUIC_FL_CONN_TID_REBIND;
/* If quic_conn is closing it is unnecessary to migrate it as it will /* 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 * 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; qc->flags &= ~QUIC_FL_CONN_IO_TO_REQUEUE;
} }
TRACE_LEAVE(QUIC_EV_CONN_SET_AFFINITY, qc); TRACE_LEAVE(QUIC_EV_CONN_BIND_TID, qc);
} }
/* /*

View 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); eb64_entry(eb64_first(qc->cids), struct quic_connection_id, seq_num))->tid != tid);
/* Ensure thread connection migration is finalized ASAP. */ /* Ensure thread connection migration is finalized ASAP. */
if (qc->flags & QUIC_FL_CONN_AFFINITY_CHANGED) if (qc->flags & QUIC_FL_CONN_TID_REBIND)
qc_finalize_affinity_rebind(qc); qc_finalize_tid_rebind(qc);
if (qc_rx_check_closing(qc, pkt)) { if (qc_rx_check_closing(qc, pkt)) {
/* Skip the entire datagram. */ /* Skip the entire datagram. */

View 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_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_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_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 */ } { /* end */ }
}; };

View File

@ -113,8 +113,8 @@ static int qc_conn_init(struct connection *conn, void **xprt_ctx)
TRACE_ENTER(QUIC_EV_CONN_NEW, qc); TRACE_ENTER(QUIC_EV_CONN_NEW, qc);
/* Ensure thread connection migration is finalized ASAP. */ /* Ensure thread connection migration is finalized ASAP. */
if (qc->flags & QUIC_FL_CONN_AFFINITY_CHANGED) if (qc->flags & QUIC_FL_CONN_TID_REBIND)
qc_finalize_affinity_rebind(qc); qc_finalize_tid_rebind(qc);
/* do not store the context if already set */ /* do not store the context if already set */
if (*xprt_ctx) if (*xprt_ctx)