From 89f8741a6717b08fe5b9116660d5833e20d6dfda Mon Sep 17 00:00:00 2001 From: compudj Date: Thu, 7 Dec 2006 21:53:24 +0000 Subject: [PATCH] fix unknown mode elapsed time git-svn-id: http://ltt.polymtl.ca/svn@2294 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/lttv/lttv/state.c | 9 ++- ltt/branches/poly/lttv/lttv/stats.c | 103 +++++++++++++--------------- 2 files changed, 55 insertions(+), 57 deletions(-) diff --git a/ltt/branches/poly/lttv/lttv/state.c b/ltt/branches/poly/lttv/lttv/state.c index 98c4c332..1be0ce21 100644 --- a/ltt/branches/poly/lttv/lttv/state.c +++ b/ltt/branches/poly/lttv/lttv/state.c @@ -2257,7 +2257,8 @@ static gboolean process_fork(void *hook_data, void *call_data) return FALSE; } -/* We stamp a newly created process as kernel_thread */ +/* We stamp a newly created process as kernel_thread. + * The thread should not be running yet. */ static gboolean process_kernel_thread(void *hook_data, void *call_data) { LttvTracefileState *s = (LttvTracefileState *)call_data; @@ -2430,7 +2431,9 @@ static void fix_process(gpointer key, gpointer value, es->s = LTTV_STATE_RUN; if(process->execution_stack->len == 1) { - /* Still in user mode, means never scheduled */ + /* Still in bottom unknown mode, means never did a system call + * May be either in user mode, syscall mode, running or waiting.*/ + /* FIXME : we may be tagging syscall mode when being user mode */ process->execution_stack = g_array_set_size(process->execution_stack, 2); es = process->state = &g_array_index(process->execution_stack, @@ -2441,7 +2444,7 @@ static void fix_process(gpointer key, gpointer value, //g_assert(timestamp->tv_sec != 0); es->change = *timestamp; es->cum_cpu_time = ltt_time_zero; - es->s = LTTV_STATE_WAIT; + //es->s = LTTV_STATE_WAIT; } } } diff --git a/ltt/branches/poly/lttv/lttv/stats.c b/ltt/branches/poly/lttv/lttv/stats.c index 6e6a61f2..fe126141 100644 --- a/ltt/branches/poly/lttv/lttv/stats.c +++ b/ltt/branches/poly/lttv/lttv/stats.c @@ -393,7 +393,6 @@ lttv_tracefile_stats_get_type(void) return type; } - static void find_event_tree(LttvTracefileStats *tfcs, GQuark pid_time, @@ -429,10 +428,9 @@ find_event_tree(LttvTracefileStats *tfcs, *event_types_tree = a; } - -/* Update the trace event tree for the specified cpu */ -static void update_trace_event_tree(LttvTracefileStats *tfcs, guint cpu) +static void update_event_tree(LttvTracefileStats *tfcs) { + guint cpu = tfcs->parent.cpu; LttvTraceState *ts = (LttvTraceState *)tfcs->parent.parent.t_context; LttvProcessState *process = ts->running_process[cpu]; LttvExecutionState *es = process->state; @@ -444,9 +442,21 @@ static void update_trace_event_tree(LttvTracefileStats *tfcs, guint cpu) &(tfcs->current_event_types_tree)); } -static void update_event_tree(LttvTracefileStats *tfcs) + +/* Update the trace event tree for the specified cpu */ +static void update_trace_event_tree(LttvTraceStats *tcs) { - update_trace_event_tree(tfcs, tfcs->parent.cpu); + LttvTracefileStats *tfcs; + 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); + } } static void mode_change(LttvTracefileStats *tfcs) @@ -485,15 +495,16 @@ static void mode_end(LttvTracefileStats *tfcs) LttTime delta; /* FIXME put there in case of a missing update after a state modification */ + //void *lasttree = tfcs->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, LTTV_TIME, &elapsed_time); - if(process->state->t != LTTV_STATE_MODE_UNKNOWN) + if(process->state->t != LTTV_STATE_MODE_UNKNOWN) { delta = ltt_time_sub(tfcs->parent.parent.timestamp, process->state->entry); - else + } else delta = ltt_time_zero; *(elapsed_time.v_time) = ltt_time_add(*(elapsed_time.v_time), delta); @@ -552,7 +563,7 @@ static gboolean after_syscall_entry(void *hook_data, void *call_data) } -gboolean before_syscall_exit(void *hook_data, void *call_data) +static gboolean before_syscall_exit(void *hook_data, void *call_data) { mode_end((LttvTracefileStats *)call_data); return FALSE; @@ -566,7 +577,7 @@ static gboolean after_syscall_exit(void *hook_data, void *call_data) } -gboolean before_trap_entry(void *hook_data, void *call_data) +static gboolean before_trap_entry(void *hook_data, void *call_data) { mode_change((LttvTracefileStats *)call_data); return FALSE; @@ -580,99 +591,98 @@ static gboolean after_trap_entry(void *hook_data, void *call_data) } -gboolean before_trap_exit(void *hook_data, void *call_data) +static gboolean before_trap_exit(void *hook_data, void *call_data) { mode_end((LttvTracefileStats *)call_data); return FALSE; } -gboolean after_trap_exit(void *hook_data, void *call_data) +static gboolean after_trap_exit(void *hook_data, void *call_data) { after_mode_end((LttvTracefileStats *)call_data); return FALSE; } -gboolean before_irq_entry(void *hook_data, void *call_data) +static gboolean before_irq_entry(void *hook_data, void *call_data) { mode_change((LttvTracefileStats *)call_data); return FALSE; } -gboolean after_irq_entry(void *hook_data, void *call_data) +static gboolean after_irq_entry(void *hook_data, void *call_data) { update_event_tree((LttvTracefileStats *)call_data); return FALSE; } -gboolean before_irq_exit(void *hook_data, void *call_data) +static gboolean before_irq_exit(void *hook_data, void *call_data) { mode_end((LttvTracefileStats *)call_data); return FALSE; } -gboolean after_irq_exit(void *hook_data, void *call_data) +static gboolean after_irq_exit(void *hook_data, void *call_data) { after_mode_end((LttvTracefileStats *)call_data); return FALSE; } -gboolean before_soft_irq_entry(void *hook_data, void *call_data) +static gboolean before_soft_irq_entry(void *hook_data, void *call_data) { mode_change((LttvTracefileStats *)call_data); return FALSE; } -gboolean after_soft_irq_entry(void *hook_data, void *call_data) +static gboolean after_soft_irq_entry(void *hook_data, void *call_data) { update_event_tree((LttvTracefileStats *)call_data); return FALSE; } - -gboolean before_soft_irq_exit(void *hook_data, void *call_data) +static gboolean before_soft_irq_exit(void *hook_data, void *call_data) { mode_end((LttvTracefileStats *)call_data); return FALSE; } -gboolean after_soft_irq_exit(void *hook_data, void *call_data) +static gboolean after_soft_irq_exit(void *hook_data, void *call_data) { after_mode_end((LttvTracefileStats *)call_data); return FALSE; } -gboolean before_function_entry(void *hook_data, void *call_data) +static gboolean before_function_entry(void *hook_data, void *call_data) { mode_change((LttvTracefileStats *)call_data); return FALSE; } -gboolean after_function_entry(void *hook_data, void *call_data) +static gboolean after_function_entry(void *hook_data, void *call_data) { update_event_tree((LttvTracefileStats *)call_data); return FALSE; } -gboolean before_function_exit(void *hook_data, void *call_data) +static gboolean before_function_exit(void *hook_data, void *call_data) { mode_end((LttvTracefileStats *)call_data); return FALSE; } -gboolean after_function_exit(void *hook_data, void *call_data) +static gboolean after_function_exit(void *hook_data, void *call_data) { after_mode_end((LttvTracefileStats *)call_data); return FALSE; } -gboolean before_schedchange(void *hook_data, void *call_data) +static gboolean before_schedchange(void *hook_data, void *call_data) { LttvTracefileStats *tfcs = (LttvTracefileStats *)call_data; @@ -696,7 +706,7 @@ gboolean before_schedchange(void *hook_data, void *call_data) return FALSE; } -gboolean after_schedchange(void *hook_data, void *call_data) +static gboolean after_schedchange(void *hook_data, void *call_data) { LttvTracefileStats *tfcs = (LttvTracefileStats *)call_data; @@ -732,21 +742,18 @@ gboolean after_schedchange(void *hook_data, void *call_data) return FALSE; } -gboolean process_fork(void *hook_data, void *call_data) +static gboolean process_fork(void *hook_data, void *call_data) { - /* nothing to do for now */ return FALSE; } - -gboolean process_exit(void *hook_data, void *call_data) +static gboolean process_exit(void *hook_data, void *call_data) { - /* We should probably exit all modes here or we could do that at - schedule out. */ + update_event_tree((LttvTracefileStats *)call_data); return FALSE; } -gboolean before_enum_process_state(void *hook_data, void *call_data) +static gboolean before_enum_process_state(void *hook_data, void *call_data) { #if 0 /* Broken : adds up time in the current process doing the dump */ @@ -758,40 +765,28 @@ gboolean before_enum_process_state(void *hook_data, void *call_data) return FALSE; } -gboolean after_enum_process_state(void *hook_data, void *call_data) +static gboolean after_enum_process_state(void *hook_data, void *call_data) { - LttvTracefileStats *tfcs = (LttvTracefileStats *)call_data; LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; - LttvTraceState *ts = (LttvTraceState*)tfc->t_context; - guint nb_cpus, i; - - nb_cpus = ltt_trace_get_num_cpu(ts->parent.t); - for(i=0; it_context; + update_trace_event_tree(tcs); return FALSE; } static gboolean after_statedump_end(void *hook_data, void *call_data) { - LttvTracefileStats *tfcs = (LttvTracefileStats *)call_data; LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; - LttvTraceState *ts = (LttvTraceState*)tfc->t_context; - guint nb_cpus, i; - - nb_cpus = ltt_trace_get_num_cpu(ts->parent.t); - for(i=0; it_context; + update_trace_event_tree(tcs); return FALSE; } -gboolean process_free(void *hook_data, void *call_data) +static gboolean process_free(void *hook_data, void *call_data) { return FALSE; } -gboolean every_event(void *hook_data, void *call_data) +static gboolean every_event(void *hook_data, void *call_data) { LttvTracefileStats *tfcs = (LttvTracefileStats *)call_data; -- 2.34.1