Overview

Download

Install Instructions

LiMiT Tools

Lock Monitor

Library Monitor

Video Demo

Sponsors

The Pthread Tool monitors pthread locks -- locking overheads and critical regions. It uses dynamic function interposition, so it can monitor any program without recompilation. Just substitute the "data" function in probe.c with you code and execute with LD_PRELOAD.

Downloads

Version 1 Mutex_probe_v1.tar.gz

Directions

The following function is called whenever new data is available. You can just replace it with your own data aggregation functions. The printf here is way too slow to use for anything but demonstration.

static void data(void* lock, enum Type type, uint64_t ev, uint64_t tsc) {
  // Get an address in the function calling the pthread_mutex_*
  // function.  Resolve this to function name at command line with:
  //    addr2line -f -e ./test 0x400ded
  // Warning: doesn't always work, depending on optimization
  void* locker = __builtin_return_address(1);
  printf("%15s %p -- Lock: %p, ev: %10lu, tsc: %lu\n",
         TypeNames[type], locker, lock, ev, tsc);
}
Once you've got your tool going, execute a program using LD_PRELOAD:
$ LD_PRELOAD=./probe.so ./test_program

Technical Tricks Used

Function Interposition
Dynamic function interposition is really cool, so we use it. This is the best tutorial I've seen on it.

LiMiT Library Replacement
This tool doesn't use the LiMiT library provided on the Download page. That library is designed to be statically linked to the monitored executable, which influences the way the access code works, particularly with respect to the location of the overflow variable. We replace that code with slightly more generic though slightly slower code which works within a shared object.