From 93290e83d330653f090b3780e59ea5d2bf1e3bca Mon Sep 17 00:00:00 2001 From: Jonathan Herman Date: Fri, 5 Oct 2012 17:14:37 -0400 Subject: Rewrote set_cpu_to_rts() and iterate() for increased performance and accuracy. Container job information functions, like displaying the job in the server's boxes or the currently running task in pop-ups, rewritten to take advantage of these changes. --- rt-plot-container.c | 114 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 80 insertions(+), 34 deletions(-) (limited to 'rt-plot-container.c') diff --git a/rt-plot-container.c b/rt-plot-container.c index 94f78ee..6c647fc 100644 --- a/rt-plot-container.c +++ b/rt-plot-container.c @@ -22,6 +22,80 @@ int rt_plot_get_containers(struct graph_info *ginfo, gint **conts, return count; } +struct record * +rt_read_next_data(struct graph_info *ginfo, struct tracecmd_input *handle, int *rec_cpu) +{ + unsigned long long ts; + struct record *record; + int next; + int cpu; + + if (rec_cpu) + *rec_cpu = -1; + + next = -1; + ts = 0; + + for (cpu = 0; cpu < ginfo->cpus; cpu++) { + record = tracecmd_peek_data(handle, cpu); + if (record && (!ts || get_rts(ginfo, record) < ts)) { + ts = get_rts(ginfo, record); + next = cpu; + } + } + + if (next >= 0) { + if (rec_cpu) + *rec_cpu = next; + return tracecmd_read_data(handle, next); + } + + return NULL; +} + +struct server_iter_args { + unsigned long long goal; + int match_sid; + + int *out_job; + int *out_tid; + int *out_tjob; + int is_running; +}; + +static int server_iterator(struct graph_info *ginfo, struct record *record, void *data) +{ + int sid, job, tid, tjob, match; + struct server_iter_args *args = data; + unsigned long long when, time = get_rts(ginfo, record); + + if (time > args->goal + max_rt_search(ginfo)) + return 0; + if (time < args->goal) + return 1; + +#define ARGS ginfo, record, &sid, &job, &tid, &tjob, &when + match = rt_graph_check_server_switch_away(ARGS); + if (match && sid == args->match_sid) { + (*args->out_tid) = tid; + (*args->out_tjob) = tjob; + (*args->out_job) = job; + args->is_running = 1; + return 0; + + } + + match = rt_graph_check_server_switch_to(ARGS); + if (match && sid == args->match_sid) { + /* We must not have been running anything */ + (*args->out_job) = job; + return 0; + } + +#undef ARGS + return 1; +} + int get_server_info(struct graph_info *ginfo, struct rt_plot_common *rt, int match_sid, unsigned long long time, unsigned long long *out_release, @@ -29,47 +103,19 @@ int get_server_info(struct graph_info *ginfo, struct rt_plot_common *rt, int *out_job, int *out_tid, int *out_tjob, struct record **out_record) { - struct record *record; - int sid, job, tid, tjob, match, next_cpu, is_running = 0; - unsigned long long when, max_ts; + struct server_iter_args args = {time, match_sid, + out_job, out_tid, out_tjob, 0}; *out_record = find_rt_record(ginfo, rt, time); - if (!(*out_record)) + if (!*out_record) return 0; *out_release = *out_deadline = *out_job = *out_tid = 0; - /* Get current job info for server task */ - get_previous_release(ginfo, rt, sid, time, - out_job, out_release, out_deadline); - - /* Need to reset back to current location */ - record = find_rt_record(ginfo, rt, time); - if (!record) - goto out; - - /* TODO: read backwards too */ - max_ts = time + max_rt_search(ginfo); - do { - if (get_rts(ginfo, record) > max_ts) - break; - - match = rt_graph_check_server_switch_away(ginfo, record, - &sid, &job, &tid, &tjob, - &when); - if (match && sid == match_sid) { - *out_tid = tid; - *out_tjob = tjob; - is_running = 1; - break; - } - free_record(record); - } while ((record = tracecmd_read_next_data(ginfo->handle, &next_cpu))); + set_cpus_to_rts(ginfo, time); + iterate(ginfo, 0, server_iterator, &args); - if (record && record != *out_record) - free_record(record); - out: - return is_running; + return args.is_running; } void rt_plot_container(struct graph_info *ginfo, int cid) -- cgit v1.2.2