This is the mail archive of the
systemtap@sources.redhat.com
mailing list for the systemtap project.
Attempting to try out "asynchronous probes" and the current runtime...
- From: "Spirakis, Charles" <charles dot spirakis at intel dot com>
- To: <systemtap at sources dot redhat dot com>
- Date: Wed, 6 Jul 2005 20:31:47 -0700
- Subject: Attempting to try out "asynchronous probes" and the current runtime...
All --
I'm playing around with an "asynchronous probe" concept and the current
runtime using simple os timers (code is below). Anyone have experience
with task_pt_regs() function? As you can see, I'm trying to grab the
"current" pt_regs in the home of seeing the eip at the time of the timer
interrupt, but the data I get is not what I'd hoped.
This is running on a Pentium M laptop with the mm2 kernel,
CONFIG_PREEMPT_NONE=y, other preemption configs are not set.
-- charles
============= os_timer.c ==============
/* Framework for new probes using the runtime */
/* os includes */
#include "linux/timer.h"
/* define this if you don't want to use relayfs. Normally */
/* you want relayfs, unless you need a realtime stream of data */
/* #define STP_NETLINK_ONLY */
/* How many strings to allocate. see strings.c. Default is 0. */
#define STP_NUM_STRINGS 1
/* maximum size for a string. default is 2048 */
#define STP_STRING_SIZE 2048
/* size of strings saved in maps */
#define MAP_STRING_LENGTH 256
/* width of histograms. Default 50 */
#define HIST_WIDTH 50
/* always include this. Put all non-map defines above it. */
#include "runtime.h"
/* since we don't have aggregation maps yet, try regular maps */
#define NEED_INT64_VALS
#define KEY1_TYPE INT64
#include "map-keys.c"
#include "map.c"
#include "stat.c"
#include "stack.c"
MODULE_DESCRIPTION("SystemTap probe: os_timer");
MODULE_AUTHOR("Charles Spirakis <charles.spirakis@intel.com>");
Stat addr;
MAP cur_addr;
/* An asynchorous probe entry point */
void inst_async(struct pt_regs *regs)
{
unsigned long ip = regs->eip;
/* can we generate a histogram of ip addresses seen? */
_stp_stat_add(addr, 1);
/* Create a map of interrupted addresses seen */
/* really want a map of image name / address */
_stp_map_key_int64(cur_addr, ip);
_stp_map_add_int64(cur_addr, 1);
/* Need _stp_stack() and _stp_ustack()? */
/* _stp_image() and aggregation maps */
}
static struct timer_list timer;
/* Helper function to convert from os timer callback into */
/* generic asynchronous entry point form */
static void os_timer_callback(unsigned long val)
{
struct pt_regs *regs;
/* setup the next timeout now so it doesn't drift */
/* due to processing the async probe code */
mod_timer(&timer, jiffies + val);
/* determine pt_regs from the kernel stack */
regs = task_pt_regs(current);
/* Call the asynchronous probe with a ptregs struct */
inst_async(regs);
}
/* called when the module loads. */
int init_module(void)
{
int ret;
TRANSPORT_OPEN;
addr = _stp_stat_init(HIST_LINEAR, 0, 1000, 100);
cur_addr = _stp_map_new_int64(1000, INT64);
/* register the os_timer */
init_timer(&timer);
timer.expires = jiffies + 50;
timer.function = os_timer_callback;
/* data is usd for defining when the next timeout shoud occur */
timer.data = 50;
add_timer(&timer);
ret = 0;
return ret;
}
static void probe_exit (void)
{
/* unregister the os_timer */
del_timer_sync(&timer);
/* print out any colledted data, etc */
_stp_printf ("os timer done.\n");
_stp_stat_print (addr, "addr: count:%C sum:%S avg:%A min:%m
max:%M\n%H",
0);
_stp_map_print (cur_addr, "Count: %d\tInterrupts: %1P");
_stp_map_del(cur_addr);
_stp_print_flush();
}
/* required */
void cleanup_module(void)
{
_stp_transport_close();
}
MODULE_LICENSE("GPL");