using the kernel stack trace functions
Tim Moore
timoore@redhat.com
Wed Jan 14 17:58:00 GMT 2009
Hi,
I've been messing with using the built-in kernel stack tracing in system tap.
Unfortunately, it's not working yet in the context of my latencytap script, and
I'm not sure why. "Not working yet" means nothing is printed out. Does anyone
spot anything obvious?
Thanks,
Tim
In runtime/stack.c:
void _stp_stack_print_tsk(struct task_struct *tsk, int verbose, int levels)
{
int i;
unsigned long backtrace[MAXBACKTRACE];
struct stack_trace trace;
int maxLevels = min(levels, MAXBACKTRACE);
memset(&trace, 0, sizeof(trace));
trace.entries = &backtrace[0];
trace.max_entries = maxLevels;
trace.skip = 0;
save_stack_trace_tsk(tsk, &trace);
for (i = 0; i < maxLevels; ++i) {
if (backtrace[i] == 0 || backtrace[i] == ULONG_MAX)
break;
_stp_func_print(backtrace[i], verbose, 1);
}
}
The probe:
function _get_sleep_time:long(rq_param:long, p_param:long)
%{
struct rq *rq = (struct rq *)(unsigned long)THIS->rq_param;
struct task_struct *p = (struct task_struct *)(unsigned long)THIS->p_param;
struct sched_entity *se = &p->se;
u64 delta = cpu_clock(smp_processor_id()) - se->sleep_start;
if ((s64)delta < 0)
delta = 0;
THIS->__retvalue = delta;
%}
function print_backtrace (task:long)
%{
_stp_stack_print_tsk((struct task_struct *)THIS->task, 0, MAXTRACE);
%}
probe kernel.function("enqueue_task_fair") {
if ($wakeup == 1) {
this_sleep = _get_sleep_time($rq, $p)
if (this_sleep > 0) {
print_backtrace($p)
}
}
}
More information about the Systemtap
mailing list