From 70441ec3cb97aa058fe44f1918172ee989aee245 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 8 Mar 2012 21:55:37 -0500 Subject: rt-graph: cleanup of graph display --- rt-plot-cpu.c | 74 +++++++++++++++++++++++++++++++++++++++++++++------------- rt-plot-task.c | 25 ++++++++++++-------- trace-graph.c | 14 +++++++---- trace-graph.h | 1 + trace-plot.c | 1 + 5 files changed, 85 insertions(+), 30 deletions(-) diff --git a/rt-plot-cpu.c b/rt-plot-cpu.c index bc37df7..82d03e6 100644 --- a/rt-plot-cpu.c +++ b/rt-plot-cpu.c @@ -44,20 +44,53 @@ next_sa_record(struct graph_info *ginfo, struct rt_cpu_info *rtc_info, return ret; } +static inline int +is_displayed(struct graph_info *ginfo, int eid) +{ + struct rt_graph_info *rtg_info = &ginfo->rtg_info; + return !(eid == rtg_info->switch_away_id || + eid == rtg_info->switch_to_id || + eid == rtg_info->task_completion_id || + eid == rtg_info->task_block_id || + eid == rtg_info->task_resume_id || + eid == rtg_info->task_release_id || + eid == ginfo->event_sched_switch_id); +} + static struct record* -find_record(struct graph_info *ginfo, int cpu, unsigned long long time) +__find_record(struct graph_info *ginfo, int cpu, unsigned long long time, + int display) { - struct record *record = NULL; + struct record *record; + int eid, ignored; + set_cpu_to_rts(ginfo, time, cpu); while ((record = tracecmd_read_data(ginfo->handle, cpu))) { - if (get_rts(ginfo, record) >= time) + ignored = 0; + if (display) { + eid = pevent_data_type(ginfo->pevent, record); + ignored = !is_displayed(ginfo, eid); + } + if (get_rts(ginfo, record) >= time && !ignored) break; free_record(record); } return record; } +static inline struct record* +find_record(struct graph_info *ginfo, int cpu, guint64 time) +{ + return __find_record(ginfo, cpu, time, 0); +} + +static inline struct record* +find_display_record(struct graph_info *ginfo, int cpu, guint64 time) +{ + return __find_record(ginfo, cpu, time, 1); +} + static void update_pid(struct rt_cpu_info *rtc_info, int pid) { @@ -79,7 +112,8 @@ try_switch_away(struct graph_info *ginfo, struct rt_cpu_info *rtc_info, record, &pid, &job, &ts); if (match) { update_pid(rtc_info, pid); - if (rtc_info->rt_run_time && rtc_info->rt_run_time < ts) { + if (rtc_info->rt_run_time && rtc_info->rt_run_time < ts && + job != 1) { info->box = TRUE; info->bcolor = hash_pid(rtc_info->run_pid); info->bfill = TRUE; @@ -220,8 +254,8 @@ static void rt_cpu_plot_start(struct graph_info *ginfo, struct graph_plot *plot, static int rt_cpu_plot_event(struct graph_info *ginfo, struct graph_plot *plot, struct record *record, struct plot_info *info) { - int pid, eid, match; - unsigned long long ts; + int pid, eid, match, dint; + unsigned long long ts, dull; struct rt_cpu_info *rtc_info = plot->private; struct rt_graph_info *rtg_info = &ginfo->rtg_info; @@ -239,11 +273,20 @@ static int rt_cpu_plot_event(struct graph_info *ginfo, struct graph_plot *plot, try_sched_switch(ginfo, rtc_info, record, info); if (!match) { - rt_graph_check_any(rtg_info, ginfo->pevent, record, - &pid, &eid, &ts); - info->line = TRUE; - info->lcolor = hash_pid(pid); - info->ltime = ts; + /* Have to call checks to ensure ids are loaded. Otherwise, + * is_displayed will not work in any methods. + */ +#define ARG rtg_info, ginfo->pevent, record, &pid + rt_graph_check_task_release(ARG, &dint, &dull, &dull); + rt_graph_check_task_block(ARG, &dull); + rt_graph_check_task_resume(ARG, &dull); + rt_graph_check_any(ARG, &eid, &ts); +#undef ARG + if (is_displayed(ginfo, eid)) { + info->line = TRUE; + info->lcolor = hash_pid(pid); + info->ltime = ts; + } } return 1; } @@ -263,7 +306,7 @@ rt_cpu_plot_display_last_event(struct graph_info *ginfo, struct graph_plot *plot if (record) offset = record->offset; - record = find_record(ginfo, cpu, time); + record = find_display_record(ginfo, cpu, time); if (offset) tracecmd_set_cursor(ginfo->handle, cpu, offset); @@ -351,7 +394,7 @@ rt_cpu_plot_display_info(struct graph_info *ginfo, struct graph_plot *plot, if (is_running) { comm = pevent_data_comm_from_pid(ginfo->pevent, pid); - trace_seq_printf(s, "%s-%d:%d\n", comm, pid, job); + trace_seq_printf(s, "%s-%d:%d\n\n", comm, pid, job); } if (record) { @@ -360,16 +403,15 @@ rt_cpu_plot_display_info(struct graph_info *ginfo, struct graph_plot *plot, eid = pevent_data_type(ginfo->pevent, record); event = pevent_data_event_from_type(ginfo->pevent, eid); if (event) { - trace_seq_putc(s, '\n'); trace_seq_puts(s, event->name); trace_seq_putc(s, '\n'); pevent_event_info(s, event, record); + trace_seq_putc(s, '\n'); } else - trace_seq_printf(s, "\nUNKNOWN EVENT %d\n", eid); + trace_seq_printf(s, "UNKNOWN EVENT %d\n", eid); } free_record(record); } - trace_seq_putc(s, '\n'); nano_to_milli(time, &msec, &nsec); trace_seq_printf(s, "%llu.%06llu ms CPU: %03d", msec, nsec, rtc_info->cpu); diff --git a/rt-plot-task.c b/rt-plot-task.c index f8d29ed..947e2e9 100644 --- a/rt-plot-task.c +++ b/rt-plot-task.c @@ -83,18 +83,18 @@ next_box_record(struct graph_info *ginfo, struct rt_task_info *rtt_info, /* * Return first relevant record after @time. - * @display: If set, only considers records which are plotted in some way + * @display: If set, only considers records which aren't plotted */ static struct record* __find_record(struct graph_info *ginfo, gint pid, guint64 time, int display) { - int next_cpu, match, eid, ignored= 0; - struct record *record = NULL; + int next_cpu, match, eid, ignored; + struct record *record; struct rt_graph_info *rtg_info = &ginfo->rtg_info; set_cpus_to_rts(ginfo, time); while ((record = tracecmd_read_next_data(ginfo->handle, &next_cpu))) { - free_record(record); + ignored = 0; match = record_matches_pid(ginfo, record, pid); if (display) { eid = pevent_data_type(ginfo->pevent, record); @@ -105,9 +105,10 @@ __find_record(struct graph_info *ginfo, gint pid, guint64 time, int display) eid == rtg_info->task_resume_id || eid == rtg_info->task_release_id); } - ignored = ignored && eid == ginfo->event_sched_switch_id; + ignored = ignored || eid == ginfo->event_sched_switch_id; if (get_rts(ginfo, record) >= time && match && !ignored) break; + free_record(record); }; return record; @@ -318,9 +319,11 @@ static int try_completion(struct graph_info *ginfo, match = rt_graph_check_task_completion(&ginfo->rtg_info, ginfo->pevent, record, &pid, &job, &ts); if (match && pid == rtt_info->pid) { - update_job(rtt_info, job); + info->completion = TRUE; info->ctime = ts; + update_job(rtt_info, job); + dprintf(3, "Completion for %d:%d on %d at %llu\n", pid, job, record->cpu, ts); ret = 1; @@ -386,7 +389,8 @@ try_switch_away(struct graph_info *ginfo, struct rt_task_info *rtt_info, if (match && pid == rtt_info->pid) { update_job(rtt_info, job); - if (rtt_info->run_time && rtt_info->run_time < ts) { + if (rtt_info->run_time && rtt_info->run_time < ts && + job != 1) { dprintf(3, "Box for %d:%d, %llu to %llu on CPU %d\n", rtt_info->pid, rtt_info->last_job, rtt_info->run_time, ts, record->cpu); @@ -430,7 +434,7 @@ static int try_switch_to(struct graph_info *ginfo, struct rt_task_info *rtt_info static int try_other(struct graph_info *ginfo, struct rt_task_info *rtt_info, struct record *record, struct plot_info *info) { - int pid, eid, epid, my_pid, my_cpu, not_sa, ret = 0; + int pid, eid, epid, my_pid, my_cpu, not_sa, not_ss, ret = 0; unsigned long long ts; pid = rtt_info->pid; @@ -440,8 +444,9 @@ static int try_other(struct graph_info *ginfo, struct rt_task_info *rtt_info, my_pid = (pid == epid); my_cpu = (rtt_info->run_time && record->cpu == rtt_info->run_cpu); not_sa = (eid != ginfo->rtg_info.switch_away_id); - if (not_sa && (my_pid || my_cpu) && - eid != ginfo->event_sched_switch_id) { + not_ss = (eid != ginfo->event_sched_switch_id); + + if ((my_pid || my_cpu) && not_ss && not_sa) { info->line = TRUE; info->lcolor = hash_pid(record->cpu); info->ltime = ts; diff --git a/trace-graph.c b/trace-graph.c index 9ce0853..42a0b27 100644 --- a/trace-graph.c +++ b/trace-graph.c @@ -1632,14 +1632,20 @@ static gint draw_event_label(struct graph_info *ginfo, gint i, } static gint draw_plot_line(struct graph_info *ginfo, int i, - unsigned long long time, GdkGC *gc) + unsigned long long time, gboolean small, + GdkGC *gc) { gint x; + gint y; x = convert_time_to_x(ginfo, time); + /* y = (small) ? PLOT_BOX_TOP(i) : PLOT_TOP(i); */ + y = PLOT_TOP(i); - gdk_draw_line(ginfo->curr_pixmap, gc, - x, PLOT_TOP(i), x, PLOT_BOTTOM(i)); + if (!small || convert_dist_to_time(ginfo, PLOT_TRI_SIZE) < MAX_TRI_TIME) { + gdk_draw_line(ginfo->curr_pixmap, gc, + x, y, x, PLOT_BOTTOM(i)); + } return x; } @@ -1815,7 +1821,7 @@ static void draw_plot(struct graph_info *ginfo, struct graph_plot *plot, set_color(ginfo->draw, plot->gc, plot->last_color); } - x = draw_plot_line(ginfo, plot->pos, info.ltime, plot->gc); + x = draw_plot_line(ginfo, plot->pos, info.ltime, info.lsmall, plot->gc); /* Figure out if we can show the text for the previous record */ diff --git a/trace-graph.h b/trace-graph.h index d3d4cba..4bfef4d 100644 --- a/trace-graph.h +++ b/trace-graph.h @@ -58,6 +58,7 @@ struct graph_plot; struct plot_info { gboolean line; + gboolean lsmall; int lcolor; unsigned long long ltime; diff --git a/trace-plot.c b/trace-plot.c index 5629e47..8551a34 100644 --- a/trace-plot.c +++ b/trace-plot.c @@ -348,6 +348,7 @@ int trace_graph_plot_event(struct graph_info *ginfo, info->line = FALSE; info->box = FALSE; info->bfill = TRUE; + info->lsmall = FALSE; info->blabel = NULL; info->bthin = FALSE; -- cgit v1.2.2