]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: activity: add per-thread statistics on FD takeover
authorWilly Tarreau <w@1wt.eu>
Mon, 29 Jun 2020 12:17:59 +0000 (14:17 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 29 Jun 2020 12:26:05 +0000 (14:26 +0200)
The FD takeover operation might have certain impacts explaining
unexpected activities, so it's important to report such a counter
there. We thus count the number of times a thread has stolen an
FD from another thread.

include/haproxy/activity-t.h
src/backend.c
src/cli.c

index 6fc584465c547075bfbfc857b5a975c3f748743d..5301ceed69976f2a4a6142a452998b3a0e65635f 100644 (file)
@@ -52,7 +52,7 @@ struct activity {
        unsigned int empty_rq;     // calls to process_runnable_tasks() with nothing for the thread
        unsigned int long_rq;      // process_runnable_tasks() left with tasks in the run queue
        unsigned int cpust_total;  // sum of half-ms stolen per thread
-       /* one unused entry left before end of first cache line */
+       unsigned int fd_takeover;  // number of times this thread stole another one's FD
        ALWAYS_ALIGN(64);
 
        struct freq_ctr cpust_1s;  // avg amount of half-ms stolen over last second
index 51d954babf46bd49a57e3d95a85e7228e15ca82c..70487870c950da5c37ab38e74e42620a153f5423 100644 (file)
@@ -1103,6 +1103,7 @@ static struct connection *conn_backend_get(struct server *srv, int is_safe)
                mt_list_for_each_entry_safe(conn, &mt_list[i], list, elt1, elt2) {
                        if (conn->mux->takeover && conn->mux->takeover(conn) == 0) {
                                MT_LIST_DEL_SAFE(elt1);
+                               _HA_ATOMIC_ADD(&activity[tid].fd_takeover, 1);
                                found = 1;
                                break;
                        }
index 3438fffe099aff7f5832b11dd4a03a08e298ad2c..c1964df72bd3b51132550ec395c25e4ff33d5a75 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -1174,6 +1174,7 @@ static int cli_io_handler_show_activity(struct appctx *appctx)
        chunk_appendf(&trash, "accq_full:");    SHOW_TOT(thr, activity[thr].accq_full);
 #ifdef USE_THREAD
        chunk_appendf(&trash, "accq_ring:");    SHOW_TOT(thr, (accept_queue_rings[thr].tail - accept_queue_rings[thr].head + ACCEPT_QUEUE_SIZE) % ACCEPT_QUEUE_SIZE);
+       chunk_appendf(&trash, "fd_takeover:");  SHOW_TOT(thr, activity[thr].fd_takeover);
 #endif
 
 #if defined(DEBUG_DEV)