Fix softirq raise dynamic expand
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 21 Mar 2011 23:22:59 +0000 (19:22 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 21 Mar 2011 23:22:59 +0000 (19:22 -0400)
The softirq raison action was not using the proper "expand" primitive,
thus causing segfault on traces taken from 2.6.38 kernels, which use
softirq IDs above 31 (seen softirqs up to 255).

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lttv/lttv/state.c
lttv/lttv/state.h

index 475c2305b6e7b2654d54061e3af42b12eba7f218..fffd95f08bb81d7783e45cc75014ff257c108c8c 100644 (file)
@@ -2020,9 +2020,9 @@ static void create_name_tables(LttvTraceState *tcs)
 //                     }
 //             }
 
-               name_tables->nb_syscalls = 256;
-               name_tables->syscall_names = g_new(GQuark, 256);
-               for(i = 0 ; i < 256 ; i++) {
+               name_tables->nb_syscalls = PREALLOC_NB_SYSCALLS;
+               name_tables->syscall_names = g_new(GQuark, name_tables->nb_syscalls);
+               for(i = 0 ; i < name_tables->nb_syscalls; i++) {
                        g_string_printf(fe_name, "syscall %d", i);
                        name_tables->syscall_names[i] = g_quark_from_string(fe_name->str);
                }
@@ -2054,9 +2054,9 @@ static void create_name_tables(LttvTraceState *tcs)
 //                                     ltt_enum_string_get(t, i));
 //             }
 
-               name_tables->nb_traps = 256;
-               name_tables->trap_names = g_new(GQuark, 256);
-               for(i = 0 ; i < 256 ; i++) {
+               name_tables->nb_traps = PREALLOC_NB_TRAPS;
+               name_tables->trap_names = g_new(GQuark, name_tables->nb_traps);
+               for(i = 0 ; i < name_tables->nb_traps; i++) {
                        g_string_printf(fe_name, "trap %d", i);
                        name_tables->trap_names[i] = g_quark_from_string(fe_name->str);
                }
@@ -2079,11 +2079,10 @@ static void create_name_tables(LttvTraceState *tcs)
                }
                */
                /* FIXME: LttvIRQState *irq_states should become a g_array */
-               /* temp fix: increase from 256 to 512 default size */
 
-               name_tables->nb_irqs = 512;
-               name_tables->irq_names = g_new(GQuark, 512);
-               for(i = 0 ; i < 512 ; i++) {
+               name_tables->nb_irqs = PREALLOC_NB_IRQS;
+               name_tables->irq_names = g_new(GQuark, name_tables->nb_irqs);
+               for(i = 0 ; i < name_tables->nb_irqs; i++) {
                        g_string_printf(fe_name, "irq %d", i);
                        name_tables->irq_names[i] = g_quark_from_string(fe_name->str);
                }
@@ -2099,8 +2098,7 @@ static void create_name_tables(LttvTraceState *tcs)
        }
        */
 
-       /* the kernel is limited to 32 statically defined softirqs */
-       name_tables->nb_soft_irqs = 32;
+       name_tables->nb_soft_irqs = PREALLOC_NB_SOFT_IRQS;
        name_tables->soft_irq_names = g_new(GQuark, name_tables->nb_soft_irqs);
        for(i = 0 ; i < name_tables->nb_soft_irqs ; i++) {
                g_string_printf(fe_name, "softirq %d", i);
@@ -2698,20 +2696,12 @@ static gboolean soft_irq_raise(void *hook_data, void *call_data)
        LttvTraceHook *th = (LttvTraceHook *)hook_data;
        struct marker_field *f = lttv_trace_get_hook_field(th, 0);
        LttvNameTables *nt = ((LttvTraceState *)(s->parent.t_context))->name_tables;
-
        LttvExecutionSubmode submode;
        guint64 softirq = ltt_event_get_long_unsigned(e, f);
-       guint64 nb_softirqs = nt->nb_soft_irqs;
 
-       if(softirq < nb_softirqs) {
-               submode = nt->soft_irq_names[softirq];
-       } else {
-               /* Fixup an incomplete irq table */
-               GString *string = g_string_new("");
-               g_string_printf(string, "softirq %" PRIu64, softirq);
-               submode = g_quark_from_string(string->str);
-               g_string_free(string, TRUE);
-       }
+       expand_soft_irq_table(ts, softirq);
+
+       submode = nt->soft_irq_names[softirq];
 
        /* update softirq status */
        /* a soft irq raises are not cumulative */
index 3f5ca849b8895aa274f50bc48e7ef7a872f3e7fc..ef22627f8447defc376f74c3409a895e08193546 100644 (file)
 
 #define LTTV_STATE_SAVE_INTERVAL 50000
 
+
+#define PREALLOC_NB_SYSCALLS   256
+/*
+ * As of 2.6.38, IRQ 239 has been seen (and we have seen higher than
+ * 256 too.
+ */
+#define PREALLOC_NB_IRQS       512
+/* As of 2.6.38, 255 softirqs are used. */
+#define PREALLOC_NB_SOFT_IRQS  512
+#define PREALLOC_NB_TRAPS      256
+
 /* Channel Quarks */
 
 extern GQuark
This page took 0.027333 seconds and 4 git commands to generate.