xref: /openbmc/linux/tools/tracing/rtla/src/osnoise.h (revision 94d964e5)
1 // SPDX-License-Identifier: GPL-2.0
2 #include "trace.h"
3 
4 /*
5  * osnoise_context - read, store, write, restore osnoise configs.
6  */
7 struct osnoise_context {
8 	int			flags;
9 	int			ref;
10 
11 	char			*curr_cpus;
12 	char			*orig_cpus;
13 
14 	/* 0 as init value */
15 	unsigned long long	orig_runtime_us;
16 	unsigned long long	runtime_us;
17 
18 	/* 0 as init value */
19 	unsigned long long	orig_period_us;
20 	unsigned long long	period_us;
21 
22 	/* 0 as init value */
23 	long long		orig_timerlat_period_us;
24 	long long		timerlat_period_us;
25 
26 	/* -1 as init value because 0 is disabled */
27 	long long		orig_stop_us;
28 	long long		stop_us;
29 
30 	/* -1 as init value because 0 is disabled */
31 	long long		orig_stop_total_us;
32 	long long		stop_total_us;
33 
34 	/* -1 as init value because 0 is disabled */
35 	long long		orig_print_stack;
36 	long long		print_stack;
37 };
38 
39 /*
40  * *_INIT_VALs are also invalid values, they are used to
41  * communicate errors.
42  */
43 #define OSNOISE_OPTION_INIT_VAL	(-1)
44 #define OSNOISE_TIME_INIT_VAL	(0)
45 
46 struct osnoise_context *osnoise_context_alloc(void);
47 int osnoise_get_context(struct osnoise_context *context);
48 void osnoise_put_context(struct osnoise_context *context);
49 
50 int osnoise_set_cpus(struct osnoise_context *context, char *cpus);
51 void osnoise_restore_cpus(struct osnoise_context *context);
52 
53 int osnoise_set_runtime_period(struct osnoise_context *context,
54 			       unsigned long long runtime,
55 			       unsigned long long period);
56 void osnoise_restore_runtime_period(struct osnoise_context *context);
57 
58 int osnoise_set_stop_us(struct osnoise_context *context,
59 			long long stop_us);
60 void osnoise_restore_stop_us(struct osnoise_context *context);
61 
62 int osnoise_set_stop_total_us(struct osnoise_context *context,
63 			      long long stop_total_us);
64 void osnoise_restore_stop_total_us(struct osnoise_context *context);
65 
66 int osnoise_set_timerlat_period_us(struct osnoise_context *context,
67 				   long long timerlat_period_us);
68 void osnoise_restore_timerlat_period_us(struct osnoise_context *context);
69 
70 void osnoise_restore_print_stack(struct osnoise_context *context);
71 int osnoise_set_print_stack(struct osnoise_context *context,
72 			    long long print_stack);
73 
74 /*
75  * osnoise_tool -  osnoise based tool definition.
76  */
77 struct osnoise_tool {
78 	struct trace_instance		trace;
79 	struct osnoise_context		*context;
80 	void				*data;
81 	void				*params;
82 	time_t				start_time;
83 };
84 
85 void osnoise_destroy_tool(struct osnoise_tool *top);
86 struct osnoise_tool *osnoise_init_tool(char *tool_name);
87 struct osnoise_tool *osnoise_init_trace_tool(char *tracer);
88 
89 int osnoise_hist_main(int argc, char *argv[]);
90 int osnoise_top_main(int argc, char **argv);
91 int osnoise_main(int argc, char **argv);
92