This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
using the kernel stack trace functions
- From: Tim Moore <timoore at redhat dot com>
- To: systemtap at sourceware dot org
- Date: Wed, 14 Jan 2009 18:57:36 +0100
- Subject: using the kernel stack trace functions
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)
}
}
}