This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[Systemtap][RFC] sample test script and tapset for markers
- From: Masami Hiramatsu <mhiramat at redhat dot com>
- To: systemtap-ml <systemtap at sources dot redhat dot com>
- Cc: ltt-dev at lists dot casi dot polymtl dot ca, Hideo AOKI <haoki at redhat dot com>, Takahiro Yasui <tyasui at redhat dot com>
- Date: Tue, 26 Aug 2008 12:06:47 -0400
- Subject: [Systemtap][RFC] sample test script and tapset for markers
Hi,
Here is a tapset and sample script for markers.
This tapset partially covers LTTng markers(with our additional
patches for markers which I attached to the previous mails).
In this marker tapset, I used the marker.* namespace for
markers.
ex)
marker.irq.softirq.exit
2nd symbol means subsystem and 3nd or later symbols are
depends on the subsystem.
As you can see in sample.stp, we can easily specify
the events occurred on each subsystem.
Thank you,
--
Masami Hiramatsu
Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division
e-mail: mhiramat@redhat.com
//
// kernel marker tapset
//
// 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.
/*
* Each marker has "name" variable which stores marker name.
*/
/*-------------------------------------------*
* marker.irq.* - IRQ related markers
*-------------------------------------------*/
/*
* probe marker.irq.hardirq.entry
*
* Fires just before handing a hard interrupt.
*
* Context:
* A hard interrupt occurs.
*
* Arguments:
* irq_id - the id of hard irq.
* kernel_mode - boolean indicating whether the interrupt occured
* in kernel mode.
*/
probe marker.irq.hardirq.entry
= kernel.mark("kernel_irq_entry")
{
name = "kernel_irq_entry"
irq_id = $arg1
kernel_mode = $arg2
}
/*
* probe marker.irq.hardirq.exit
*
* Fires after handling a hard interrupt.
*
* Context:
* A hard interrupt was handled.
*
* Arguments:
* irq_id - the id of hard irq.
* retval - return value of handle_IRQ_event().
*/
probe marker.irq.hardirq.exit
= kernel.mark("kernel_irq_exit")
{
name = "kernel_irq_exit"
irq_id = $arg1
retval = $arg2
}
/*
* probe marker.irq.softirq.enter
*
* Fires before calling softirq handler.
*
* Context:
* Softirq handler will be invoked.
*
* Arguments:
* softirq_id - the id of softirq.
* func - the pointer of softirq handler.
*
* Note:
* On specific architecture(ex. ia64) the "func" is not the address of
* the actuall function. You might need to derefer *func for getting
* actuall adress.
*/
probe marker.irq.softirq.entry
= kernel.mark("kernel_softirq_entry")
{
name = "kernel_softirq_entry"
softirq_id = $arg1
func = $arg2
}
/*
* probe marker.irq.softirq.exit
*
* Fires after calling softirq handler.
*
* Context:
* Softirq handler was handled.
*
* Arguments:
* softirq_id - the id of softirq.
*/
probe marker.irq.softirq.exit
= kernel.mark("kernel_softirq_exit")
{
name = "kernel_softirq_exit"
softirq_id = $arg1
}
/*
* probe marker.irq.tasklet_low.enter
*
* Fires before calling tasklet_low handler.
*
* Context:
* Tasklet(low) handler will be invoked.
*
* Arguments:
* func - the pointer of tasklet_low handler.
* data - the data passed to the handler.
*
* Note:
* On specific architecture(ex. ia64) the "func" is not the address of
* the actuall function. You might need to derefer *func for getting
* actuall adress.
*/
probe marker.irq.tasklet_low.entry
= kernel.mark("kernel_tasklet_low_entry")
{
name = "kernel_tasklet_low_entry"
func = $arg1
data = $arg2
}
/*
* probe marker.irq.tasklet_low.exit
*
* Fires after calling tasklet_low handler.
*
* Context:
* Tasklet(low) handler was handled.
*
* Arguments:
* func - the pointer of tasklet_low handler.
* data - the data passed to the handler.
*
* Note:
* On specific architecture(ex. ia64) the "func" is not the address of
* the actuall function. You might need to derefer *func for getting
* actuall adress.
*/
probe marker.irq.tasklet_low.exit
= kernel.mark("kernel_tasklet_low_exit")
{
name = "kernel_tasklet_low_exit"
func = $arg1
data = $arg2
}
/*
* probe marker.irq.tasklet_high.enter
*
* Fires before calling tasklet_high handler.
*
* Context:
* Tasklet(high) handler will be invoked.
*
* Arguments:
* func - the pointer of tasklet_high handler.
* data - the data passed to the handler.
*
* Note:
* On specific architecture(ex. ia64) the "func" is not the address of
* the actuall function. You might need to derefer *func for getting
* actuall adress.
*/
probe marker.irq.tasklet_high.entry
= kernel.mark("kernel_tasklet_high_entry")
{
name = "kernel_tasklet_high_entry"
func = $arg1
data = $arg2
}
/*
* probe marker.irq.tasklet_high.exit
*
* Fires after calling tasklet_high handler.
*
* Context:
* Tasklet(high) handler was handled.
*
* Arguments:
* func - the pointer of tasklet_high handler.
* data - the data passed to the handler.
*
* Note:
* On specific architecture(ex. ia64) the "func" is not the address of
* the actuall function. You might need to derefer *func for getting
* actuall adress.
*/
probe marker.irq.tasklet_high.exit
= kernel.mark("kernel_tasklet_high_exit")
{
name = "kernel_tasklet_high_exit"
func = $arg1
data = $arg2
}
/*-------------------------------------------*
* marker.process.* - Process related markers
*-------------------------------------------*/
/*
* probe marker.process.free
*
* Fires when task_struct is released.
*
* Context:
* A process is released.
*
* Arguments:
* pid - released process pid.
*/
probe marker.process.free
= kernel.mark("kernel_process_free")
{
name = "kernel_process_free"
pid = $arg1
}
/*
* probe marker.process.wait
*
* Fires when do_wait() is called.
*
* Context:
* Current process waits another process.
*
* Arguments:
* pid - waiting target pid.
*/
probe marker.process.wait
= kernel.mark("kernel_process_wait")
{
name = "kernel_process_wait"
pid = $arg1
}
/*
* probe marker.process.exit
*
* Fires when do_exit() is called.
*
* Context:
* A process exits.
*
* Arguments:
* pid - exit process pid.
*/
probe marker.process.exit
= kernel.mark("kernel_process_exit")
{
name = "kernel_process_exit"
pid = $arg1
}
/*
* probe marker.process.fork
*
* Fires when a process forked/cloned.
*
* Context:
* A process forked/cloned.
*
* Arguments:
* pid - parent pid.
* parent_pid - same as above "pid".
* child_pid - forked child pid.
* child_tgid - forked child thread group id.
*/
probe marker.process.fork
= kernel.mark("kernel_process_fork")
{
name = "kernel_process_fork"
pid = $arg1
parent_pid = $arg1
child_pid = $arg2
child_tgid = $arg3
}
/*-----------------------------------------------*
* marker.scheduler.* - scheduler related markers
*-----------------------------------------------*/
probe __marker.scheduler.wakeup = kernel.mark("kernel_sched_wakeup")
{
name = "kernel_sched_wakeup"
}
probe __marker.scheduler.wakeup_new = kernel.mark("kernel_sched_wakeup_new")
{
name = "kernel_sched_wakeup_new"
}
/*
* probe marker.scheduler.wakeup
*
* Fires a process wakeup.
*
* Context:
* A process wakeup.
*
* Arguments:
* pid - wakeup process pid.
* state - process task state.
* cpu_id - the id of cpu where the process wakeup.
*/
probe marker.scheduler.wakeup
= __marker.scheduler.wakeup,
__marker.scheduler.wakeup_new
{
pid = $arg1
state = $arg2
cpu_id = $arg3
}
/*
* probe marker.scheduler.switch
*
* Fires scheduler switches tasks.
*
* Context:
* A process is switching to another process.
*
* Arguments:
* prev_pid - the pid of the process from which next task is switched.
* next_pid - the pid of the process to which previous task switches.
* prev_state - task state of previous process
* prev_prio - task priority of previous process
* next_prio - task priority of next process
*/
probe marker.scheduler.switch
= kernel.mark("kernel_sched_switch")
{
name = "kernel_sched_switch"
prev_pid = $arg1
next_pid = $arg2
prev_state = $arg3
prev_prio = $arg4
next_prio = $arg5
}
#!/usr/bin/stap
#
# sample script for kernel marker
#
#------------------------------------------------------------
# Counter
#------------------------------------------------------------
global num
#------------------------------------------------------------
# Probes
#------------------------------------------------------------
#
# Interrupts
#
probe marker.irq.* {
num[name] <<< 1
}
#
# Scheduler
#
probe marker.scheduler.* {
num[name] <<< 1
}
#
# Process
#
probe marker.process.* {
num[name] <<< 1
}
#------------------------------------------------------------
# begin/end
#------------------------------------------------------------
probe begin {
printf("[STP] --- start ---\n")
}
probe end {
printf("[STP] --- end ---\n")
foreach (n+ in num) {
printf("%s is hit %d times\n", n, @count(num[n]))
}
}