This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Capturing load average from within systemtap script...


Rick Beldin <rick.beldin@hp.com> writes:

> [...]
> I've been struggling for a bit on how to (or if possible) to capture the
> value of avenrun (declared as: 
>
> unsigned long avenrun[3];
> EXPORT_SYMBOL(avenrun);
> [...]

> I've tried accessing it both as an array or as a single value.  I either
> end up with syntax errors or things like this: 
>
>  sudo stap -g loadavg_trigger.stp 
> ERROR: kernel long copy fault at 0x0000000000000000 near identifier
> 'avenrun' at loadavg_trigger.stp:13:27
> timer 0 0
> WARNING: Number of errors: 1, skipped probes: 0

Your script is accessing "avenrun" by that name - and this is treated
as a systemtap numeric variable (with initial value 0).  kernel_long
dereferences it, and you get the fault message.

One way to access that is "$avenrun[0]" through "[2]", in the scope of
a kprobe that is set in the same compilation unit.  If that doesn't
work for some reason, you can use a smidgen of embedded-C:

%{
#include <some_header_that_declares_avenrun>
%}
function get_avenrun:long (idx:long) %{ /* pure */
    if (idx < 0 || idx > 2) return 0;
    else return avenrun[idx];
%}
probe foo { /* do something with */ get_avenrun(0) }


- FChE


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]