From: phk Date: Sun, 17 Sep 2006 19:30:31 +0000 (+0000) Subject: Keep track of shmlog mutex contests X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=93a24917e7a37aa28482c0281d8dd652c63ead87;p=varnish Keep track of shmlog mutex contests git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1051 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index 73c5d50f..ee6c4dca 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -422,9 +422,6 @@ cli_func_t cli_func_dump_pool; /* rfc2616.c */ int RFC2616_cache_policy(struct sess *sp, struct http *hp); -#define LOCKSHM(foo) AZ(pthread_mutex_lock(foo)) -#define UNLOCKSHM(foo) AZ(pthread_mutex_unlock(foo)) - #if 1 #define MTX pthread_mutex_t #define MTX_INIT(foo) AZ(pthread_mutex_init(foo, NULL)) diff --git a/varnish-cache/bin/varnishd/shmlog.c b/varnish-cache/bin/varnishd/shmlog.c index 892a0ce1..70558d81 100644 --- a/varnish-cache/bin/varnishd/shmlog.c +++ b/varnish-cache/bin/varnishd/shmlog.c @@ -16,6 +16,16 @@ #include "heritage.h" +#define LOCKSHM(foo) \ + do { \ + if (pthread_mutex_trylock(foo)) { \ + AZ(pthread_mutex_lock(foo)); \ + VSL_stats->shm_cont++; \ + } \ + } while (0); + +#define UNLOCKSHM(foo) AZ(pthread_mutex_unlock(foo)) + #ifndef MAP_HASSEMAPHORE #define MAP_HASSEMAPHORE 0 /* XXX Linux */ #endif diff --git a/varnish-cache/include/Makefile.am b/varnish-cache/include/Makefile.am index 254710af..c5bedcb2 100644 --- a/varnish-cache/include/Makefile.am +++ b/varnish-cache/include/Makefile.am @@ -24,7 +24,6 @@ noinst_HEADERS = \ shmlog_tags.h \ stat_field.h \ stats.h \ - tree.h \ varnish/assert.h \ varnishapi.h \ vcl.h \ diff --git a/varnish-cache/include/stat_field.h b/varnish-cache/include/stat_field.h index acbf9f77..f85ec996 100644 --- a/varnish-cache/include/stat_field.h +++ b/varnish-cache/include/stat_field.h @@ -48,3 +48,5 @@ MAC_STAT(sess_closed, uint64_t, "u", "Session Closed") MAC_STAT(sess_pipeline, uint64_t, "u", "Session Pipeline") MAC_STAT(sess_readahead, uint64_t, "u", "Session Read Ahead") MAC_STAT(sess_herd, uint64_t, "u", "Session herd") + +MAC_STAT(shm_cont, uint64_t, "u", "SHM MTX contention")