File Index
Files and directories
Sign in
FILE

common.h

File preview with syntax highlighting.

linux-6.19.14/tools/tracing/rtla/src/common.h C
  1/* SPDX-License-Identifier: GPL-2.0 */
  2#pragma once
  3
  4#include "actions.h"
  5#include "timerlat_u.h"
  6#include "trace.h"
  7#include "utils.h"
  8
  9/*
 10 * osnoise_context - read, store, write, restore osnoise configs.
 11 */
 12struct osnoise_context {
 13	int			flags;
 14	int			ref;
 15
 16	char			*curr_cpus;
 17	char			*orig_cpus;
 18
 19	/* 0 as init value */
 20	unsigned long long	orig_runtime_us;
 21	unsigned long long	runtime_us;
 22
 23	/* 0 as init value */
 24	unsigned long long	orig_period_us;
 25	unsigned long long	period_us;
 26
 27	/* 0 as init value */
 28	long long		orig_timerlat_period_us;
 29	long long		timerlat_period_us;
 30
 31	/* 0 as init value */
 32	long long		orig_tracing_thresh;
 33	long long		tracing_thresh;
 34
 35	/* -1 as init value because 0 is disabled */
 36	long long		orig_stop_us;
 37	long long		stop_us;
 38
 39	/* -1 as init value because 0 is disabled */
 40	long long		orig_stop_total_us;
 41	long long		stop_total_us;
 42
 43	/* -1 as init value because 0 is disabled */
 44	long long		orig_print_stack;
 45	long long		print_stack;
 46
 47	/* -1 as init value because 0 is off */
 48	int			orig_opt_irq_disable;
 49	int			opt_irq_disable;
 50
 51	/* -1 as init value because 0 is off */
 52	int			orig_opt_workload;
 53	int			opt_workload;
 54};
 55
 56extern struct trace_instance *trace_inst;
 57extern int stop_tracing;
 58
 59struct hist_params {
 60	char			no_irq;
 61	char			no_thread;
 62	char			no_header;
 63	char			no_summary;
 64	char			no_index;
 65	char			with_zeros;
 66	int			bucket_size;
 67	int			entries;
 68};
 69
 70/*
 71 * common_params - Parameters shared between timerlat_params and osnoise_params
 72 */
 73struct common_params {
 74	/* trace configuration */
 75	char			*cpus;
 76	cpu_set_t		monitored_cpus;
 77	struct trace_events	*events;
 78	int			buffer_size;
 79
 80	/* Timing parameters */
 81	int			warmup;
 82	long long		stop_us;
 83	long long		stop_total_us;
 84	int			sleep_time;
 85	int			duration;
 86
 87	/* Scheduling parameters */
 88	int			set_sched;
 89	struct sched_attr	sched_param;
 90	int			cgroup;
 91	char			*cgroup_name;
 92	int			hk_cpus;
 93	cpu_set_t		hk_cpu_set;
 94
 95	/* Other parameters */
 96	struct hist_params	hist;
 97	int			output_divisor;
 98	int			pretty_output;
 99	int			quiet;
100	int			user_workload;
101	int			kernel_workload;
102	int			user_data;
103	int			aa_only;
104
105	struct actions		threshold_actions;
106	struct actions		end_actions;
107	struct timerlat_u_params user;
108};
109
110#define for_each_monitored_cpu(cpu, nr_cpus, common) \
111	for (cpu = 0; cpu < nr_cpus; cpu++) \
112		if (!(common)->cpus || CPU_ISSET(cpu, &(common)->monitored_cpus))
113
114struct tool_ops;
115
116/*
117 * osnoise_tool -  osnoise based tool definition.
118 *
119 * Only the "trace" and "context" fields are used for
120 * the additional trace instances (record and aa).
121 */
122struct osnoise_tool {
123	struct tool_ops			*ops;
124	struct trace_instance		trace;
125	struct osnoise_context		*context;
126	void				*data;
127	struct common_params		*params;
128	time_t				start_time;
129	struct osnoise_tool		*record;
130	struct osnoise_tool		*aa;
131};
132
133struct tool_ops {
134	const char *tracer;
135	const char *comm_prefix;
136	struct common_params *(*parse_args)(int argc, char *argv[]);
137	struct osnoise_tool *(*init_tool)(struct common_params *params);
138	int (*apply_config)(struct osnoise_tool *tool);
139	int (*enable)(struct osnoise_tool *tool);
140	int (*main)(struct osnoise_tool *tool);
141	void (*print_stats)(struct osnoise_tool *tool);
142	void (*analyze)(struct osnoise_tool *tool, bool stopped);
143	void (*free)(struct osnoise_tool *tool);
144};
145
146int osnoise_set_cpus(struct osnoise_context *context, char *cpus);
147void osnoise_restore_cpus(struct osnoise_context *context);
148
149int osnoise_set_workload(struct osnoise_context *context, bool onoff);
150
151void osnoise_destroy_tool(struct osnoise_tool *top);
152struct osnoise_tool *osnoise_init_tool(char *tool_name);
153struct osnoise_tool *osnoise_init_trace_tool(const char *tracer);
154bool osnoise_trace_is_off(struct osnoise_tool *tool, struct osnoise_tool *record);
155
156int common_apply_config(struct osnoise_tool *tool, struct common_params *params);
157int top_main_loop(struct osnoise_tool *tool);
158int hist_main_loop(struct osnoise_tool *tool);
~/ Read-only file preview.