X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Flttv%2Fstate.c;h=1e7d1d2b120b59a0fb306b6ece649886e457f923;hb=dc6b246703be1051c20919746dc34eccbc8912ea;hp=bcb44f5ace21e4cc0a20486840b701ec43dd4c0b;hpb=0bc550223aad93406ad19887decdd079686610ba;p=lttv.git diff --git a/ltt/branches/poly/lttv/lttv/state.c b/ltt/branches/poly/lttv/lttv/state.c index bcb44f5a..1e7d1d2b 100644 --- a/ltt/branches/poly/lttv/lttv/state.c +++ b/ltt/branches/poly/lttv/lttv/state.c @@ -31,6 +31,7 @@ #include #include #include +#include /* Comment : * Mathieu Desnoyers @@ -52,7 +53,8 @@ GQuark LTT_FACILITY_LIST, LTT_FACILITY_FS, LTT_FACILITY_USER_GENERIC, - LTT_FACILITY_BLOCK; + LTT_FACILITY_BLOCK, + LTT_FACILITY_STATEDUMP; /* Events Quarks */ @@ -78,7 +80,9 @@ GQuark LTT_EVENT_THREAD_BRAND, LTT_EVENT_REQUEST_ISSUE, LTT_EVENT_REQUEST_COMPLETE, - LTT_EVENT_LIST_INTERRUPT; + LTT_EVENT_LIST_INTERRUPT, + LTT_EVENT_SYS_CALL_TABLE, + LTT_EVENT_SOFTIRQ_VEC; /* Fields Quarks */ @@ -106,7 +110,10 @@ GQuark LTT_FIELD_MINOR, LTT_FIELD_MAJOR, LTT_FIELD_OPERATION, - LTT_FIELD_ACTION; + LTT_FIELD_ACTION, + LTT_FIELD_ID, + LTT_FIELD_ADDRESS, + LTT_FIELD_SYMBOL; LttvExecutionMode LTTV_STATE_MODE_UNKNOWN, @@ -2239,17 +2246,23 @@ lttv_state_find_process_or_create(LttvTraceState *ts, guint cpu, guint pid, * has the flag SA_NOCLDWAIT. It can also happen when the child is part * of a killed thread group, but isn't the leader. */ -static void exit_process(LttvTracefileState *tfs, LttvProcessState *process) +static int exit_process(LttvTracefileState *tfs, LttvProcessState *process) { LttvTraceState *ts = LTTV_TRACE_STATE(tfs->parent.t_context); LttvProcessState key; + /* Wait for both schedule with exit dead and process free to happen. + * They can happen in any order. */ + if (++(process->free_events) < 2) + return 0; + key.pid = process->pid; key.cpu = process->cpu; g_hash_table_remove(ts->processes, &key); g_array_free(process->execution_stack, TRUE); g_array_free(process->user_stack, TRUE); g_free(process); + return 1; } @@ -2620,6 +2633,58 @@ static gboolean function_exit(void *hook_data, void *call_data) return FALSE; } +static gboolean dump_syscall(void *hook_data, void *call_data) +{ + LttvTracefileState *s = (LttvTracefileState *)call_data; + LttvTraceState *ts = (LttvTraceState*)s->parent.t_context; + LttEvent *e = ltt_tracefile_get_event(s->parent.tf); + LttvTraceHook *th = (LttvTraceHook *)hook_data; + guint id; + guint64 address; + char *symbol; + + id = ltt_event_get_unsigned(e, lttv_trace_get_hook_field(th, 0)); + address = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 1)); + symbol = ltt_event_get_string(e, lttv_trace_get_hook_field(th, 2)); + + if (ts->nb_syscalls < id) { + GQuark *old_names = ts->syscall_names; + guint new_nb_syscalls = max(id + 1, ts->nb_syscalls * 2); + guint i; + GString *fe_name = g_string_new(""); + ts->syscall_names = g_new(GQuark, new_nb_syscalls); + memcpy(ts->syscall_names, old_names, + ts->nb_syscalls * sizeof(GQuark)); + for(i = ts->nb_syscalls ; i < new_nb_syscalls ; i++) { + g_string_printf(fe_name, "syscall %d", i); + ts->syscall_names[i] = g_quark_from_string(fe_name->str); + } + g_string_free(fe_name, TRUE); + ts->nb_syscalls = new_nb_syscalls; + } + ts->syscall_names[id] = g_quark_from_string(symbol); + + return FALSE; +} + +static gboolean dump_softirq(void *hook_data, void *call_data) +{ + LttvTracefileState *s = (LttvTracefileState *)call_data; + LttvTraceState *ts = (LttvTraceState*)s->parent.t_context; + LttEvent *e = ltt_tracefile_get_event(s->parent.tf); + LttvTraceHook *th = (LttvTraceHook *)hook_data; + guint id; + guint64 address; + char *symbol; + + id = ltt_event_get_unsigned(e, lttv_trace_get_hook_field(th, 0)); + address = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 1)); + symbol = ltt_event_get_string(e, lttv_trace_get_hook_field(th, 2)); + ts->soft_irq_names[id] = g_quark_from_string(symbol); + + return FALSE; +} + static gboolean schedchange(void *hook_data, void *call_data) { LttvTracefileState *s = (LttvTracefileState *)call_data; @@ -2674,8 +2739,10 @@ static gboolean schedchange(void *hook_data, void *call_data) if(state_out == 32 || state_out == 64) { /* EXIT_DEAD || TASK_DEAD */ /* see sched.h for states */ - process->state->s = LTTV_STATE_DEAD; - process->state->change = s->parent.timestamp; + if (!exit_process(s, process)) { + process->state->s = LTTV_STATE_DEAD; + process->state->change = s->parent.timestamp; + } } } } @@ -2857,6 +2924,33 @@ static gboolean process_free(void *hook_data, void *call_data) process = lttv_state_find_process(ts, ANY_CPU, release_pid); if(likely(process != NULL)) exit_process(s, process); + return FALSE; +//DISABLED + if(likely(process != NULL)) { + /* release_task is happening at kernel level : we can now safely release + * the data structure of the process */ + //This test is fun, though, as it may happen that + //at time t : CPU 0 : process_free + //at time t+150ns : CPU 1 : schedule out + //Clearly due to time imprecision, we disable it. (Mathieu) + //If this weird case happen, we have no choice but to put the + //Currently running process on the cpu to 0. + //I re-enable it following time precision fixes. (Mathieu) + //Well, in the case where an process is freed by a process on another CPU + //and still scheduled, it happens that this is the schedchange that will + //drop the last reference count. Do not free it here! + guint num_cpus = ltt_trace_get_num_cpu(ts->parent.t); + guint i; + for(i=0; i< num_cpus; i++) { + //g_assert(process != ts->running_process[i]); + if(process == ts->running_process[i]) { + //ts->running_process[i] = lttv_state_find_process(ts, i, 0); + break; + } + } + if(i == num_cpus) /* process is not scheduled */ + exit_process(s, process); + } return FALSE; } @@ -3315,6 +3409,18 @@ void lttv_state_add_event_hooks(LttvTracesetState *self) FIELD_ARRAY(LTT_FIELD_THIS_FN, LTT_FIELD_CALL_SITE), function_exit, NULL, &hooks); + lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_STATEDUMP, + LTT_EVENT_SYS_CALL_TABLE, + FIELD_ARRAY(LTT_FIELD_ID, LTT_FIELD_ADDRESS, LTT_FIELD_SYMBOL), + dump_syscall, NULL, &hooks); + + lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_STATEDUMP, + LTT_EVENT_SOFTIRQ_VEC, + FIELD_ARRAY(LTT_FIELD_ID, LTT_FIELD_ADDRESS, LTT_FIELD_SYMBOL), + dump_softirq, NULL, &hooks); + /* Add these hooks to each event_by_id hooks list */ nb_tracefile = ts->parent.tracefiles->len; @@ -3978,8 +4084,8 @@ static void module_init() LTT_FACILITY_LIST = g_quark_from_string("list"); LTT_FACILITY_USER_GENERIC = g_quark_from_string("user_generic"); LTT_FACILITY_BLOCK = g_quark_from_string("block"); - - + LTT_FACILITY_STATEDUMP = g_quark_from_string("statedump"); + LTT_EVENT_SYSCALL_ENTRY = g_quark_from_string("syscall_entry"); LTT_EVENT_SYSCALL_EXIT = g_quark_from_string("syscall_exit"); LTT_EVENT_TRAP_ENTRY = g_quark_from_string("trap_entry"); @@ -4001,8 +4107,9 @@ static void module_init() LTT_EVENT_THREAD_BRAND = g_quark_from_string("thread_brand"); LTT_EVENT_REQUEST_ISSUE = g_quark_from_string("_blk_request_issue"); LTT_EVENT_REQUEST_COMPLETE = g_quark_from_string("_blk_request_complete"); - LTT_EVENT_LIST_INTERRUPT = g_quark_from_string("interrupt");; - + LTT_EVENT_LIST_INTERRUPT = g_quark_from_string("interrupt"); + LTT_EVENT_SYS_CALL_TABLE = g_quark_from_string("sys_call_table"); + LTT_EVENT_SOFTIRQ_VEC = g_quark_from_string("softirq_vec"); LTT_FIELD_SYSCALL_ID = g_quark_from_string("syscall_id"); LTT_FIELD_TRAP_ID = g_quark_from_string("trap_id"); @@ -4028,6 +4135,9 @@ static void module_init() LTT_FIELD_MINOR = g_quark_from_string("minor"); LTT_FIELD_OPERATION = g_quark_from_string("direction"); LTT_FIELD_ACTION = g_quark_from_string("action"); + LTT_FIELD_ID = g_quark_from_string("id"); + LTT_FIELD_ADDRESS = g_quark_from_string("address"); + LTT_FIELD_SYMBOL = g_quark_from_string("symbol"); LTTV_CPU_UNKNOWN = g_quark_from_string("unknown"); LTTV_CPU_IDLE = g_quark_from_string("idle");