diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index e91c29f..bd80c14 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -54,6 +54,7 @@ void update_xtime_cache(u64 nsec) } struct clocksource *clock; +EXPORT_SYMBOL(clock); #ifdef CONFIG_GENERIC_TIME diff --git a/kernel/timer.c b/kernel/timer.c index 03bc7f1..add3a1d 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -1064,6 +1064,7 @@ static inline void update_times(unsigned long ticks) void do_timer(unsigned long ticks) { + trace_mark(apic_timer_tick, "tick = %lu", ticks); jiffies_64 += ticks; update_times(ticks); } diff --git a/samples/markers/Makefile b/samples/markers/Makefile index 6d72312..94d2ac7 100644 --- a/samples/markers/Makefile +++ b/samples/markers/Makefile @@ -1,4 +1,4 @@ # builds the kprobes example kernel modules; # then to use one (as root): insmod -obj-$(CONFIG_SAMPLE_MARKERS) += probe-example.o marker-example.o +obj-$(CONFIG_SAMPLE_MARKERS) += probe-example.o marker-example.o test-apic.o diff --git a/samples/markers/test-apic.c b/samples/markers/test-apic.c new file mode 100644 index 0000000..a1b1107 --- /dev/null +++ b/samples/markers/test-apic.c @@ -0,0 +1,48 @@ +#include +#include +#include +#include +#include +#include + +extern struct clocksource *clock; +static cycle_t cycle_prev, cycle_cur; + +void probe_apic_timer_event(void *data, void *call_data, + const char *format, va_list *args) +{ + unsigned long tick; + + tick = va_arg(*args, typeof(tick)); + + cycle_cur = clocksource_read(clock); + if (cycle_prev) { + printk(KERN_INFO "tick = %lu, apic tick timer interval is %ld\n", + tick, cyc2ns(clock, cycle_cur - cycle_prev)); + } + + cycle_prev = cycle_cur; +} + +static int __init probe_init(void) +{ + int r; + + r = marker_probe_register("apic_timer_tick", "tick = %lu", + probe_apic_timer_event, NULL); + + if (r) + printk(KERN_INFO "Unable to register probe for apic timer tick\n"); + + return 0; +} + +static void __exit probe_exit(void) +{ + marker_probe_unregister("apic_timer_tick", probe_apic_timer_event, NULL); +} + +module_init(probe_init); +module_exit(probe_exit); + +MODULE_LICENSE("GPL");