Changeset: ae6edfa8ed6a for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ae6edfa8ed6a
Modified Files:
gdk/gdk_system.c
gdk/gdk_system.h
Branch: default
Log Message:
Debug help: maintain last (un)locker of each lock.
Only maintained when NDEBUG is not defined (i.e., no assertions).
To be printed from the debugger by calling the function GDKlockstatistics.
diffs (99 lines):
diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -142,15 +142,17 @@ GDKlockstatistics(int what)
return;
}
GDKlocklist = sortlocklist(GDKlocklist);
+ fprintf(stderr, "# lock
name\tcount\tcontention\tsleep\tlocked\t(un)locker\n");
for (l = GDKlocklist; l; l = l->next)
if (what == 0 ||
(what == 1 && l->count) ||
(what == 2 && l->contention) ||
(what == 3 && l->lock))
- fprintf(stderr, "#lock %-18s\t" SZFMT "\t" SZFMT "\t"
SZFMT "%s\n",
+ fprintf(stderr, "# %-18s\t" SZFMT "\t" SZFMT "\t" SZFMT
"\t%s\t%s\n",
l->name ? l->name : "unknown",
l->count, l->contention, l->sleep,
- what != 3 && l->lock ? "\tlocked" : "");
+ l->lock ? "locked" : "",
+ l->locker ? l->locker : "");
fprintf(stderr, "#total lock count " SZFMT "\n", (size_t) GDKlockcnt);
fprintf(stderr, "#lock contention " SZFMT "\n", (size_t)
GDKlockcontentioncnt);
fprintf(stderr, "#lock sleep count " SZFMT "\n", (size_t)
GDKlocksleepcnt);
diff --git a/gdk/gdk_system.h b/gdk/gdk_system.h
--- a/gdk/gdk_system.h
+++ b/gdk/gdk_system.h
@@ -205,12 +205,13 @@ typedef struct MT_Lock {
size_t sleep;
struct MT_Lock * volatile next;
const char *name;
+ const char *locker;
#endif
} MT_Lock;
#ifndef NDEBUG
-#define MT_LOCK_INITIALIZER(name) = {0, 0, 0, 0, (struct MT_Lock *) -1,
name}
+#define MT_LOCK_INITIALIZER(name) = {0, 0, 0, 0, (struct MT_Lock *) -1,
name, NULL}
gdk_export void GDKlockstatistics(int);
gdk_export MT_Lock * volatile GDKlocklist;
@@ -219,6 +220,7 @@ gdk_export ATOMIC_TYPE volatile GDKlockc
gdk_export ATOMIC_TYPE volatile GDKlockcontentioncnt;
gdk_export ATOMIC_TYPE volatile GDKlocksleepcnt;
#define _DBG_LOCK_COUNT_0(l, n) ATOMIC_INC(GDKlockcnt, dummy, n)
+#define _DBG_LOCK_LOCKER(l, n) ((l)->locker = (n))
#define _DBG_LOCK_CONTENTION(l, n) \
do { \
TEMDEBUG fprintf(stderr, "#lock %s contention in %s\n",
(l)->name, n); \
@@ -248,7 +250,8 @@ gdk_export ATOMIC_TYPE volatile GDKlocks
#define _DBG_LOCK_INIT(l, n) \
do { \
(l)->count = (l)->contention = (l)->sleep = 0; \
- (l)->name = n; \
+ (l)->name = (n); \
+ _DBG_LOCK_LOCKER(l, NULL); \
while (ATOMIC_TAS(GDKlocklistlock, dummy, "") != 0) \
; \
(l)->next = GDKlocklist; \
@@ -277,13 +280,14 @@ gdk_export ATOMIC_TYPE volatile GDKlocks
#define MT_LOCK_INITIALIZER(name) = ATOMIC_FLAG_INIT
-#define _DBG_LOCK_COUNT_0(l, n) ((void) n)
-#define _DBG_LOCK_CONTENTION(l, n) ((void) n)
-#define _DBG_LOCK_SLEEP(l, n) ((void) n)
+#define _DBG_LOCK_COUNT_0(l, n) ((void) (n))
+#define _DBG_LOCK_CONTENTION(l, n) ((void) (n))
+#define _DBG_LOCK_SLEEP(l, n) ((void) (n))
#define _DBG_LOCK_COUNT_1(l) ((void) 0)
#define _DBG_LOCK_COUNT_2(l) ((void) 0)
-#define _DBG_LOCK_INIT(l, n) ((void) n)
+#define _DBG_LOCK_INIT(l, n) ((void) (n))
#define _DBG_LOCK_DESTROY(l) ((void) 0)
+#define _DBG_LOCK_LOCKER(l, n) ((void) (n))
#endif
@@ -302,6 +306,7 @@ gdk_export ATOMIC_TYPE volatile GDKlocks
} while (ATOMIC_TAS((l)->lock, dummy, n) != 0); \
_DBG_LOCK_COUNT_1(l); \
} \
+ _DBG_LOCK_LOCKER(l, n); \
_DBG_LOCK_COUNT_2(l); \
} while (0)
#define MT_lock_init(l, n) \
@@ -309,7 +314,11 @@ gdk_export ATOMIC_TYPE volatile GDKlocks
ATOMIC_CLEAR((l)->lock, dummy, n); \
_DBG_LOCK_INIT(l, n); \
} while (0)
-#define MT_lock_unset(l, n) ATOMIC_CLEAR((l)->lock, dummy, n)
+#define MT_lock_unset(l, n) \
+ do { \
+ _DBG_LOCK_LOCKER(l, n); \
+ ATOMIC_CLEAR((l)->lock, dummy, n); \
+ } while (0)
#define MT_lock_destroy(l) _DBG_LOCK_DESTROY(l)
/* return 0 on success, -1 on failure to get the lock */
#define MT_lock_try(l) ((ATOMIC_TAS((l)->lock, dummy, dummy) == 0) - 1)
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list