*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
LTTV_STATS_EVENTS_COUNT,
LTTV_STATS_USE_COUNT,
LTTV_STATS,
- LTTV_STATS_TRACEFILES,
LTTV_STATS_SUMMED,
LTTV_STATS_BEFORE_HOOKS,
LTTV_STATS_AFTER_HOOKS;
-static void find_event_tree(LttvTracefileStats *tfcs, GQuark pid_time,
+static void find_event_tree(LttvCPUStats *cpu_stats, GQuark pid_time,
guint cpu, guint64 function,
GQuark mode, GQuark sub_mode, LttvAttribute **events_tree,
LttvAttribute **event_types_tree);
static void lttv_stats_init(LttvTracesetStats *self)
{
- guint i, j, nb_trace, nb_tracefile;
+ guint i, j, nb_trace, nb_cpu, nb_tracefile;
LttvTraceContext *tc;
LttvTracefileContext **tfs;
LttvTracefileStats *tfcs;
+ LttvCPUStats *cpu_stats;
LttvAttributeValue v;
- LttvAttribute *tracefiles_stats;
-
LttvTraceset *ts = self->parent.parent.ts;
self->stats = lttv_attribute_find_subdir(
tcs->stats = lttv_attribute_find_subdir(tcs->parent.parent.t_a,
LTTV_STATS);
- tracefiles_stats = lttv_attribute_find_subdir(tcs->parent.parent.t_a,
- LTTV_STATS_TRACEFILES);
lttv_attribute_find(tcs->parent.parent.t_a, LTTV_STATS_USE_COUNT,
LTTV_UINT, &v);
g_assert(lttv_attribute_get_number(tcs->stats) == 0);
}
+ nb_cpu = ltt_trace_get_num_cpu(tc->t);
+ tcs->cpu_stats = g_new(LttvCPUStats, nb_cpu);
+ for(j = 0 ; j < nb_cpu; j++) {
+ cpu_stats = &tcs->cpu_stats[j];
+ cpu_stats->cpu = j;
+ cpu_stats->tcs = tcs;
+ find_event_tree(cpu_stats, LTTV_STATS_PROCESS_UNKNOWN,
+ cpu_stats->cpu,
+ 0x0ULL,
+ LTTV_STATE_MODE_UNKNOWN,
+ LTTV_STATE_SUBMODE_UNKNOWN, &cpu_stats->current_events_tree,
+ &cpu_stats->current_event_types_tree);
+ }
nb_tracefile = tc->tracefiles->len;
-
- for(j = 0 ; j < nb_tracefile ; j++) {
+ for (j = 0; j < nb_tracefile; j++) {
tfs = &g_array_index(tc->tracefiles, LttvTracefileContext*, j);
tfcs = LTTV_TRACEFILE_STATS(*tfs);
- tfcs->stats = lttv_attribute_find_subdir(tracefiles_stats,
- ltt_tracefile_long_name(tfcs->parent.parent.tf));
- guint cpu = tfcs->parent.cpu;
- find_event_tree(tfcs, LTTV_STATS_PROCESS_UNKNOWN,
- cpu,
- 0x0ULL,
- LTTV_STATE_MODE_UNKNOWN,
- LTTV_STATE_SUBMODE_UNKNOWN, &tfcs->current_events_tree,
- &tfcs->current_event_types_tree);
+ tfcs->cpu_stats = &tcs->cpu_stats[tfcs->parent.cpu];
}
}
static void lttv_stats_fini(LttvTracesetStats *self)
{
- guint i, j, nb_trace, nb_tracefile;
+ guint i, j, nb_trace, nb_cpu, nb_tracefile;
LttvTraceset *ts;
LttvTracefileStats *tfcs;
- LttvAttributeValue v;
+ LttvCPUStats *cpu_stats;
- LttvAttribute *tracefiles_stats;
+ LttvAttributeValue v;
lttv_attribute_find(self->parent.parent.ts_a, LTTV_STATS_USE_COUNT,
LTTV_UINT, &v);
LTTV_UINT, &v);
(*(v.v_uint))--;
- if(*(v.v_uint) == 0) {
- lttv_attribute_remove_by_name(tcs->parent.parent.t_a,LTTV_STATS);
- tracefiles_stats = lttv_attribute_find_subdir(tcs->parent.parent.t_a,
- LTTV_STATS_TRACEFILES);
- lttv_attribute_remove_by_name(tcs->parent.parent.t_a,
- LTTV_STATS_TRACEFILES);
- }
+ if(*(v.v_uint) == 0)
+ lttv_attribute_remove_by_name(tcs->parent.parent.t_a, LTTV_STATS);
tcs->stats = NULL;
nb_tracefile = tc->tracefiles->len;
-
- for(j = 0 ; j < nb_tracefile ; j++) {
+ for (j = 0; j < nb_tracefile; j++) {
tfc = g_array_index(tc->tracefiles, LttvTracefileContext*, j);
- tfcs = (LttvTracefileStats *)tfc;
- tfcs->stats = NULL;
- tfcs->current_events_tree = NULL;
- tfcs->current_event_types_tree = NULL;
+ tfcs = LTTV_TRACEFILE_STATS(tfc);
+ tfcs->cpu_stats = NULL;
}
+
+ nb_cpu = ltt_trace_get_num_cpu(tc->t);
+
+ for(j = 0 ; j < nb_cpu; j++) {
+ cpu_stats = &tcs->cpu_stats[j];
+ cpu_stats->current_events_tree = NULL;
+ cpu_stats->current_event_types_tree = NULL;
+ }
+ g_free(tcs->cpu_stats);
}
}
return type;
}
-static void find_event_tree(LttvTracefileStats *tfcs,
+static void find_event_tree(LttvCPUStats *cpu_stats,
GQuark pid_time,
guint cpu,
guint64 function,
g_assert(ret > 0);
fstring[MAX_64_HEX_STRING_LEN-1] = '\0';
- LttvTraceStats *tcs = (LttvTraceStats*)tfcs->parent.parent.t_context;
+ LttvTraceStats *tcs = cpu_stats->tcs;
a = lttv_attribute_find_subdir(tcs->stats, LTTV_STATS_PROCESSES);
a = lttv_attribute_find_subdir(a, pid_time);
a = lttv_attribute_find_subdir(a, LTTV_STATS_CPU);
*event_types_tree = a;
}
-static void update_event_tree(LttvTracefileStats *tfcs)
+static void update_event_tree(LttvCPUStats *cpu_stats)
{
- guint cpu = tfcs->parent.cpu;
- LttvTraceState *ts = (LttvTraceState *)tfcs->parent.parent.t_context;
+ LttvTraceStats *tcs = cpu_stats->tcs;
+ guint cpu = cpu_stats->cpu;
+ LttvTraceState *ts = &tcs->parent;
LttvProcessState *process = ts->running_process[cpu];
LttvExecutionState *es = process->state;
- find_event_tree(tfcs, process->pid_time,
+ find_event_tree(cpu_stats, process->pid_time,
cpu,
process->current_function,
- es->t, es->n, &(tfcs->current_events_tree),
- &(tfcs->current_event_types_tree));
+ es->t, es->n, &(cpu_stats->current_events_tree),
+ &(cpu_stats->current_event_types_tree));
}
-
-/* Update the trace event tree for the specified cpu */
+/* Update the trace event tree each cpu */
static void update_trace_event_tree(LttvTraceStats *tcs)
{
- LttvTracefileStats *tfcs;
+ LttvCPUStats *cpu_stats;
LttvTraceContext *tc = (LttvTraceContext*)tcs;
- guint j, nb_tracefile;
-
- /* For each tracefile, update the event tree */
- nb_tracefile = tc->tracefiles->len;
- for(j = 0; j < nb_tracefile; j++) {
- tfcs = LTTV_TRACEFILE_STATS(g_array_index(tc->tracefiles,
- LttvTracefileContext*, j));
- update_event_tree(tfcs);
+ guint j, nb_cpu;
+
+ /* For each cpu, update the event tree */
+ nb_cpu = ltt_trace_get_num_cpu(tc->t);
+ for(j = 0; j < nb_cpu; j++) {
+ cpu_stats = &tcs->cpu_stats[j];
+ update_event_tree(cpu_stats);
}
}
else
delta = ltt_time_zero;
- lttv_attribute_find(tfcs->current_events_tree, LTTV_STATS_CPU_TIME,
+ lttv_attribute_find(tfcs->cpu_stats->current_events_tree, LTTV_STATS_CPU_TIME,
LTTV_TIME, &cpu_time);
*(cpu_time.v_time) = ltt_time_add(*(cpu_time.v_time), delta);
LttTime delta;
/* FIXME put there in case of a missing update after a state modification */
- //void *lasttree = tfcs->current_events_tree;
+ //void *lasttree = tfcs->cpu_stats->current_events_tree;
//update_event_tree(tfcs);
- //g_assert (lasttree == tfcs->current_events_tree);
- lttv_attribute_find(tfcs->current_events_tree, LTTV_STATS_ELAPSED_TIME,
+ //g_assert (lasttree == tfcs->cpu_stats->current_events_tree);
+ lttv_attribute_find(tfcs->cpu_stats->current_events_tree, LTTV_STATS_ELAPSED_TIME,
LTTV_TIME, &elapsed_time);
if(process->state->t != LTTV_STATE_MODE_UNKNOWN) {
*(elapsed_time.v_time) = ltt_time_add(*(elapsed_time.v_time), delta);
- lttv_attribute_find(tfcs->current_events_tree, LTTV_STATS_CPU_TIME,
+ lttv_attribute_find(tfcs->cpu_stats->current_events_tree, LTTV_STATS_CPU_TIME,
LTTV_TIME, &cpu_time);
/* if it is a running mode, we must count its cpu time */
process->state->cum_cpu_time = ltt_time_add(process->state->cum_cpu_time,
delta);
- lttv_attribute_find(tfcs->current_events_tree, LTTV_STATS_CUMULATIVE_CPU_TIME,
+ lttv_attribute_find(tfcs->cpu_stats->current_events_tree, LTTV_STATS_CUMULATIVE_CPU_TIME,
LTTV_TIME, &cum_cpu_time);
*(cum_cpu_time.v_time) = ltt_time_add(*(cum_cpu_time.v_time),
process->state->cum_cpu_time);
nested_delta = process->state->cum_cpu_time;
process->state->cum_cpu_time = ltt_time_zero; /* For after traceset hook */
- update_event_tree(tfcs);
+ update_event_tree(tfcs->cpu_stats);
process->state->cum_cpu_time = ltt_time_add(process->state->cum_cpu_time,
nested_delta);
static gboolean after_syscall_entry(void *hook_data, void *call_data)
{
- update_event_tree((LttvTracefileStats *)call_data);
+ update_event_tree(((LttvTracefileStats *)call_data)->cpu_stats);
return FALSE;
}
static gboolean after_trap_entry(void *hook_data, void *call_data)
{
- update_event_tree((LttvTracefileStats *)call_data);
+ update_event_tree(((LttvTracefileStats *)call_data)->cpu_stats);
return FALSE;
}
static gboolean after_irq_entry(void *hook_data, void *call_data)
{
- update_event_tree((LttvTracefileStats *)call_data);
+ update_event_tree(((LttvTracefileStats *)call_data)->cpu_stats);
return FALSE;
}
static gboolean after_soft_irq_entry(void *hook_data, void *call_data)
{
- update_event_tree((LttvTracefileStats *)call_data);
+ update_event_tree(((LttvTracefileStats *)call_data)->cpu_stats);
return FALSE;
}
static gboolean after_function_entry(void *hook_data, void *call_data)
{
- update_event_tree((LttvTracefileStats *)call_data);
+ update_event_tree(((LttvTracefileStats *)call_data)->cpu_stats);
return FALSE;
}
{
LttvTracefileStats *tfcs = (LttvTracefileStats *)call_data;
- LttEvent *e = ltt_tracefile_get_event(tfcs->parent.parent.tf);
-
- LttvTraceHook *th = (LttvTraceHook *)hook_data;
-
- guint pid_in, pid_out;
-
- gint64 state_out;
-
- pid_out = ltt_event_get_unsigned(e, lttv_trace_get_hook_field(th, 0));
- pid_in = ltt_event_get_unsigned(e, lttv_trace_get_hook_field(th, 1));
- state_out = ltt_event_get_long_int(e, lttv_trace_get_hook_field(th, 2));
-
/* compute the time for the process to schedule out */
mode_change(tfcs);
LttvTraceState *ts = (LttvTraceState*)tfcs->parent.parent.t_context;
- LttEvent *e = ltt_tracefile_get_event(tfcs->parent.parent.tf);
-
- LttvTraceHook *th = (LttvTraceHook *)hook_data;
-
- guint pid_in, pid_out;
-
- gint64 state_out;
-
LttvProcessState *process;
- pid_out = ltt_event_get_unsigned(e, lttv_trace_get_hook_field(th, 0));
- pid_in = ltt_event_get_unsigned(e, lttv_trace_get_hook_field(th, 1));
- state_out = ltt_event_get_long_int(e, lttv_trace_get_hook_field(th, 2));
-
/* get the information for the process scheduled in */
guint cpu = tfcs->parent.cpu;
process = ts->running_process[cpu];
- find_event_tree(tfcs, process->pid_time,
+ find_event_tree(tfcs->cpu_stats, process->pid_time,
cpu,
process->current_function,
- process->state->t, process->state->n, &(tfcs->current_events_tree),
- &(tfcs->current_event_types_tree));
+ process->state->t, process->state->n,
+ &(tfcs->cpu_stats->current_events_tree),
+ &(tfcs->cpu_stats->current_event_types_tree));
/* compute the time waiting for the process to schedule in */
mode_change(tfcs);
static gboolean process_exit(void *hook_data, void *call_data)
{
- update_event_tree((LttvTracefileStats *)call_data);
+ update_event_tree(((LttvTracefileStats *)call_data)->cpu_stats);
return FALSE;
}
info = marker_get_info_from_id(tfcs->parent.parent.tf->mdata, e->event_id);
- lttv_attribute_find(tfcs->current_event_types_tree,
+ lttv_attribute_find(tfcs->cpu_stats->current_event_types_tree,
info->name, LTTV_UINT, &v);
(*(v.v_uint))++;
return FALSE;
do {
if(ltt_time_compare(process->state->cum_cpu_time, ltt_time_zero) != 0) {
- find_event_tree(*tfs, process->pid_time,
+ find_event_tree((*tfs)->cpu_stats, process->pid_time,
process->cpu,
process->current_function,
- process->state->t, process->state->n, &((*tfs)->
- current_events_tree),
- &((*tfs)->current_event_types_tree));
+ process->state->t, process->state->n,
+ &((*tfs)->cpu_stats->current_events_tree),
+ &((*tfs)->cpu_stats->current_event_types_tree));
/* Call mode_end only if not at end of trace */
if(ltt_time_compare(current_time, ltt_time_infinite) != 0)
mode_end(*tfs);
{
LttvAttribute *sum_container = self->stats;
- LttvAttributeType type;
-
LttvAttributeValue value;
LttvAttributeName name;
nb_process = lttv_attribute_get_number(processes_tree);
for(i = 0 ; i < nb_process ; i++) {
- type = lttv_attribute_get(processes_tree, i, &name, &value, &is_named);
+ lttv_attribute_get(processes_tree, i, &name, &value, &is_named);
process_tree = LTTV_ATTRIBUTE(*(value.v_gobject));
cpus_tree = lttv_attribute_find_subdir(process_tree, LTTV_STATS_CPU);
nb_cpu = lttv_attribute_get_number(cpus_tree);
for(j = 0 ; j < nb_cpu ; j++) {
- type = lttv_attribute_get(cpus_tree, j, &name, &value, &is_named);
+ lttv_attribute_get(cpus_tree, j, &name, &value, &is_named);
cpu_tree = LTTV_ATTRIBUTE(*(value.v_gobject));
trace_cpu_tree = lttv_attribute_find_subdir(main_tree,
nb_functions = lttv_attribute_get_number(cpu_functions_tree);
for(nf=0; nf < nb_functions; nf++) {
- type = lttv_attribute_get(cpu_functions_tree, nf, &name, &value,
+ lttv_attribute_get(cpu_functions_tree, nf, &name, &value,
&is_named);
function_tree = LTTV_ATTRIBUTE(*(value.v_gobject));
function_mode_types_tree = lttv_attribute_find_subdir(function_tree,
LTTV_STATS_MODE_TYPES);
nb_mode_type = lttv_attribute_get_number(function_mode_types_tree);
for(k = 0 ; k < nb_mode_type ; k++) {
- type = lttv_attribute_get(function_mode_types_tree, k, &name,
+ lttv_attribute_get(function_mode_types_tree, k, &name,
&value, &is_named);
mode_tree = LTTV_ATTRIBUTE(*(value.v_gobject));
nb_submode = lttv_attribute_get_number(submodes_tree);
for(l = 0 ; l < nb_submode ; l++) {
- type = lttv_attribute_get(submodes_tree, l, &name, &value,
+ lttv_attribute_get(submodes_tree, l, &name, &value,
&is_named);
submode_tree = LTTV_ATTRIBUTE(*(value.v_gobject));
sum = 0;
for(m = 0 ; m < nb_event_type ; m++) {
- type = lttv_attribute_get(event_types_tree, m, &name,
+ lttv_attribute_get(event_types_tree, m, &name,
&value, &is_named);
sum += *(value.v_uint);
}
LTTV_UINT, &value);
*(value.v_uint) = sum;
- type = lttv_attribute_get(submodes_tree, l, &name, &value,
+ lttv_attribute_get(submodes_tree, l, &name, &value,
&is_named);
submode_tree = LTTV_ATTRIBUTE(*(value.v_gobject));
if(!trace_is_summed) {
LTTV_STATS_AFTER_HOOKS = g_quark_from_string("saved stats after hooks");
LTTV_STATS_USE_COUNT = g_quark_from_string("stats_use_count");
LTTV_STATS = g_quark_from_string("statistics");
- LTTV_STATS_TRACEFILES = g_quark_from_string("tracefiles statistics");
LTTV_STATS_SUMMED = g_quark_from_string("statistics summed");
}