glibc standard library User-Space Markers

glibc includes support for SystemTap user-space markers and are enabled in current versions of Fedora and Red Hat Enterprise Linux 7. The markers allow SystemTap to probe glibc memory allocation, thread management, slow math functions, lock operations, and dynamic linking. Below are SystemTap commands to list out the various glibc events available on Fedora.

To list out the probe points in glibc for non-local goto probes and memory allocation use the following command:

$ stap -L 'process("/usr/lib*/*.so").provider("libc").mark("*")'

To list out the pthread probe points in glibc use:

$ stap -L 'process("/usr/lib*/*.so").provider("libpthread").mark("*")'

To list out the probe points related to the glibc's [[https://www.gnu.org/software/libc/manual/html_node/Mathematical-Function-Probes.html#Mathematical-Function-Probes |math library probes] use:

$ stap -L 'process("/usr/lib*/*.so").provider("libm").mark("*")'

To list out the runtime linker (rtld) probe points in glibc's loader use:

$ stap -L 'process("/usr/lib*/*.so").provider("rtld").mark("*")'

Using glibc User-Space Markers

To use the glibc user-space markers on Fedora you will need:

Examples and Demonstrations of Markers

The SystemTap glibc-malloc.stp example shows information about memory use for a process. Below is short run of glibc-malloc.stp showing the memory activity for emacs opening a large text file. The output below shows that there are multiple threads setup, each with its own arena for memory allocation. On exit from emacs the amount allocated for each arena is shown to be 132KB.

$ cd /usr/share/systemtap/examples/
$ stap memory/glibc-malloc.stp -c "emacs ../testsuite/systemtap.log"
5481: New heap
5481: Created new arena
5482: New heap
5482: Created new arena
5483: New heap
5483: Created new arena
5478: New thresholds: mmap: 790528 bytes, trim: 1581056 bytes
malloc information for pid 5478
Contention: 
Active arenas:
        5481 -> 0x7fdbe8000020
        5482 -> 0x7fdbe0000020
        5483 -> 0x7fdbd8000020
Allocated heaps:
        0x7fdbe8000000 -> 135168 bytes
        0x7fdbe0000000 -> 135168 bytes
        0x7fdbd8000000 -> 135168 bytes
Total sbrk: 11800576 bytes
Mmap threshold in the end: 772 kb

References

None: glibcMarkers (last edited 2018-11-16 20:49:28 by WilliamCohen)