Instrumenting context switches

Martin Hunt hunt@redhat.com
Thu Nov 30 18:22:00 GMT 2006


On Wed, 2006-11-29 at 18:25 -0500, Perry Cheng wrote:

> probe kernel.function("__switch_to")
> {
>         doSwitchTo(gettimeofday_us(), $prev_p, $next_p);
> }
> 
> function doSwitchTo(timeus:long, prev:long, next:long)
> %{
>         _stp_printf("SWITCHCOUNT = %ld\n", switchCount); 
> <------------------------------ BAD LINE
>         switchCount++;
> }%

Obviously the code fragment above is not exactly what you are using to
reproduce the bug. (You can't use keywords as parameter names,
uninitialized switchCount, "}%", etc).  I tried the following and did
not see any problems.  Can you give more details (arch, OS, etc) on how
to reproduce?

%{
	long switchCount = 1000000;
%}

function doSwitchTo (t:long, p:long, n:long) %{
	_stp_printf("SWITCHCOUNT = %ld\n", switchCount); 
	switchCount++;
%}

probe kernel.function("__switch_to")
{
        doSwitchTo(gettimeofday_us(), $prev_p, $next_p);
}





More information about the Systemtap mailing list