diff options
Diffstat (limited to 'rt-plot-container.c')
-rw-r--r-- | rt-plot-container.c | 114 |
1 files changed, 80 insertions, 34 deletions
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, | |||
22 | return count; | 22 | return count; |
23 | } | 23 | } |
24 | 24 | ||
25 | struct record * | ||
26 | rt_read_next_data(struct graph_info *ginfo, struct tracecmd_input *handle, int *rec_cpu) | ||
27 | { | ||
28 | unsigned long long ts; | ||
29 | struct record *record; | ||
30 | int next; | ||
31 | int cpu; | ||
32 | |||
33 | if (rec_cpu) | ||
34 | *rec_cpu = -1; | ||
35 | |||
36 | next = -1; | ||
37 | ts = 0; | ||
38 | |||
39 | for (cpu = 0; cpu < ginfo->cpus; cpu++) { | ||
40 | record = tracecmd_peek_data(handle, cpu); | ||
41 | if (record && (!ts || get_rts(ginfo, record) < ts)) { | ||
42 | ts = get_rts(ginfo, record); | ||
43 | next = cpu; | ||
44 | } | ||
45 | } | ||
46 | |||
47 | if (next >= 0) { | ||
48 | if (rec_cpu) | ||
49 | *rec_cpu = next; | ||
50 | return tracecmd_read_data(handle, next); | ||
51 | } | ||
52 | |||
53 | return NULL; | ||
54 | } | ||
55 | |||
56 | struct server_iter_args { | ||
57 | unsigned long long goal; | ||
58 | int match_sid; | ||
59 | |||
60 | int *out_job; | ||
61 | int *out_tid; | ||
62 | int *out_tjob; | ||
63 | int is_running; | ||
64 | }; | ||
65 | |||
66 | static int server_iterator(struct graph_info *ginfo, struct record *record, void *data) | ||
67 | { | ||
68 | int sid, job, tid, tjob, match; | ||
69 | struct server_iter_args *args = data; | ||
70 | unsigned long long when, time = get_rts(ginfo, record); | ||
71 | |||
72 | if (time > args->goal + max_rt_search(ginfo)) | ||
73 | return 0; | ||
74 | if (time < args->goal) | ||
75 | return 1; | ||
76 | |||
77 | #define ARGS ginfo, record, &sid, &job, &tid, &tjob, &when | ||
78 | match = rt_graph_check_server_switch_away(ARGS); | ||
79 | if (match && sid == args->match_sid) { | ||
80 | (*args->out_tid) = tid; | ||
81 | (*args->out_tjob) = tjob; | ||
82 | (*args->out_job) = job; | ||
83 | args->is_running = 1; | ||
84 | return 0; | ||
85 | |||
86 | } | ||
87 | |||
88 | match = rt_graph_check_server_switch_to(ARGS); | ||
89 | if (match && sid == args->match_sid) { | ||
90 | /* We must not have been running anything */ | ||
91 | (*args->out_job) = job; | ||
92 | return 0; | ||
93 | } | ||
94 | |||
95 | #undef ARGS | ||
96 | return 1; | ||
97 | } | ||
98 | |||
25 | int get_server_info(struct graph_info *ginfo, struct rt_plot_common *rt, | 99 | int get_server_info(struct graph_info *ginfo, struct rt_plot_common *rt, |
26 | int match_sid, unsigned long long time, | 100 | int match_sid, unsigned long long time, |
27 | unsigned long long *out_release, | 101 | unsigned long long *out_release, |
@@ -29,47 +103,19 @@ int get_server_info(struct graph_info *ginfo, struct rt_plot_common *rt, | |||
29 | int *out_job, int *out_tid, int *out_tjob, | 103 | int *out_job, int *out_tid, int *out_tjob, |
30 | struct record **out_record) | 104 | struct record **out_record) |
31 | { | 105 | { |
32 | struct record *record; | 106 | struct server_iter_args args = {time, match_sid, |
33 | int sid, job, tid, tjob, match, next_cpu, is_running = 0; | 107 | out_job, out_tid, out_tjob, 0}; |
34 | unsigned long long when, max_ts; | ||
35 | 108 | ||
36 | *out_record = find_rt_record(ginfo, rt, time); | 109 | *out_record = find_rt_record(ginfo, rt, time); |
37 | if (!(*out_record)) | 110 | if (!*out_record) |
38 | return 0; | 111 | return 0; |
39 | 112 | ||
40 | *out_release = *out_deadline = *out_job = *out_tid = 0; | 113 | *out_release = *out_deadline = *out_job = *out_tid = 0; |
41 | 114 | ||
42 | /* Get current job info for server task */ | 115 | set_cpus_to_rts(ginfo, time); |
43 | get_previous_release(ginfo, rt, sid, time, | 116 | iterate(ginfo, 0, server_iterator, &args); |
44 | out_job, out_release, out_deadline); | ||
45 | |||
46 | /* Need to reset back to current location */ | ||
47 | record = find_rt_record(ginfo, rt, time); | ||
48 | if (!record) | ||
49 | goto out; | ||
50 | |||
51 | /* TODO: read backwards too */ | ||
52 | max_ts = time + max_rt_search(ginfo); | ||
53 | do { | ||
54 | if (get_rts(ginfo, record) > max_ts) | ||
55 | break; | ||
56 | |||
57 | match = rt_graph_check_server_switch_away(ginfo, record, | ||
58 | &sid, &job, &tid, &tjob, | ||
59 | &when); | ||
60 | if (match && sid == match_sid) { | ||
61 | *out_tid = tid; | ||
62 | *out_tjob = tjob; | ||
63 | is_running = 1; | ||
64 | break; | ||
65 | } | ||
66 | free_record(record); | ||
67 | } while ((record = tracecmd_read_next_data(ginfo->handle, &next_cpu))); | ||
68 | 117 | ||
69 | if (record && record != *out_record) | 118 | return args.is_running; |
70 | free_record(record); | ||
71 | out: | ||
72 | return is_running; | ||
73 | } | 119 | } |
74 | 120 | ||
75 | void rt_plot_container(struct graph_info *ginfo, int cid) | 121 | void rt_plot_container(struct graph_info *ginfo, int cid) |