From: Bart Van Assche Date: Sat, 19 Apr 2008 15:16:45 +0000 (+0000) Subject: Added more detailed statistics about thread_new_segment() calls. X-Git-Tag: svn/VALGRIND_3_4_0~723 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2f5eaf9681ce1b980b5ca25c0cb836fa869837c4;p=thirdparty%2Fvalgrind.git Added more detailed statistics about thread_new_segment() calls. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7891 --- diff --git a/exp-drd/drd_barrier.c b/exp-drd/drd_barrier.c index c1273cf3f5..96e2b74cf5 100644 --- a/exp-drd/drd_barrier.c +++ b/exp-drd/drd_barrier.c @@ -60,6 +60,7 @@ static const char* barrier_type_name(const BarrierT bt); // Local variables. static Bool s_trace_barrier = False; +static ULong s_barrier_segment_creation_count; // Function definitions. @@ -343,6 +344,7 @@ void barrier_post_wait(const DrdThreadId tid, const Addr barrier, } thread_new_segment(tid); + s_barrier_segment_creation_count++; if (--p->post_waiters_left <= 0) { @@ -386,3 +388,8 @@ static const char* barrier_type_name(const BarrierT bt) } return "?"; } + +ULong get_barrier_segment_creation_count(void) +{ + return s_barrier_segment_creation_count; +} diff --git a/exp-drd/drd_barrier.h b/exp-drd/drd_barrier.h index 54deb4929a..f525f15556 100644 --- a/exp-drd/drd_barrier.h +++ b/exp-drd/drd_barrier.h @@ -50,6 +50,7 @@ void barrier_post_wait(const DrdThreadId tid, const Addr barrier, const BarrierT barrier_type, const Bool waited); void barrier_thread_delete(const DrdThreadId threadid); void barrier_stop_using_mem(const Addr a1, const Addr a2); +ULong get_barrier_segment_creation_count(void); #endif /* __DRD_BARRIER_H */ diff --git a/exp-drd/drd_main.c b/exp-drd/drd_main.c index d501cb8d07..3b9563af59 100644 --- a/exp-drd/drd_main.c +++ b/exp-drd/drd_main.c @@ -50,7 +50,6 @@ #include "pub_tool_mallocfree.h" // VG_(malloc)(), VG_(free)() #include "pub_tool_options.h" // command line options #include "pub_tool_replacemalloc.h" -#include "pub_tool_replacemalloc.h" #include "pub_tool_threadstate.h" // VG_(get_running_tid)() #include "pub_tool_tooliface.h" @@ -1078,6 +1077,12 @@ void drd_fini(Int exitcode) sg_get_created_segments_count(), sg_get_max_alive_segments_count(), thread_get_discard_ordered_segments_count()); + VG_(message)(Vg_UserMsg, + " (%lld m, %lld rw, %lld s, %lld b)", + get_mutex_segment_creation_count(), + get_rwlock_segment_creation_count(), + get_semaphore_segment_creation_count(), + get_barrier_segment_creation_count()); VG_(message)(Vg_UserMsg, " bitmaps: %lld level 1 / %lld level 2 bitmap refs", bm_get_bitmap_creation_count(), diff --git a/exp-drd/drd_mutex.c b/exp-drd/drd_mutex.c index c28487d4ab..dca84a74fe 100644 --- a/exp-drd/drd_mutex.c +++ b/exp-drd/drd_mutex.c @@ -45,6 +45,7 @@ static Bool mutex_is_locked(struct mutex_info* const p); static Bool s_trace_mutex; static ULong s_mutex_lock_count; +static ULong s_mutex_segment_creation_count; // Function definitions. @@ -284,6 +285,7 @@ void mutex_post_lock(const Addr mutex, const Bool took_lock, thread_combine_vc2(drd_tid, &p->last_locked_segment->vc); } thread_new_segment(drd_tid); + s_mutex_segment_creation_count++; p->owner = drd_tid; s_mutex_lock_count++; @@ -374,6 +376,7 @@ void mutex_unlock(const Addr mutex, const MutexT mutex_type) thread_get_latest_segment(&p->last_locked_segment, drd_tid); thread_new_segment(drd_tid); + s_mutex_segment_creation_count++; } } @@ -457,3 +460,8 @@ ULong get_mutex_lock_count(void) { return s_mutex_lock_count; } + +ULong get_mutex_segment_creation_count(void) +{ + return s_mutex_segment_creation_count; +} diff --git a/exp-drd/drd_mutex.h b/exp-drd/drd_mutex.h index 52880ffb64..77f24e9415 100644 --- a/exp-drd/drd_mutex.h +++ b/exp-drd/drd_mutex.h @@ -55,6 +55,7 @@ Bool mutex_is_locked_by(const Addr mutex, const DrdThreadId tid); int mutex_get_recursion_count(const Addr mutex); void mutex_thread_delete(const DrdThreadId tid); ULong get_mutex_lock_count(void); +ULong get_mutex_segment_creation_count(void); #endif /* __DRD_MUTEX_H */ diff --git a/exp-drd/drd_rwlock.c b/exp-drd/drd_rwlock.c index 7e23173153..dd1d0c6673 100644 --- a/exp-drd/drd_rwlock.c +++ b/exp-drd/drd_rwlock.c @@ -50,6 +50,7 @@ struct rwlock_thread_info // Local functions. static void rwlock_cleanup(struct rwlock_info* p); +static ULong s_rwlock_segment_creation_count; // Local variables. @@ -350,6 +351,7 @@ void rwlock_post_rdlock(const Addr rwlock, const Bool took_lock) { rwlock_combine_other_vc(p, drd_tid, False); thread_new_segment(drd_tid); + s_rwlock_segment_creation_count++; } } @@ -423,6 +425,7 @@ void rwlock_post_wrlock(const Addr rwlock, const Bool took_lock) tl_assert(q->writer_nesting_count == 1); rwlock_combine_other_vc(p, drd_tid, True); thread_new_segment(drd_tid); + s_rwlock_segment_creation_count++; } /** @@ -479,6 +482,7 @@ void rwlock_pre_unlock(const Addr rwlock) thread_get_latest_segment(&q->last_unlock_segment, drd_tid); q->last_lock_was_writer_lock = False; thread_new_segment(drd_tid); + s_rwlock_segment_creation_count++; } } @@ -508,3 +512,8 @@ void rwlock_thread_delete(const DrdThreadId tid) } } } + +ULong get_rwlock_segment_creation_count(void) +{ + return s_rwlock_segment_creation_count; +} diff --git a/exp-drd/drd_rwlock.h b/exp-drd/drd_rwlock.h index 6abc203b67..77e3abfe67 100644 --- a/exp-drd/drd_rwlock.h +++ b/exp-drd/drd_rwlock.h @@ -48,6 +48,7 @@ void rwlock_pre_wrlock(const Addr rwlock); void rwlock_post_wrlock(const Addr rwlock, const Bool took_lock); void rwlock_pre_unlock(const Addr rwlock); void rwlock_thread_delete(const DrdThreadId tid); +ULong get_rwlock_segment_creation_count(void); #endif /* __DRD_RWLOCK_H */ diff --git a/exp-drd/drd_semaphore.c b/exp-drd/drd_semaphore.c index dc5c9f5f81..38d3b9a1b4 100644 --- a/exp-drd/drd_semaphore.c +++ b/exp-drd/drd_semaphore.c @@ -43,6 +43,7 @@ static void semaphore_cleanup(struct semaphore_info* p); // Local variables. static Bool s_trace_semaphore; +static ULong s_semaphore_segment_creation_count; // Function definitions. @@ -222,6 +223,7 @@ void semaphore_post_wait(const DrdThreadId tid, const Addr semaphore, thread_combine_vc2(tid, &p->last_sem_post_segment->vc); } thread_new_segment(tid); + s_semaphore_segment_creation_count++; } /** Called before sem_post(). */ @@ -244,6 +246,7 @@ void semaphore_pre_post(const DrdThreadId tid, const Addr semaphore) p->last_sem_post_tid = tid; thread_new_segment(tid); thread_get_latest_segment(&p->last_sem_post_segment, tid); + s_semaphore_segment_creation_count++; } } @@ -264,3 +267,8 @@ void semaphore_post_post(const DrdThreadId tid, const Addr semaphore, void semaphore_thread_delete(const DrdThreadId threadid) { } + +ULong get_semaphore_segment_creation_count(void) +{ + return s_semaphore_segment_creation_count; +} diff --git a/exp-drd/drd_semaphore.h b/exp-drd/drd_semaphore.h index c55dc9df68..2b5107fa67 100644 --- a/exp-drd/drd_semaphore.h +++ b/exp-drd/drd_semaphore.h @@ -49,6 +49,7 @@ void semaphore_pre_post(const DrdThreadId tid, const Addr semaphore); void semaphore_post_post(const DrdThreadId tid, const Addr semaphore, const Bool waited); void semaphore_thread_delete(const DrdThreadId tid); +ULong get_semaphore_segment_creation_count(void); #endif /* __DRD_SEMAPHORE_H */