From: pmf Date: Thu, 21 May 2009 03:57:43 +0000 (+0000) Subject: resourceview: fix stuck softirq and trap problem X-Git-Tag: v0.12.20~103 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=16e4e89bccb8f0a0181e422e57636fde3e828698;p=lttv.git resourceview: fix stuck softirq and trap problem git-svn-id: http://ltt.polymtl.ca/svn@3386 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/trunk/lttv/lttv/lttv/state.c b/trunk/lttv/lttv/lttv/state.c index 69497d37..70ca8cbe 100644 --- a/trunk/lttv/lttv/lttv/state.c +++ b/trunk/lttv/lttv/lttv/state.c @@ -469,8 +469,10 @@ restore_init_state(LttvTraceState *self) g_array_remove_range(self->cpu_states[i].mode_stack, 0, self->cpu_states[i].mode_stack->len); if(self->cpu_states[i].irq_stack->len) g_array_remove_range(self->cpu_states[i].irq_stack, 0, self->cpu_states[i].irq_stack->len); - self->cpu_states[i].last_soft_irq = -1; - self->cpu_states[i].last_trap = -1; + if(self->cpu_states[i].softirq_stack->len) + g_array_remove_range(self->cpu_states[i].softirq_stack, 0, self->cpu_states[i].softirq_stack->len); + if(self->cpu_states[i].trap_stack->len) + g_array_remove_range(self->cpu_states[i].trap_stack, 0, self->cpu_states[i].trap_stack->len); } } @@ -651,8 +653,8 @@ init(LttvTracesetState *self, LttvTraceset *ts) for(j = 0; jcpu_states[j].mode_stack = g_array_new(FALSE, FALSE, sizeof(LttvCPUMode)); tcs->cpu_states[j].irq_stack = g_array_new(FALSE, FALSE, sizeof(gint)); - tcs->cpu_states[j].last_soft_irq = -1; - tcs->cpu_states[j].last_trap = -1; + tcs->cpu_states[j].softirq_stack = g_array_new(FALSE, FALSE, sizeof(gint)); + tcs->cpu_states[j].trap_stack = g_array_new(FALSE, FALSE, sizeof(gint)); g_assert(tcs->cpu_states[j].mode_stack != NULL); } @@ -1329,15 +1331,24 @@ static LttvCPUState *lttv_state_copy_cpu_states(LttvCPUState *states, guint n) retval = g_new(LttvCPUState, n); for(i=0; ilen); for(j=0; jlen; j++) { g_array_index(retval[i].irq_stack, gint, j) = g_array_index(states[i].irq_stack, gint, j); } + retval[i].softirq_stack = g_array_new(FALSE, FALSE, sizeof(gint)); + g_array_set_size(retval[i].softirq_stack, states[i].softirq_stack->len); + for(j=0; jlen; j++) { + g_array_index(retval[i].softirq_stack, gint, j) = g_array_index(states[i].softirq_stack, gint, j); + } + + retval[i].trap_stack = g_array_new(FALSE, FALSE, sizeof(gint)); + g_array_set_size(retval[i].trap_stack, states[i].trap_stack->len); + for(j=0; jlen; j++) { + g_array_index(retval[i].trap_stack, gint, j) = g_array_index(states[i].trap_stack, gint, j); + } + retval[i].mode_stack = g_array_new(FALSE, FALSE, sizeof(LttvCPUMode)); g_array_set_size(retval[i].mode_stack, states[i].mode_stack->len); for(j=0; jlen; j++) { @@ -1355,6 +1366,8 @@ static void lttv_state_free_cpu_states(LttvCPUState *states, guint n) for(i=0; icpu_state, LTTV_CPU_TRAP); /* update trap status */ - s->cpu_state->last_trap = trap; + g_array_append_val(s->cpu_state->trap_stack, trap); ts->trap_states[trap].running++; return FALSE; @@ -2535,7 +2548,6 @@ static gboolean trap_exit(void *hook_data, void *call_data) { LttvTracefileState *s = (LttvTracefileState *)call_data; LttvTraceState *ts = (LttvTraceState *)s->parent.t_context; - gint trap = s->cpu_state->last_trap; pop_state(s, LTTV_STATE_TRAP); @@ -2543,10 +2555,12 @@ static gboolean trap_exit(void *hook_data, void *call_data) cpu_pop_mode(s->cpu_state); /* update trap status */ - if (trap != -1) - if(ts->trap_states[trap].running) - ts->trap_states[trap].running--; - + if (s->cpu_state->trap_stack->len > 0) { + gint last = g_array_index(s->cpu_state->trap_stack, gint, s->cpu_state->trap_stack->len-1); + if(ts->trap_states[last].running) + ts->trap_states[last].running--; + g_array_remove_index(s->cpu_state->trap_stack, s->cpu_state->trap_stack->len-1); + } return FALSE; } @@ -2583,18 +2597,19 @@ static gboolean soft_irq_exit(void *hook_data, void *call_data) { LttvTracefileState *s = (LttvTracefileState *)call_data; LttvTraceState *ts = (LttvTraceState *)s->parent.t_context; - gint softirq = s->cpu_state->last_soft_irq; pop_state(s, LTTV_STATE_SOFT_IRQ); - /* update softirq status */ - if (softirq != -1) - if(ts->soft_irq_states[softirq].running) - ts->soft_irq_states[softirq].running--; - /* update cpu status */ cpu_pop_mode(s->cpu_state); + /* update softirq status */ + if (s->cpu_state->softirq_stack->len > 0) { + gint last = g_array_index(s->cpu_state->softirq_stack, gint, s->cpu_state->softirq_stack->len-1); + if(ts->soft_irq_states[last].running) + ts->soft_irq_states[last].running--; + g_array_remove_index(s->cpu_state->softirq_stack, s->cpu_state->softirq_stack->len-1); + } return FALSE; } @@ -2668,7 +2683,7 @@ static gboolean soft_irq_entry(void *hook_data, void *call_data) cpu_push_mode(s->cpu_state, LTTV_CPU_SOFT_IRQ); /* update softirq status */ - s->cpu_state->last_soft_irq = softirq; + g_array_append_val(s->cpu_state->softirq_stack, softirq); if(ts->soft_irq_states[softirq].pending) ts->soft_irq_states[softirq].pending--; ts->soft_irq_states[softirq].running++; diff --git a/trunk/lttv/lttv/lttv/state.h b/trunk/lttv/lttv/lttv/state.h index a65f2635..ad7f9e06 100644 --- a/trunk/lttv/lttv/lttv/state.h +++ b/trunk/lttv/lttv/lttv/state.h @@ -334,8 +334,8 @@ GType lttv_traceset_state_get_type (void); typedef struct _LttvCPUState { GArray *mode_stack; GArray *irq_stack; - gint last_soft_irq; - gint last_trap; + GArray *softirq_stack; + GArray *trap_stack; } LttvCPUState; typedef struct _LttvIRQState { diff --git a/trunk/lttv/lttv/modules/gui/resourceview/eventhooks.c b/trunk/lttv/lttv/modules/gui/resourceview/eventhooks.c index 37d0a07f..9edba155 100644 --- a/trunk/lttv/lttv/modules/gui/resourceview/eventhooks.c +++ b/trunk/lttv/lttv/modules/gui/resourceview/eventhooks.c @@ -1032,7 +1032,13 @@ int before_execmode_hook_soft_irq(void *hook_data, void *call_data) || minfo->name == LTT_EVENT_SOFT_IRQ_ENTRY) { softirq = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 0)); } else if (minfo->name == LTT_EVENT_SOFT_IRQ_EXIT) { - softirq = ts->cpu_states[cpu].last_soft_irq; + gint len = ts->cpu_states[cpu].softirq_stack->len; + if(len) { + softirq = g_array_index(ts->cpu_states[cpu].softirq_stack, gint, len-1); + } + else { + return 0; + } } else return 0; @@ -1206,7 +1212,13 @@ int before_execmode_hook_trap(void *hook_data, void *call_data) } else if (minfo->name == LTT_EVENT_TRAP_EXIT || minfo->name == LTT_EVENT_PAGE_FAULT_EXIT || minfo->name == LTT_EVENT_PAGE_FAULT_NOSEM_EXIT) { - trap = ts->cpu_states[cpu].last_trap; + gint len = ts->cpu_states[cpu].trap_stack->len; + if(len) { + trap = g_array_index(ts->cpu_states[cpu].trap_stack, gint, len-1); + } + else { + return 0; + } } else return 0;