Vlad, On Fri, Dec 11, 2009 at 3:18 AM, Vlad Slavici <vs...@ccs.neu.edu> wrote: > Hello, > > I would like to use the performance counters in libpfm4 on an AMD Opteron > running Ubuntu, kernel 2.6.31 . I have built libpfm4. I am mostly interesting > in two counters: LOCK WAIT and LOCK COUNT (I basically want to see how many > times a multi-threaded user-level program makes calls to functions that use > locks - like malloc and how much time is spent waiting on those locks). > > I don't know where to start - I can't find anything about locks in the > documentation for libpfm4 and also I don't know what these events are called > from the kernel's perspective. > You are talking about lock events not lock counters. You have to distinguish events from counters, i.e., registers. You program an event into a config register and you collect counts in a data register.
There are indeed lock events on AMD64. They are supported by libpfm4 for AMD64. The particular event is: PMU name : AMD64 (Family 10h RevB, Barcelona) (AMD64) Name : LOCKED_OPS Desc : Locked Operations Code : 0x24 Umask-00 : 0x01 : [EXECUTED] : The number of locked instructions executed Umask-01 : 0x02 : [CYCLES_SPECULATIVE_PHASE] : The number of cycles spent in speculative phase Umask-02 : 0x04 : [CYCLES_NON_SPECULATIVE_PHASE] : The number of cycles spent in non-speculative phase (including cache miss penalty) Umask-03 : 0x08 : [CYCLES_WAITING] : The number of cycles waiting for a cache hit (cache miss penalty). Umask-04 : 0x0f : [ALL] : All sub-events selected Modif-00 : 0x00 : [u] : monitor at priv level 1, 2, 3 (boolean) Modif-01 : 0x01 : [k] : monitor at priv level 0 (boolean) Modif-02 : 0x02 : [h] : monitor in hypervisor (boolean) Modif-03 : 0x03 : [g] : measure in guest (boolean) Modif-04 : 0x04 : [i] : invert (boolean) Modif-05 : 0x05 : [e] : edge level (boolean) Modif-06 : 0x06 : [c] : counter-mask in range [0-255] (integer) So grab libpfm4, build it. 2.6.31 comes with perf_events. Libpfm4 supports perf_events. But libpfm4 is not a tool, it's a library. The default perf_event tool is called perf, but it does not know all the AMD64 events. So instead, I suggest you use one of the libpfm4 perf_events examples, called task. For instance, you can do: $ task -e LOCK_OPS:CYCLES_WAITING my_program This will count the number of occurrences of this event at the user level. ------------------------------------------------------------------------------ Return on Information: Google Enterprise Search pays you back Get the facts. http://p.sf.net/sfu/google-dev2dev _______________________________________________ perfmon2-devel mailing list perfmon2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/perfmon2-devel