summaryrefslogtreecommitdiffstats
path: root/tapset/LKET/timestamp.stp
diff options
context:
space:
mode:
authorguanglei <guanglei>2006-08-29 04:57:10 +0000
committerguanglei <guanglei>2006-08-29 04:57:10 +0000
commit9e4d76d8408ebd39704c96e11ae8b64de754d98d (patch)
tree064624b0edd2e73450bac1b2af6337c03d5ae959 /tapset/LKET/timestamp.stp
parentdc38c0ae43f0c98b203866eeeb88070d32db2c8d (diff)
downloadsystemtap-steved-9e4d76d8408ebd39704c96e11ae8b64de754d98d.tar.gz
systemtap-steved-9e4d76d8408ebd39704c96e11ae8b64de754d98d.tar.xz
systemtap-steved-9e4d76d8408ebd39704c96e11ae8b64de754d98d.zip
add another two kinds of timing mechanisms for LKET, i.e. get_cycles() and
sched_clock()
Diffstat (limited to 'tapset/LKET/timestamp.stp')
-rwxr-xr-xtapset/LKET/timestamp.stp67
1 files changed, 67 insertions, 0 deletions
diff --git a/tapset/LKET/timestamp.stp b/tapset/LKET/timestamp.stp
new file mode 100755
index 00000000..471177a9
--- /dev/null
+++ b/tapset/LKET/timestamp.stp
@@ -0,0 +1,67 @@
+%{
+#ifndef TIMING_GETCYCLES
+#define TIMING_GETCYCLES 0x01
+#endif
+#ifndef TIMING_GETTIMEOFDAY
+#define TIMING_GETTIMEOFDAY 0x02
+#endif
+#ifndef TIMING_SCHEDCLOCK
+#define TIMING_SCHEDCLOCK 0x03
+#endif
+
+#define MAX_TIMING_METHOD TIMING_SCHEDCLOCK
+
+long timing_method = TIMING_GETTIMEOFDAY;
+
+#ifndef _PFN_SCHEDCLOCK_TYPE
+#define _PFN_SCHEDCLOCK_TYPE
+typedef unsigned long long (* pfn_schedclock_type)(void);
+#endif
+
+pfn_schedclock_type pfn_schedclock = NULL;
+%}
+
+%{
+#ifdef CONFIG_CPU_FREQ
+static int __lket_time_cpufreq_callback(struct notifier_block *self,
+ unsigned long state, void *vfreqs);
+
+struct notifier_block __lket_time_notifier = {
+ .notifier_call = __lket_time_cpufreq_callback,
+};
+
+#endif
+%}
+
+function set_timing_method(method:long)
+%{
+ if(THIS->method == TIMING_SCHEDCLOCK) {
+ pfn_schedclock = (pfn_schedclock_type)kallsyms_lookup_name("sched_clock");
+ if(!pfn_schedclock) {
+ _stp_warn("Failed to lookup specified timing method sched_clock()\n");
+ return;
+ }
+ }
+ if(THIS->method > 0 && THIS->method <= MAX_TIMING_METHOD)
+ timing_method = THIS->method;
+%}
+
+function lket_init_time:long()
+%{
+ int ret = 0;
+#ifdef CONFIG_CPU_FREQ
+ if(timing_method == TIMING_GETCYCLES)
+ ret = cpufreq_register_notifier(&__lket_time_notifier,
+ CPUFREQ_TRANSITION_NOTIFIER);
+#endif
+ THIS->__retvalue = ret;
+%}
+
+function lket_kill_time()
+%{
+#ifdef CONFIG_CPU_FREQ
+ if(timing_method == TIMING_GETCYCLES)
+ cpufreq_unregister_notifier(&__lket_time_notifier,
+ CPUFREQ_TRANSITION_NOTIFIER);
+#endif
+%}