From 6c6d6b6ff8ad6cb08d57232ca8ae0ba0261ac823 Mon Sep 17 00:00:00 2001 From: Jonathan Herman Date: Thu, 29 Mar 2012 15:44:25 -0400 Subject: rt-graph: popup resolution expanded, works in both directions --- rt-graph.h | 2 +- rt-plot-task.c | 37 +++++++++++++++++++------------------ rt-plot.c | 53 ++++++++++++++++++++++++++++++++++++++--------------- rt-plot.h | 6 +++--- 4 files changed, 61 insertions(+), 37 deletions(-) diff --git a/rt-graph.h b/rt-graph.h index 12ce72d..27aeb88 100644 --- a/rt-graph.h +++ b/rt-graph.h @@ -10,7 +10,7 @@ #include "rt-plot-container.h" #define LLABEL 30 -#define SEARCH_PERIODS 1 +#define SEARCH_PERIODS 5 #define NO_CPU -1 #define RT_TS_FIELD "__rt_ts" diff --git a/rt-plot-task.c b/rt-plot-task.c index c72013f..56c3c28 100644 --- a/rt-plot-task.c +++ b/rt-plot-task.c @@ -3,7 +3,7 @@ #include "trace-graph.h" #include "trace-filter.h" -#define DEBUG_LEVEL 0 +#define DEBUG_LEVEL 1 #if DEBUG_LEVEL > 0 #define dprintf(l, x...) \ do { \ @@ -75,6 +75,18 @@ static int update_job(struct rt_task_info *rtt_info, int job) return 1; } +static int rt_task_plot_is_drawn(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); +} + /* * Get information about the given @time. * @out_job: Job number at this time @@ -203,8 +215,8 @@ static int try_block(struct graph_info *ginfo, struct rt_task_info *rtt_info, if (match && pid == rtt_info->pid) { rtt_info->fresh = FALSE; rtt_info->block_time = ts; - rtt_info->block_cpu = NO_CPU; - dprintf(3, "Resume for %d on %d at %llu\n", + rtt_info->block_cpu = record->cpu; + dprintf(3, "Block for %d on %d at %llu\n", pid, record->cpu, ts); ret = 1; } @@ -292,7 +304,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, not_ss, ret = 0; + int pid, eid, epid, my_pid, my_cpu, not_sa, not_ss, not_drawn, ret = 0; unsigned long long ts; pid = rtt_info->pid; @@ -302,8 +314,9 @@ static int try_other(struct graph_info *ginfo, struct rt_task_info *rtt_info, my_cpu = (rtt_info->run_time && record->cpu == rtt_info->run_cpu); not_sa = (eid != ginfo->rtg_info.switch_away_id); not_ss = (eid != ginfo->event_sched_switch_id); + not_drawn = (!rt_task_plot_is_drawn(ginfo, eid)); - if ((my_pid || my_cpu) && not_ss && not_sa) { + if ((my_pid || my_cpu) && not_ss && not_sa && not_drawn) { info->line = TRUE; info->lcolor = hash_pid(record->cpu); info->ltime = ts; @@ -448,18 +461,6 @@ rt_task_plot_record_matches(struct rt_plot_common *rt, } -static int rt_task_plot_is_drawn(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); -} - static struct record* rt_task_plot_write_header(struct rt_plot_common *rt, struct graph_info *ginfo, @@ -467,7 +468,7 @@ rt_task_plot_write_header(struct rt_plot_common *rt, unsigned long long time) { const char *comm; - int pid, job, found; + int pid, job = -1, found; struct record *record; unsigned long long release, deadline; struct rt_task_info *rtt_info = (struct rt_task_info*)rt; diff --git a/rt-plot.c b/rt-plot.c index c45ee0e..10f8b2d 100644 --- a/rt-plot.c +++ b/rt-plot.c @@ -7,13 +7,20 @@ */ struct record* __find_rt_record(struct graph_info *ginfo, struct rt_plot_common *rt_info, - guint64 time, int display) + guint64 time, int display, unsigned long long range) { int next_cpu, match, eid, ignored; struct record *record; set_cpus_to_rts(ginfo, time); while ((record = tracecmd_read_next_data(ginfo->handle, &next_cpu))) { + + if (range && get_rts(ginfo, record) >= time + range) { + free_record(record); + record = NULL; + break; + } + eid = pevent_data_type(ginfo->pevent, record); ignored = (eid == ginfo->event_sched_switch_id); if (!ignored && display) { @@ -65,14 +72,17 @@ rt_plot_display_last_event(struct graph_info *ginfo, struct graph_plot *plot, } static struct record* -find_prev_record(struct graph_info *ginfo, struct rt_plot_common *rt_info, - unsigned long long time) +find_prev_display_record(struct graph_info *ginfo, struct rt_plot_common *rt_info, + unsigned long long time, unsigned long long range) { int eid, ignored, match, cpu; struct record *prev, *res = NULL; unsigned long long min_ts; - min_ts = time - max_rt_search(ginfo); + if (range) + min_ts = time - range; + else + min_ts = time - max_rt_search(ginfo); set_cpus_to_rts(ginfo, time); @@ -111,17 +121,25 @@ rt_plot_display_info(struct graph_info *ginfo, struct graph_plot *plot, struct rt_plot_common *rt_info = plot->private; struct event_format *event; struct record *record, *prev_record; - unsigned long long msec, nsec, rts; + unsigned long long msec, nsec, rts, ptime, rtime, range; + long long pdiff, rdiff; int eid; - record = rt_info->write_header(rt_info, ginfo, s, time); - prev_record = find_prev_record(ginfo, rt_info, time); - - if (!record || (prev_record && prev_record != record && - (time - get_rts(ginfo, prev_record)) < - (get_rts(ginfo, record) - time))) { - free_record(record); - record = prev_record; + rt_info->write_header(rt_info, ginfo, s, time); + + /* Stupid, fix to use resolution */ + range = 2 / ginfo->resolution; + record = __find_rt_record(ginfo, rt_info, time, 1, range); + prev_record = find_prev_display_record(ginfo, rt_info, time, range); + + if (!record) { + record = prev_record; + } else if (prev_record) { + ptime = get_rts(ginfo, prev_record); + rtime = get_rts(ginfo, record); + pdiff = (ptime < time) ? time - ptime : ptime - time; + rdiff = (rtime < time) ? time - rtime : rtime - time; + record = (pdiff < rdiff) ? prev_record : record; } if (record) { @@ -137,6 +155,8 @@ rt_plot_display_info(struct graph_info *ginfo, struct graph_plot *plot, pevent_event_info(s, event, record); } else trace_seq_printf(s, "\nUNKNOWN EVENT %d\n", eid); + } else { + trace_seq_printf(s, "Failsauce\n"); } trace_seq_putc(s, '\n'); nano_to_milli(time, &msec, &nsec); @@ -349,15 +369,19 @@ struct record* get_previous_release(struct graph_info *ginfo, int match_tid, unsigned long long release, deadline, min_ts; struct record *last_rec = NULL, *rec, *ret = NULL; + *out_job = -2; + min_ts = time - max_rt_search(ginfo); /* The release record could have occurred on any CPU. Search all */ for (cpu = 0; cpu < ginfo->cpus; cpu++) { + set_cpu_to_rts(ginfo, time, cpu); last_rec = tracecmd_peek_data(ginfo->handle, cpu); /* Require a record to start with */ - if (!last_rec) + if (!last_rec) { goto loop_end; + } last_rec->ref_count++; while ((rec = tracecmd_read_prev(ginfo->handle, last_rec))) { @@ -384,7 +408,6 @@ struct record* get_previous_release(struct graph_info *ginfo, int match_tid, *out_release = release; *out_deadline = deadline; } - last_rec = NULL; goto loop_end; } diff --git a/rt-plot.h b/rt-plot.h index cae15ae..1b04547 100644 --- a/rt-plot.h +++ b/rt-plot.h @@ -36,19 +36,19 @@ rt_plot_match_time(struct graph_info *ginfo, struct graph_plot *plot, unsigned long long time); struct record* __find_rt_record(struct graph_info *ginfo, struct rt_plot_common *rt, - guint64 time, int display); + guint64 time, int display, unsigned long long range); static inline struct record* find_rt_record(struct graph_info *ginfo, struct rt_plot_common *rt, guint64 time) { - return __find_rt_record(ginfo, rt, time, 0); + return __find_rt_record(ginfo, rt, time, 0, 0); } static inline struct record* find_rt_display_record(struct graph_info *ginfo, struct rt_plot_common *rt, guint64 time) { - return __find_rt_record(ginfo, rt, time, 1); + return __find_rt_record(ginfo, rt, time, 1, 0); } unsigned long long next_rts(struct graph_info *ginfo, int cpu, -- cgit v1.2.2