1*436bf2bcSAndroid Build Coastguard Worker // SPDX-License-Identifier: LGPL-2.1
2*436bf2bcSAndroid Build Coastguard Worker /*
3*436bf2bcSAndroid Build Coastguard Worker * Copyright (C) 2009 Red Hat Inc, Steven Rostedt <[email protected]>
4*436bf2bcSAndroid Build Coastguard Worker * Copyright (C) 2009 Johannes Berg <[email protected]>
5*436bf2bcSAndroid Build Coastguard Worker */
6*436bf2bcSAndroid Build Coastguard Worker #include <stdio.h>
7*436bf2bcSAndroid Build Coastguard Worker #include <stdlib.h>
8*436bf2bcSAndroid Build Coastguard Worker #include <string.h>
9*436bf2bcSAndroid Build Coastguard Worker
10*436bf2bcSAndroid Build Coastguard Worker #include "event-parse.h"
11*436bf2bcSAndroid Build Coastguard Worker #include "trace-seq.h"
12*436bf2bcSAndroid Build Coastguard Worker
timer_expire_handler(struct trace_seq * s,struct tep_record * record,struct tep_event * event,void * context)13*436bf2bcSAndroid Build Coastguard Worker static int timer_expire_handler(struct trace_seq *s,
14*436bf2bcSAndroid Build Coastguard Worker struct tep_record *record,
15*436bf2bcSAndroid Build Coastguard Worker struct tep_event *event, void *context)
16*436bf2bcSAndroid Build Coastguard Worker {
17*436bf2bcSAndroid Build Coastguard Worker trace_seq_printf(s, "hrtimer=");
18*436bf2bcSAndroid Build Coastguard Worker
19*436bf2bcSAndroid Build Coastguard Worker if (tep_print_num_field(s, "0x%llx", event, "timer",
20*436bf2bcSAndroid Build Coastguard Worker record, 0) == -1)
21*436bf2bcSAndroid Build Coastguard Worker tep_print_num_field(s, "0x%llx", event, "hrtimer",
22*436bf2bcSAndroid Build Coastguard Worker record, 1);
23*436bf2bcSAndroid Build Coastguard Worker
24*436bf2bcSAndroid Build Coastguard Worker trace_seq_printf(s, " now=");
25*436bf2bcSAndroid Build Coastguard Worker
26*436bf2bcSAndroid Build Coastguard Worker tep_print_num_field(s, "%llu", event, "now", record, 1);
27*436bf2bcSAndroid Build Coastguard Worker
28*436bf2bcSAndroid Build Coastguard Worker tep_print_func_field(s, " function=%s", event, "function",
29*436bf2bcSAndroid Build Coastguard Worker record, 0);
30*436bf2bcSAndroid Build Coastguard Worker return 0;
31*436bf2bcSAndroid Build Coastguard Worker }
32*436bf2bcSAndroid Build Coastguard Worker
timer_start_handler(struct trace_seq * s,struct tep_record * record,struct tep_event * event,void * context)33*436bf2bcSAndroid Build Coastguard Worker static int timer_start_handler(struct trace_seq *s,
34*436bf2bcSAndroid Build Coastguard Worker struct tep_record *record,
35*436bf2bcSAndroid Build Coastguard Worker struct tep_event *event, void *context)
36*436bf2bcSAndroid Build Coastguard Worker {
37*436bf2bcSAndroid Build Coastguard Worker trace_seq_printf(s, "hrtimer=");
38*436bf2bcSAndroid Build Coastguard Worker
39*436bf2bcSAndroid Build Coastguard Worker if (tep_print_num_field(s, "0x%llx", event, "timer",
40*436bf2bcSAndroid Build Coastguard Worker record, 0) == -1)
41*436bf2bcSAndroid Build Coastguard Worker tep_print_num_field(s, "0x%llx", event, "hrtimer",
42*436bf2bcSAndroid Build Coastguard Worker record, 1);
43*436bf2bcSAndroid Build Coastguard Worker
44*436bf2bcSAndroid Build Coastguard Worker tep_print_func_field(s, " function=%s", event, "function",
45*436bf2bcSAndroid Build Coastguard Worker record, 0);
46*436bf2bcSAndroid Build Coastguard Worker
47*436bf2bcSAndroid Build Coastguard Worker trace_seq_printf(s, " expires=");
48*436bf2bcSAndroid Build Coastguard Worker tep_print_num_field(s, "%llu", event, "expires", record, 1);
49*436bf2bcSAndroid Build Coastguard Worker
50*436bf2bcSAndroid Build Coastguard Worker trace_seq_printf(s, " softexpires=");
51*436bf2bcSAndroid Build Coastguard Worker tep_print_num_field(s, "%llu", event, "softexpires", record, 1);
52*436bf2bcSAndroid Build Coastguard Worker return 0;
53*436bf2bcSAndroid Build Coastguard Worker }
54*436bf2bcSAndroid Build Coastguard Worker
TEP_PLUGIN_LOADER(struct tep_handle * tep)55*436bf2bcSAndroid Build Coastguard Worker int TEP_PLUGIN_LOADER(struct tep_handle *tep)
56*436bf2bcSAndroid Build Coastguard Worker {
57*436bf2bcSAndroid Build Coastguard Worker tep_register_event_handler(tep, -1,
58*436bf2bcSAndroid Build Coastguard Worker "timer", "hrtimer_expire_entry",
59*436bf2bcSAndroid Build Coastguard Worker timer_expire_handler, NULL);
60*436bf2bcSAndroid Build Coastguard Worker
61*436bf2bcSAndroid Build Coastguard Worker tep_register_event_handler(tep, -1, "timer", "hrtimer_start",
62*436bf2bcSAndroid Build Coastguard Worker timer_start_handler, NULL);
63*436bf2bcSAndroid Build Coastguard Worker return 0;
64*436bf2bcSAndroid Build Coastguard Worker }
65*436bf2bcSAndroid Build Coastguard Worker
TEP_PLUGIN_UNLOADER(struct tep_handle * tep)66*436bf2bcSAndroid Build Coastguard Worker void TEP_PLUGIN_UNLOADER(struct tep_handle *tep)
67*436bf2bcSAndroid Build Coastguard Worker {
68*436bf2bcSAndroid Build Coastguard Worker tep_unregister_event_handler(tep, -1,
69*436bf2bcSAndroid Build Coastguard Worker "timer", "hrtimer_expire_entry",
70*436bf2bcSAndroid Build Coastguard Worker timer_expire_handler, NULL);
71*436bf2bcSAndroid Build Coastguard Worker
72*436bf2bcSAndroid Build Coastguard Worker tep_unregister_event_handler(tep, -1, "timer", "hrtimer_start",
73*436bf2bcSAndroid Build Coastguard Worker timer_start_handler, NULL);
74*436bf2bcSAndroid Build Coastguard Worker }
75