Model-Specific Register
William Cohen
wcohen@redhat.com
Fri Oct 13 15:10:00 GMT 2006
Lorenzo Cavallaro wrote:
> Hi,
>
> On Tue, Oct 10, 2006 at 03:46:29PM -0400, Frank Ch. Eigler wrote:
>
>>> Beside that, I would like to measure (count) the number of branches (call,
>>> jmp, jcc, loop) executed so far by a given process while it's executing in
>>> user space. Do you think MSR (in particular) branch_retired register could
>>> be useful for what I'm trying to do?
>>
>>Certainly. Systemtap proper does not expose those registers yet, but
>>using e.g. inline C code, it should be able to pull out such
>>information.
>
>
> Cool. Any ideas (all the list, I mean :-)) on how to do it "from scratch"?
> Never played with MSR at all.
>
>
>>> Moreover, I would like to save this register (or a combo of
>>> registers) into the process task_struct since I would like to
>>> keep this counter accross processes' context switch [...]
>>
>>Check out the perfmon2 patches for the kernel. Among other things, they
>>do this sort of context switch tracking.
>
>
> Fine, thx! I'll check it out ASAP. :-)
There is some example code in systemtap bz#909 using perfmon2 to setup the
registers using Perfmon2. You can also take a look at the patches for the
runtime to figure out how to access the perfmon hw:
http://sources.redhat.com/bugzilla/show_bug.cgi?id=909
Perfmon2 has support to keep count of events on a per-thread basis. So you might
not need to do much in the way of modification to accomplish what you want.
http://perfmon2.sourceforge.net/
-Will
More information about the Systemtap
mailing list