|
Server : Apache/2.2.2 (Fedora) System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686 User : apache ( 48) PHP Version : 5.2.9 Disable Function : NONE Directory : /usr/share/systemtap/tapset/LKET/ |
Upload File : |
// Copyright (C) 2005, 2006 IBM Corp.
//
// This file is part of systemtap, and is free software. You can
// redistribute it and/or modify it under the terms of the GNU General
// Public License (GPL); either version 2, or (at your option) any
// later version.
/**********************************************************
* Dispatching when the cpu is idle or when a new process *
* is chosen to run. *
* *
* The actual locations for these two kinds of events are *
* the labels go_idle and switch_tasks inside the function *
* schedule. But currently SystemTap doesn't support *
* specifying probe points by label. *
* *
**********************************************************/
probe addevent.tskdispatch
= addevent.tskdispatch.cpuidle,
addevent.tskdispatch.ctxswitch
{}
/* Only applicable to SMP systems */
probe addevent.tskdispatch.cpuidle
+= _addevent.tskdispatch.cpuidle
{
update_record()
}
probe _addevent.tskdispatch.cpuidle
= scheduler.balance
{
/* we didn't call filter_by_pid() here,
so that we can get all the idle events
despite how the cpu enters idle */
log_cpuidle_tracedata(HOOKID_TASK_CPUIDLE)
}
probe addevent.tskdispatch.ctxswitch
+= _addevent.tskdispatch.ctxswitch
{
update_record()
}
probe _addevent.tskdispatch.ctxswitch
= scheduler.ctxswitch
{
target_pid = target()
cur_pid = pid()
if( stp_pid() != cur_pid ) { /* skip staprun itself */
if(target_pid == 0 || (target_pid !=0 && (prev_pid == target_pid
|| next_pid == target_pid))) {
log_ctxswitch_tracedata(HOOKID_TASK_CTXSWITCH, prev_task, next_task)
}
}
}
function log_ctxswitch_tracedata(var_id:long, prev:long, next_pid:long)
%{
struct task_struct *prev_tsk, *next_tsk;
prev_tsk = (struct task_struct *)((long)THIS->prev);
next_tsk = (struct task_struct *)((long)THIS->next_pid);
_lket_trace(_GROUP_TASK, THIS->var_id, "%4b%4b%1b", (_FMT_)prev_tsk->pid,
(_FMT_)next_tsk->pid, (_FMT_)prev_tsk->state);
%}
function log_cpuidle_tracedata(var_id:long)
%{
struct task_struct *cur = current;
_lket_trace(_GROUP_TASK, THIS->var_id, "%4b", (_FMT_)cur->pid);
%}