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