]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
DEBUG: thread: add 5 extra lock labels for statistics and debugging
authorWilly Tarreau <w@1wt.eu>
Wed, 17 Feb 2021 13:33:58 +0000 (14:33 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 18 Feb 2021 09:06:45 +0000 (10:06 +0100)
Since OTHER_LOCK is commonly used it's become much more difficult to
profile lock contention by temporarily changing a lock label. Let's
add DEBUG1..5 to serve only for debugging. These ones must not be
used in committed code. We could decide to only define them when
DEBUG_THREAD is set but that would complicate attempts at measuring
performance with debugging turned off.

include/haproxy/thread.h

index a519e77bb982b4fe13806c831764f70b5812c7bb..4419c2c787908f7a1ec6c1669defea36510536d4 100644 (file)
@@ -402,6 +402,14 @@ enum lock_label {
        SFT_LOCK, /* sink forward target */
        IDLE_CONNS_LOCK,
        OTHER_LOCK,
+       /* WT: make sure never to use these ones outside of development,
+        * we need them for lock profiling!
+        */
+       DEBUG1_LOCK,
+       DEBUG2_LOCK,
+       DEBUG3_LOCK,
+       DEBUG4_LOCK,
+       DEBUG5_LOCK,
        LOCK_LABELS
 };
 
@@ -447,6 +455,11 @@ static inline const char *lock_label(enum lock_label label)
        case SFT_LOCK:             return "SFT";
        case IDLE_CONNS_LOCK:      return "IDLE_CONNS";
        case OTHER_LOCK:           return "OTHER";
+       case DEBUG1_LOCK:          return "DEBUG1";
+       case DEBUG2_LOCK:          return "DEBUG2";
+       case DEBUG3_LOCK:          return "DEBUG3";
+       case DEBUG4_LOCK:          return "DEBUG4";
+       case DEBUG5_LOCK:          return "DEBUG5";
        case LOCK_LABELS:          break; /* keep compiler happy */
        };
        /* only way to come here is consecutive to an internal bug */