/usr/share/systemtap/examples/memory
NameSizeModeActions
cachestat.meta5450644editdlrm
cachestat.stp13180755editdlrm
glibc-malloc.meta3810644editdlrm
glibc-malloc.stp24860755editdlrm
hugepage_clear_delays.meta9460644editdlrm
hugepage_clear_delays.stp4830755editdlrm
hugepage_collapse.meta7180644editdlrm
hugepage_collapse.stp1590755editdlrm
hugepage_cow_delays.meta11060644editdlrm
hugepage_cow_delays.stp4750755editdlrm
hugepage_split.meta7560644editdlrm
hugepage_split.stp1530755editdlrm
hw_watch_addr.meta7870644editdlrm
hw_watch_addr.stp1670755editdlrm
hw_watch_addr.tcl970644editdlrm
hw_watch_sym.meta7150644editdlrm
hw_watch_sym.stp1670755editdlrm
hw_watch_sym.tcl970644editdlrm
kmalloc-top38880755editdlrm
kmalloc-top.meta6950644editdlrm
last_100_frees.meta4200644editdlrm
last_100_frees.stp8030755editdlrm
last_100_frees.tcl790644editdlrm
last_100_frees.txt7740644editdlrm
mmanonpage.meta12250644editdlrm
mmanonpage.stp18160755editdlrm
mmfilepage.meta10330644editdlrm
mmfilepage.stp35370755editdlrm
mmreclaim.meta6060644editdlrm
mmreclaim.stp52320755editdlrm
mmwriteback.meta11140644editdlrm
mmwriteback.stp19000755editdlrm
numa_faults.meta7020644editdlrm
numa_faults.stp9730755editdlrm
numa_faults.txt17100644editdlrm
overcommit.meta5840644editdlrm
overcommit.stp2170755editdlrm
pfaults.meta7440644editdlrm
pfaults.stp8750755editdlrm
pfaults.txt5580644editdlrm
vm.tracepoints.meta6080644editdlrm
vm.tracepoints.stp4140755editdlrm
vm.tracepoints.txt5570644editdlrm
Edit: /usr/share/systemtap/examples/memory/glibc-malloc.stp (2486B)
#!/usr/bin/stap # http://developerblog.redhat.com/2015/01/06/malloc-systemtap-probes-an-example/ global sbrk, waits, arenalist, mmap_threshold = 131072, heaplist # sbrk accounting probe process("/lib*/libc.so.6").mark("memory_sbrk_more") { sbrk += $arg2 } probe process("/lib*/libc.so.6").mark("memory_sbrk_less") { sbrk -= $arg2 } # threshold tracking probe process("/lib*/libc.so.6").mark("memory_mallopt_free_dyn_thresholds") { printf("%d: New thresholds: mmap: %ld bytes, trim: %ld bytes\n", tid(), $arg1, $arg2) mmap_threshold = $arg1 } # arena accounting probe process("/lib*/libc.so.6").mark("memory_arena_new") { printf ("%d: Created new arena\n", tid()) arenalist[$arg1, tid()] = 1 } probe process("/usr/lib*/libc.so.6").mark("memory_arena_reuse_wait") { waits[tid()]++ } probe process("/usr/lib*/libc.so.6").mark("memory_arena_reuse") { if ($arg2 != 0) { printf ("%d: failed to allocate on own arena, trying another\n", tid()) arenalist[$arg1, tid()] = 1 } } probe process("/usr/lib*/libc.so.6").mark("memory_arena_reuse_free_list") { arenalist[$arg1, tid()] = 1 } probe process.thread.end { /* Find the thread and mark its arena as unused. */ %( systemtap_v >= "2.6" %? delete arenalist[*, tid()] %: foreach ([a, t] in arenalist) if (t == tid()) break delete arenalist[a, t] %) } # heap accounting probe process("/usr/lib*/libc.so.6").mark("memory_heap_new") { printf("%d: New heap\n", tid()); heaplist[$arg1] = $arg2 } probe process("/usr/lib*/libc.so.6").mark("memory_heap_more") { heaplist[$arg1] = $arg2 } probe process("/usr/lib*/libc.so.6").mark("memory_heap_less") { heaplist[$arg1] = $arg2 } probe process("/usr/lib*/libc.so.6").mark("memory_heap_free") { delete heaplist[$arg1] } # reporting probe begin { if (target() == 0) error ("please specify target process with -c / -x") } probe end { printf ("malloc information for pid %d\n", target()) printf ("Contention: \n") foreach (t in waits) printf ("\t%d: %d waits\n", t, waits[t]) print("Active arenas:\n") foreach ([a, t] in arenalist) { if (arenalist[a, t]) printf ("\t%d -> %p\n", t, a) } print ("Allocated heaps:\n") foreach (h in heaplist) { if (heaplist[h]) printf ("\t%p -> %ld bytes\n", h, heaplist[h]) } printf ("Total sbrk: %ld bytes\n", sbrk) printf ("Mmap threshold in the end: %ld kb\n", mmap_threshold / 1024) }