Does the muffs make user profile profile space?

Summary : Does perf lock pthread_mutex have a profile?

More details

The perf tool has the perf lock option. The manual page says:

 You can analyze various lock behaviours and statistics with this perf lock command. 'perf lock record <command>' records lock events between start and end <command>. And this command produces the file "perf.data" which contains tracing results of lock events. 'perf lock trace' shows raw lock events. 'perf lock report' reports statistical data. 

But when I tried to run perf lock record , I got an error message: invalid or unsupported event: 'lock:lock_acquire' . I looked, and it seems that the error is probably due to the fact that my kernel was not compiled using CONFIG_LOCKDEP or CONFIG_LOCK_STAT .

My question is: do perf lock report user space perf lock events (like pthread_mutex) or only kernel locks? I'm more interested in a profiling application that runs mostly in user space. I thought this option in perf looks interesting, but since I cannot run it without compiling (or getting) a new kernel, I am interested to know what it does before I try.

+6
source share
1 answer

Summary: Does the pthread_mutex lock profile have?

Summary: No, since there is no pthread_mutex trace point in user space.

According to the source file tools/perf/builtin-lock.c ( http://lxr.free-electrons.com/source/tools/perf/builtin-lock.c#L939 ) cmd_lock calls __cmd_record , which defines several trace points for perf record (via -e TRACEPOINT_NAME ), as well as the transfer parameters -R -m 1024 -c 1 - perf report . List of specific trace points: lock_tracepoints :

 842 static const struct perf_evsel_str_handler lock_tracepoints[] = { 843 { "lock:lock_acquire", perf_evsel__process_lock_acquire, }, /* CONFIG_LOCKDEP */ 844 { "lock:lock_acquired", perf_evsel__process_lock_acquired, }, /* CONFIG_LOCKDEP, CONFIG_LOCK_STAT */ 845 { "lock:lock_contended", perf_evsel__process_lock_contended, }, /* CONFIG_LOCKDEP, CONFIG_LOCK_STAT */ 846 { "lock:lock_release", perf_evsel__process_lock_release, }, /* CONFIG_LOCKDEP */ 847 }; 

TRACE_EVENT(lock_acquire,.. is defined in trace/events/lock.h And trace_lock_acquire is defined only in kernel / locking / lockdep.c (double-check in debian codebase: http://codesearch.debian.net/search?q=trace_lock_acquire ). Only CONFIG_LOCKDEP is missing in your kernel according to kernel/locking/Makefile : obj-$(CONFIG_LOCKDEP) += lockdep.o (trace points are defined unconditionally in lockdep.c .

According to https://www.kernel.org/doc/Documentation/trace/tracepoints.txt all trace points are kernel-only, so perf lock will not detect user space locks.

You can try tracking points from LTTng, a project that declares user space trace points ( http://lttng.org/ust ). But there will be no ready statistics of blocking, but only raw data on trace points. You should also define trace points using the tracef() macro (recompile pthreads / glibc or try to create your own wrapper around pthread).

+3
source

Source: https://habr.com/ru/post/946816/


All Articles