1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Michel Dagenais
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
23 #include <lttv/state.h>
25 /* The statistics are for a complete time interval. These structures differ
26 from the system state since they relate to static components of the
27 system (all processes which existed instead of just the currently
30 The basic attributes tree to gather for several different execution modes
31 (e.g., user mode, syscall, irq), thereafter called the "events tree",
32 contains the following attributes: the number of events of each type,
33 the total number of events, the number of bytes written, the time spent
34 executing, waiting for a resource, waiting for a cpu, and possibly many
35 others. The name "facility-event_type" below is to be replaced
36 by specific event types (e.g., core-schedchange, code-syscall_entry...).
49 The events for several different execution modes are joined together to
50 form the "execution modes tree". The name "execution mode" is to be replaced
51 by "system call", "trap", "irq", "user mode" or "kernel thread".
52 The name "submode" is to be replaced by the specific system call, trap or
53 irq name. The "submode" is an empty string if none is applicable, which is
54 the case for "user mode" and "kernel thread".
56 An "events tree" for each "execution mode" contains the sum for all its
57 different submodes. An "events tree" in the "execution modes tree" contains
58 the sum for all its different execution modes.
70 Each trace set contains an "execution modes tree". While the traces
71 come from possibly different systems, which may differ in their system
72 calls..., most of the system calls will have the same name, even if their
73 actual internal numeric id differs. Categories such as cpu id and process
74 id are not kept since these are specific to each system. When several
75 traces are taken from the same system, these categories may make sense and
76 could eventually be considered.
78 Each trace contains a global "execution modes tree", one for each
79 cpu and process, and one for each process/cpu combination. The name
80 "cpu number" stands for the cpu identifier, and "process_id-start_time"
81 is a unique process identifier composed of the process id
82 (unique at any given time but which may be reused over time) concatenated
83 with the process start time. Each process has a "functions" tree which
84 contains each process'function address (when the information is available).
85 If not, only the 0x0 function will appear.
93 "process_id-start_time"/
110 All the events and derived values (cpu, elapsed and wait time) are
111 added during the trace analysis in the relevant
112 trace/processes/ * /cpu/ * /functions/ * /mode_types/ * /submodes/ *
113 "events tree". To achieve this efficiently, each tracefile context
114 contains a pointer to the current relevant "events tree" and "event_types"
117 Once all the events are processed, the total number of events is computed
119 trace/processes/ * /cpu/ * /functions/ * /mode_types/ * /submodes/ *.
120 Then, the "events tree" are summed for all submodes within each mode type
121 and for all mode types within a processes/ * /cpu/ * /functions/ *
122 "execution modes tree".
124 Then, the "execution modes trees" for all functions within a
125 trace/processes/ * /cpu for all cpu within a process, for all processes,
126 and for all traces are computed. Separately, the "execution modes tree" for
127 each function (over all cpus) for all processes, and for all traces are
128 summed in the trace/processes/ * /functions/ * subtree.
130 Finally, the "execution modes trees" for all cpu within a process,
131 for all processes, and for all traces are computed. Separately,
132 the "execution modes tree" for each cpu but for all processes within a
133 trace are summed in the trace / cpu / * subtrees.
138 /* The various statistics branch names are GQuarks. They are pre-computed for
139 easy and efficient access */
141 #define LTTV_PRIO_STATS_BEFORE_STATE LTTV_PRIO_STATE-5
142 #define LTTV_PRIO_STATS_AFTER_STATE LTTV_PRIO_STATE+5
146 LTTV_STATS_PROCESS_UNKNOWN,
147 LTTV_STATS_PROCESSES,
149 LTTV_STATS_MODE_TYPES,
151 LTTV_STATS_FUNCTIONS,
152 LTTV_STATS_EVENT_TYPES,
154 LTTV_STATS_CUMULATIVE_CPU_TIME,
155 LTTV_STATS_ELAPSED_TIME,
157 LTTV_STATS_EVENTS_COUNT,
158 LTTV_STATS_BEFORE_HOOKS,
159 LTTV_STATS_AFTER_HOOKS,
160 /***********************************************************/
161 LTTV_XENO_STATS_THREADS,
162 LTTV_XENO_STATS_THREAD_ADDRESS,
163 LTTV_XENO_STATS_THREAD_PERIOD,
164 LTTV_XENO_STATS_THREAD_PRIO,
165 LTTV_XENO_STATS_STATE,
166 LTTV_XENO_STATS_SYNCH,
167 LTTV_XENO_STATS_PERIOD,
168 LTTV_XENO_STATS_PERIOD_OVERRUNS,
169 LTTV_XENO_STATS_PERIOD_EXECUTION,
170 LTTV_XENO_STATS_TEXT_OVERRUNS,
171 LTTV_XENO_STATS_TEXT_TICKS,
172 LTTV_XENO_STATS_TEXT_TOTAL,
173 LTTV_XENO_STATS_TEXT_OWNER,
174 LTTV_XENO_STATS_TEXT_WAITING,
175 LTTV_XENO_STATS_TEXT_OWNER_TOTAL,
176 LTTV_XENO_STATS_TEXT_OWNER_MAX,
177 LTTV_XENO_STATS_TEXT_OWNER_MIN,
178 LTTV_XENO_STATS_TEXT_OWNER_AVG,
179 LTTV_XENO_STATS_TEXT_WAITING,
180 LTTV_XENO_STATS_TEXT_WAITING_TOTAL,
181 LTTV_XENO_STATS_TEXT_WAITING_MAX,
182 LTTV_XENO_STATS_TEXT_WAITING_MIN,
183 LTTV_XENO_STATS_TEXT_WAITING_AVG,
184 LTTV_XENO_STATS_TEXT_READY_MAX,
185 LTTV_XENO_STATS_TEXT_READY_MIN,
186 LTTV_XENO_STATS_TEXT_READY_AVG,
187 LTTV_XENO_STATS_TEXT_RUNNING_MAX,
188 LTTV_XENO_STATS_TEXT_RUNNING_MIN,
189 LTTV_XENO_STATS_TEXT_RUNNING_AVG,
190 LTTV_XENO_STATS_TEXT_SUSPEND_MAX,
191 LTTV_XENO_STATS_TEXT_SUSPEND_MIN,
192 LTTV_XENO_STATS_TEXT_SUSPEND_AVG,
193 LTTV_XENO_STATS_NB_PERIOD;
194 /***********************************************************/
197 typedef struct _LttvTracesetStats LttvTracesetStats;
198 typedef struct _LttvTracesetStatsClass LttvTracesetStatsClass;
200 typedef struct _LttvTraceStats LttvTraceStats;
201 typedef struct _LttvTraceStatsClass LttvTraceStatsClass;
203 typedef struct _LttvTracefileStats LttvTracefileStats;
204 typedef struct _LttvTracefileStatsClass LttvTracefileStatsClass;
208 // Hook wrapper. call_data is a trace context.
209 gboolean lttv_stats_hook_add_event_hooks(void *hook_data, void *call_data);
210 void lttv_stats_add_event_hooks(LttvTracesetStats *self);
212 // Hook wrapper. call_data is a trace context.
213 gboolean lttv_stats_hook_remove_event_hooks(void *hook_data, void *call_data);
214 void lttv_stats_remove_event_hooks(LttvTracesetStats *self);
216 gboolean lttv_stats_sum_traceset_hook(void *hook_data, void *call_data);
217 void lttv_stats_sum_traceset(LttvTracesetStats *self);
219 void lttv_stats_sum_trace(LttvTraceStats *self, LttvAttribute *ts_stats);
221 void lttv_xeno_stats_sum_trace(LttvTraceStats *self, LttvAttribute *ts_stats);
222 void lttv_xeno_stats_sum_traceset(LttvTracesetStats *self);
224 /* Reset all statistics containers */
225 void lttv_stats_reset(LttvTracesetStats *self);
228 /* The LttvTracesetStats, LttvTraceStats and LttvTracefileStats types
229 inherit from the corresponding State objects defined in state.h.. */
231 #define LTTV_TRACESET_STATS_TYPE (lttv_traceset_stats_get_type ())
232 #define LTTV_TRACESET_STATS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TRACESET_STATS_TYPE, LttvTracesetStats))
233 #define LTTV_TRACESET_STATS_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_TRACESET_STATS_TYPE, LttvTracesetStatsClass))
234 #define LTTV_IS_TRACESET_STATS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_TRACESET_STATS_TYPE))
235 #define LTTV_IS_TRACESET_STATS_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACESET_STATS_TYPE))
236 #define LTTV_TRACESET_STATS_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACESET_STATS_TYPE, LttvTracesetStatsClass))
238 struct _LttvTracesetStats {
239 LttvTracesetState parent;
241 LttvAttribute *stats;
242 /****************************************************************************************************************************/
243 LttvAttribute *xenoltt_stats;
244 /****************************************************************************************************************************/
248 struct _LttvTracesetStatsClass {
249 LttvTracesetStateClass parent;
252 GType lttv_traceset_stats_get_type (void);
255 #define LTTV_TRACE_STATS_TYPE (lttv_trace_stats_get_type ())
256 #define LTTV_TRACE_STATS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TRACE_STATS_TYPE, LttvTraceStats))
257 #define LTTV_TRACE_STATS_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_TRACE_STATS_TYPE, LttvTraceStatsClass))
258 #define LTTV_IS_TRACE_STATS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_TRACE_STATS_TYPE))
259 #define LTTV_IS_TRACE_STATS_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACE_STATS_TYPE))
260 #define LTTV_TRACE_STATS_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACE_STATS_TYPE, LttvTraceStatsClass))
262 struct _LttvTraceStats {
263 LttvTraceState parent;
265 LttvAttribute *stats;
266 /****************************************************************************************************************************/
267 LttvAttribute *xenoltt_stats;
268 /****************************************************************************************************************************/
271 struct _LttvTraceStatsClass {
272 LttvTraceStateClass parent;
275 GType lttv_trace_stats_get_type (void);
278 #define LTTV_TRACEFILE_STATS_TYPE (lttv_tracefile_stats_get_type ())
279 #define LTTV_TRACEFILE_STATS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TRACEFILE_STATS_TYPE, LttvTracefileStats))
280 #define LTTV_TRACEFILE_STATS_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_TRACEFILE_STATS_TYPE, LttvTracefileStatsClass))
281 #define LTTV_IS_TRACEFILE_STATS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_TRACEFILE_STATS_TYPE))
282 #define LTTV_IS_TRACEFILE_STATS_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACEFILE_STATS_TYPE))
283 #define LTTV_TRACEFILE_STATS_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACEFILE_STATS_TYPE, LttvTracefileStatsClass))
285 struct _LttvTracefileStats {
286 LttvTracefileState parent;
288 LttvAttribute *stats;
289 LttvAttribute *current_events_tree;
290 LttvAttribute *current_event_types_tree;
293 struct _LttvTracefileStatsClass {
294 LttvTracefileStateClass parent;
297 GType lttv_tracefile_stats_get_type (void);