summaryrefslogtreecommitdiffstats
path: root/runtime/probes/test4
diff options
context:
space:
mode:
authorhunt <hunt>2005-04-07 15:12:19 +0000
committerhunt <hunt>2005-04-07 15:12:19 +0000
commit979f20e0ecb8d287af1aedf33ac0c3b50ac9003d (patch)
tree19a2fecdafeea759885360d0df8022bddce7e7a3 /runtime/probes/test4
parente32551b18f4560056d2d482f5e1505b1b98fa82a (diff)
downloadsystemtap-steved-979f20e0ecb8d287af1aedf33ac0c3b50ac9003d.tar.gz
systemtap-steved-979f20e0ecb8d287af1aedf33ac0c3b50ac9003d.tar.xz
systemtap-steved-979f20e0ecb8d287af1aedf33ac0c3b50ac9003d.zip
Update to use relayfs, new I/O.
Diffstat (limited to 'runtime/probes/test4')
-rw-r--r--runtime/probes/test4/Makefile2
-rw-r--r--runtime/probes/test4/dtr.c81
-rwxr-xr-xruntime/probes/test4/stp39
3 files changed, 99 insertions, 23 deletions
diff --git a/runtime/probes/test4/Makefile b/runtime/probes/test4/Makefile
index 7afe0c0f..613eff1f 100644
--- a/runtime/probes/test4/Makefile
+++ b/runtime/probes/test4/Makefile
@@ -3,7 +3,7 @@
#
# make -C path/to/kernel/src M=`pwd` modules STP_RUNTIME=path_to_systemtap_rt
-CFLAGS += -I $(STP_RUNTIME) -D KALLSYMS_LOOKUP_NAME=$(KALLSYMS_LOOKUP_NAME) \
+CFLAGS += -I $(STP_RUNTIME) -I $(STP_RUNTIME)/relayfs -D KALLSYMS_LOOKUP_NAME=$(KALLSYMS_LOOKUP_NAME) \
-D KALLSYMS_LOOKUP=$(KALLSYMS_LOOKUP) -D KTA=$(KTA)
obj-m := dtr.o
diff --git a/runtime/probes/test4/dtr.c b/runtime/probes/test4/dtr.c
index 8c6257e2..814bb61d 100644
--- a/runtime/probes/test4/dtr.c
+++ b/runtime/probes/test4/dtr.c
@@ -2,15 +2,24 @@
#define HASH_TABLE_SIZE (1<<HASH_TABLE_BITS)
#define BUCKETS 16 /* largest histogram width */
+#define STP_NETLINK_ONLY
+#define STP_NUM_STRINGS 1
+
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <net/sock.h>
+#include <linux/netlink.h>
+
#include "runtime.h"
-#include "io.c"
#include "map.c"
#include "probes.c"
+#include "stack.c"
MODULE_DESCRIPTION("SystemTap probe: test4");
MODULE_AUTHOR("Martin Hunt <hunt@redhat.com>");
-MAP opens, reads, writes;
+
+MAP opens, reads, writes, traces;
asmlinkage long inst_sys_open (const char __user * filename, int flags, int mode)
{
@@ -36,6 +45,18 @@ asmlinkage ssize_t inst_sys_write (unsigned int fd, const char __user * buf, siz
return 0;
}
+int inst_show_cpuinfo(struct seq_file *m, void *v)
+{
+ String str = _stp_string_init (0);
+ _stp_stack_print (0,0);
+ _stp_stack_print (1,0);
+ _stp_list_add (traces, _stp_stack_sprint(str, 0, 0));
+
+ jprobe_return();
+ return 0;
+}
+
+
static struct jprobe dtr_probes[] = {
{
.kp.addr = (kprobe_opcode_t *)"sys_open",
@@ -49,6 +70,10 @@ static struct jprobe dtr_probes[] = {
.kp.addr = (kprobe_opcode_t *)"sys_write",
.entry = (kprobe_opcode_t *) inst_sys_write
},
+ {
+ .kp.addr = (kprobe_opcode_t *)"show_cpuinfo",
+ .entry = (kprobe_opcode_t *) inst_show_cpuinfo,
+ },
};
#define MAX_DTR_ROUTINE (sizeof(dtr_probes)/sizeof(struct jprobe))
@@ -57,46 +82,58 @@ static int init_dtr(void)
{
int ret;
+ if (_stp_netlink_open() < 0)
+ return -1;
+
opens = _stp_map_new (1000, INT64);
reads = _stp_map_new (1000, STAT);
writes = _stp_map_new (1000, STAT);
+ traces = _stp_list_new (1000, STRING);
ret = _stp_register_jprobes (dtr_probes, MAX_DTR_ROUTINE);
- dlog("instrumentation is enabled...\n");
+ _stp_log("instrumentation is enabled...\n");
return ret;
-
}
-static void cleanup_dtr(void)
+static void probe_exit (void)
{
struct map_node_stat *st;
struct map_node_int64 *ptr;
+ struct map_node_str *sptr;
_stp_unregister_jprobes (dtr_probes, MAX_DTR_ROUTINE);
- for (ptr = (struct map_node_int64 *)_stp_map_start(opens); ptr;
- ptr = (struct map_node_int64 *)_stp_map_iter (opens,(struct map_node *)ptr))
- dlog ("opens[%s] = %lld\n", key1str(ptr), ptr->val);
- dlog ("\n");
-
- for (st = (struct map_node_stat *)_stp_map_start(reads); st;
- st = (struct map_node_stat *)_stp_map_iter (reads,(struct map_node *)st))
- dlog ("reads[%s] = [count=%lld sum=%lld min=%lld max=%lld]\n", key1str(st), st->stats.count, st->stats.sum,
- st->stats.min, st->stats.max);
- dlog ("\n");
-
- for (st = (struct map_node_stat *)_stp_map_start(writes); st;
- st = (struct map_node_stat *)_stp_map_iter (writes,(struct map_node *)st))
- dlog ("writes[%s] = [count=%lld sum=%lld min=%lld max=%lld]\n", key1str(st), st->stats.count, st->stats.sum,
- st->stats.min, st->stats.max);
- dlog ("\n");
+ foreach (traces, sptr) {
+ _stp_printf ("trace: %s\n", sptr->str);
+ _stp_print_flush ();
+ }
+
+ foreach (opens, ptr) {
+ _stp_printf ("opens[%s] = %lld\n", key1str(ptr), ptr->val);
+ _stp_print_flush ();
+ }
+
+ foreach (reads, st) {
+ _stp_printf ("reads[%s] = [count=%lld sum=%lld min=%lld max=%lld]\n", key1str(st),
+ st->stats.count, st->stats.sum, st->stats.min, st->stats.max);
+ _stp_print_flush ();
+ }
+
+ foreach (writes, st) {
+ _stp_printf ("writes[%s] = [count=%lld sum=%lld min=%lld max=%lld]\n", key1str(st),
+ st->stats.count, st->stats.sum, st->stats.min, st->stats.max);
+ _stp_print_flush();
+ }
_stp_map_del (opens);
_stp_map_del (reads);
_stp_map_del (writes);
+}
- dlog("EXIT\n");
+static void cleanup_dtr(void)
+{
+ _stp_netlink_close();
}
module_init(init_dtr);
diff --git a/runtime/probes/test4/stp b/runtime/probes/test4/stp
new file mode 100755
index 00000000..d10fcaab
--- /dev/null
+++ b/runtime/probes/test4/stp
@@ -0,0 +1,39 @@
+#!/bin/bash
+if [ -n "$1" ]
+then
+ modulename=$1
+else
+ echo "Usage: stp modulename"
+ exit
+fi
+
+RELAYFS=`lsmod | grep relayfs |awk '{print $1}'`
+if [ "$RELAYFS" != "relayfs" ]
+then
+ /sbin/insmod ../../relayfs/relayfs.ko
+fi
+
+if [ ! -d "/mnt/relay" ]
+then
+ mkdir /mnt/relay
+fi
+
+MOUNT=`mount | grep relayfs |awk '{print $1}'`
+if [ "$MOUNT" != "relayfs" ]
+then
+ mount -t relayfs relayfs /mnt/relay
+fi
+
+/sbin/insmod $modulename
+
+# print to screen only, 4 8K buffers
+#../../stpd/stpd -p -b 8192 -n 4
+
+# print to screen and log to files, 4 8K buffers
+../../stpd/stpd -b 8192 -n 4
+
+# no screen or log
+#../../stpd/stpd -q -b 8192 -n 4
+
+# stpd will remove module when it exits
+#/sbin/rmmod $modulename