From: Tobias Brunner Date: Thu, 17 Dec 2009 14:58:46 +0000 (+0100) Subject: Readding changes that got lost during refactoring/rebasing. X-Git-Tag: 4.3.6~68 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4ec2c94b5dd30e0c149a254a56395011547e1358;p=thirdparty%2Fstrongswan.git Readding changes that got lost during refactoring/rebasing. --- diff --git a/src/libstrongswan/threading/lock_profiler.h b/src/libstrongswan/threading/lock_profiler.h index b8359c629c..b64453ba15 100644 --- a/src/libstrongswan/threading/lock_profiler.h +++ b/src/libstrongswan/threading/lock_profiler.h @@ -24,7 +24,12 @@ /** * Do not report mutexes with an overall waiting time smaller than this (in us) */ -#define PROFILE_TRESHHOLD 1000 +#define PROFILE_WAIT_TRESHHOLD 10000 + +/** + * Do not report mutexes with an overall lock count smaller than this + */ +#define PROFILE_LOCK_TRESHHOLD 1000 #include @@ -36,6 +41,11 @@ struct lock_profile_t { */ timeval_t waited; + /** + * How many times the lock has been invoked + */ + u_int locked; + /** * backtrace where mutex has been created */ @@ -48,10 +58,11 @@ struct lock_profile_t { static inline void profiler_cleanup(lock_profile_t *profile) { if (profile->waited.tv_sec > 0 || - profile->waited.tv_usec > PROFILE_TRESHHOLD) + profile->waited.tv_usec > PROFILE_WAIT_TRESHHOLD || + profile->locked > PROFILE_LOCK_TRESHHOLD) { - fprintf(stderr, "%d.%06ds in lock created at:", - profile->waited.tv_sec, profile->waited.tv_usec); + fprintf(stderr, "%d.%03ds / %d times in lock created at:", + profile->waited.tv_sec, profile->waited.tv_usec, profile->locked); profile->backtrace->log(profile->backtrace, stderr); } profile->backtrace->destroy(profile->backtrace); @@ -64,10 +75,12 @@ static inline void profiler_init(lock_profile_t *profile) { profile->backtrace = backtrace_create(2); timerclear(&profile->waited); + profile->locked = 0; } #define profiler_start(profile) { \ struct timeval _start, _end, _diff; \ + (profile)->locked++; \ time_monotonic(&_start); #define profiler_end(profile) \