diff options
| author | Jonathan <hermanjl@hermanjl-Aspire-5553G.(none)> | 2012-03-05 23:01:14 -0500 |
|---|---|---|
| committer | Jonathan <hermanjl@hermanjl-Aspire-5553G.(none)> | 2012-03-05 23:01:14 -0500 |
| commit | bb3a47fd55929bbeef0a6dfdef1017391d5b7425 (patch) | |
| tree | 06481a5e4dc47e3090d15a47257f0e32ae76aa4f | |
| parent | 61266395ff4f371933c104cff6671aae7f43c3fd (diff) | |
rt-graph: simple real-time task plots
| -rw-r--r-- | rt-graph.c | 99 | ||||
| -rw-r--r-- | rt-graph.h | 19 | ||||
| -rw-r--r-- | rt-plot-task.c | 293 | ||||
| -rw-r--r-- | rt-plot-task.h | 12 | ||||
| -rw-r--r-- | trace-graph.h | 15 | ||||
| -rw-r--r-- | trace-plot-cpu.c | 12 | ||||
| -rw-r--r-- | trace-plot-task.c | 25 | ||||
| -rw-r--r-- | trace-plot-task.h | 9 |
8 files changed, 439 insertions, 45 deletions
| @@ -11,6 +11,7 @@ | |||
| 11 | #else | 11 | #else |
| 12 | #define dprintf(l, x...) do { if (0) printf(x); } while (0) | 12 | #define dprintf(l, x...) do { if (0) printf(x); } while (0) |
| 13 | #endif | 13 | #endif |
| 14 | |||
| 14 | /** | 15 | /** |
| 15 | * rt_graph_check_task_param - check for litmus_task_param record | 16 | * rt_graph_check_task_param - check for litmus_task_param record |
| 16 | * Return 1 and @pid, @wcet, and @period if the record matches | 17 | * Return 1 and @pid, @wcet, and @period if the record matches |
| @@ -62,6 +63,94 @@ int rt_graph_check_task_param(struct rt_graph_info *rtinfo, | |||
| 62 | } | 63 | } |
| 63 | 64 | ||
| 64 | /** | 65 | /** |
| 66 | * rt_graph_check_task_switch_to - check for litmus_task_switch_to record | ||
| 67 | * Return 1 and @pid, @job, and @when if the record matches | ||
| 68 | */ | ||
| 69 | int rt_graph_check_task_switch_to(struct rt_graph_info *rtinfo, | ||
| 70 | struct pevent *pevent, struct record *record, | ||
| 71 | gint *pid, gint *job, | ||
| 72 | unsigned long long *when) | ||
| 73 | { | ||
| 74 | struct event_format *event; | ||
| 75 | unsigned long long val; | ||
| 76 | gint id; | ||
| 77 | int ret = 0; | ||
| 78 | |||
| 79 | if (rtinfo->task_switch_to_id < 0) { | ||
| 80 | event = pevent_find_event_by_name(pevent, "litmus", | ||
| 81 | "litmus_task_switch_to"); | ||
| 82 | if (!event) | ||
| 83 | goto out; | ||
| 84 | rtinfo->task_switch_to_id = event->id; | ||
| 85 | dprintf(2, "Found task_switch_to id %d\n", event->id); | ||
| 86 | rtinfo->switch_to_pid_field = pevent_find_field(event, "pid"); | ||
| 87 | rtinfo->switch_to_job_field = pevent_find_field(event, "job"); | ||
| 88 | rtinfo->switch_to_when_field = pevent_find_field(event, "when"); | ||
| 89 | } | ||
| 90 | |||
| 91 | id = pevent_data_type(pevent, record); | ||
| 92 | if (id == rtinfo->task_switch_to_id) { | ||
| 93 | pevent_read_number_field(rtinfo->switch_to_pid_field, | ||
| 94 | record->data, &val); | ||
| 95 | *pid = val; | ||
| 96 | pevent_read_number_field(rtinfo->switch_to_job_field, | ||
| 97 | record->data, &val); | ||
| 98 | *job = val; | ||
| 99 | pevent_read_number_field(rtinfo->switch_to_when_field, | ||
| 100 | record->data, when); | ||
| 101 | ret = 1; | ||
| 102 | dprintf(3, "Read task_switch_to (%d) record for job %d:%d, " | ||
| 103 | "when: %llu\n", id, *pid, *job, *when); | ||
| 104 | } | ||
| 105 | out: | ||
| 106 | return ret; | ||
| 107 | } | ||
| 108 | |||
| 109 | /** | ||
| 110 | * rt_graph_check_task_switch_away - check for litmus_task_switch_away record | ||
| 111 | * Return 1 and @pid, @job, and @when if the record matches | ||
| 112 | */ | ||
| 113 | int rt_graph_check_task_switch_away(struct rt_graph_info *rtinfo, | ||
| 114 | struct pevent *pevent, struct record *record, | ||
| 115 | gint *pid, gint *job, | ||
| 116 | unsigned long long *when) | ||
| 117 | { | ||
| 118 | struct event_format *event; | ||
| 119 | unsigned long long val; | ||
| 120 | gint id; | ||
| 121 | int ret = 0; | ||
| 122 | |||
| 123 | if (rtinfo->task_switch_away_id < 0) { | ||
| 124 | event = pevent_find_event_by_name(pevent, "litmus", | ||
| 125 | "litmus_task_switch_away"); | ||
| 126 | if (!event) | ||
| 127 | goto out; | ||
| 128 | rtinfo->task_switch_away_id = event->id; | ||
| 129 | dprintf(2, "Found task_switch_away id %d\n", event->id); | ||
| 130 | rtinfo->switch_away_pid_field = pevent_find_field(event, "pid"); | ||
| 131 | rtinfo->switch_away_job_field = pevent_find_field(event, "job"); | ||
| 132 | rtinfo->switch_away_when_field = pevent_find_field(event, "when"); | ||
| 133 | } | ||
| 134 | |||
| 135 | id = pevent_data_type(pevent, record); | ||
| 136 | if (id == rtinfo->task_switch_away_id) { | ||
| 137 | pevent_read_number_field(rtinfo->switch_away_pid_field, | ||
| 138 | record->data, &val); | ||
| 139 | *pid = val; | ||
| 140 | pevent_read_number_field(rtinfo->switch_away_job_field, | ||
| 141 | record->data, &val); | ||
| 142 | *job = val; | ||
| 143 | pevent_read_number_field(rtinfo->switch_away_when_field, | ||
| 144 | record->data, when); | ||
| 145 | ret = 1; | ||
| 146 | dprintf(3, "Read task_switch_away (%d) record for job %d:%d, " | ||
| 147 | "when: %llu\n", id, *pid, *job, *when); | ||
| 148 | } | ||
| 149 | out: | ||
| 150 | return ret; | ||
| 151 | } | ||
| 152 | |||
| 153 | /** | ||
| 65 | * rt_graph_check_task_release - check for litmus_task_release record | 154 | * rt_graph_check_task_release - check for litmus_task_release record |
| 66 | * Return 1 and @pid, @job, and @deadline if the record matches | 155 | * Return 1 and @pid, @job, and @deadline if the record matches |
| 67 | */ | 156 | */ |
| @@ -236,6 +325,8 @@ void init_rt_event_cache(struct rt_graph_info *rtinfo) | |||
| 236 | { | 325 | { |
| 237 | dprintf(1, "Initializing RT event cache\n"); | 326 | dprintf(1, "Initializing RT event cache\n"); |
| 238 | rtinfo->task_param_id = -1; | 327 | rtinfo->task_param_id = -1; |
| 328 | rtinfo->task_switch_to_id = -1; | ||
| 329 | rtinfo->task_switch_away = -1; | ||
| 239 | rtinfo->task_release_id = -1; | 330 | rtinfo->task_release_id = -1; |
| 240 | rtinfo->task_completion_id = -1; | 331 | rtinfo->task_completion_id = -1; |
| 241 | rtinfo->task_block_id = -1; | 332 | rtinfo->task_block_id = -1; |
| @@ -245,6 +336,14 @@ void init_rt_event_cache(struct rt_graph_info *rtinfo) | |||
| 245 | rtinfo->param_wcet_field = NULL; | 336 | rtinfo->param_wcet_field = NULL; |
| 246 | rtinfo->param_period_field = NULL; | 337 | rtinfo->param_period_field = NULL; |
| 247 | 338 | ||
| 339 | rtinfo->switch_to_pid_field = NULL; | ||
| 340 | rtinfo->switch_to_job_field = NULL; | ||
| 341 | rtinfo->switch_to_when_field = NULL; | ||
| 342 | |||
| 343 | rtinfo->switch_away_pid_field = NULL; | ||
| 344 | rtinfo->switch_away_job_field = NULL; | ||
| 345 | rtinfo->switch_away_when_field = NULL; | ||
| 346 | |||
| 248 | rtinfo->release_pid_field = NULL; | 347 | rtinfo->release_pid_field = NULL; |
| 249 | rtinfo->release_job_field = NULL; | 348 | rtinfo->release_job_field = NULL; |
| 250 | rtinfo->release_release_field = NULL; | 349 | rtinfo->release_release_field = NULL; |
| @@ -8,7 +8,7 @@ | |||
| 8 | 8 | ||
| 9 | struct rt_graph_info { | 9 | struct rt_graph_info { |
| 10 | 10 | ||
| 11 | /* List of all tasks */ | 11 | /* List of all real-time tasks */ |
| 12 | struct task_list *tasks[TASK_HASH_SIZE]; | 12 | struct task_list *tasks[TASK_HASH_SIZE]; |
| 13 | 13 | ||
| 14 | /* Cache of event fields so that they don't need to be located | 14 | /* Cache of event fields so that they don't need to be located |
| @@ -19,6 +19,16 @@ struct rt_graph_info { | |||
| 19 | struct format_field *param_wcet_field; | 19 | struct format_field *param_wcet_field; |
| 20 | struct format_field *param_period_field; | 20 | struct format_field *param_period_field; |
| 21 | 21 | ||
| 22 | gint task_switch_to_id; | ||
| 23 | struct format_field *switch_to_pid_field; | ||
| 24 | struct format_field *switch_to_job_field; | ||
| 25 | struct format_field *switch_to_when_field; | ||
| 26 | |||
| 27 | gint task_switch_away_id; | ||
| 28 | struct format_field *switch_to_pid_field; | ||
| 29 | struct format_field *switch_to_job_field; | ||
| 30 | struct format_field *switch_to_when_field; | ||
| 31 | |||
| 22 | gint task_release_id; | 32 | gint task_release_id; |
| 23 | struct format_field *release_pid_field; | 33 | struct format_field *release_pid_field; |
| 24 | struct format_field *release_job_field; | 34 | struct format_field *release_job_field; |
| @@ -37,7 +47,6 @@ struct rt_graph_info { | |||
| 37 | gint task_resume_id; | 47 | gint task_resume_id; |
| 38 | struct format_field *resume_pid_field; | 48 | struct format_field *resume_pid_field; |
| 39 | struct format_field *resume_when_field; | 49 | struct format_field *resume_when_field; |
| 40 | |||
| 41 | }; | 50 | }; |
| 42 | 51 | ||
| 43 | /* Event parsers */ | 52 | /* Event parsers */ |
| @@ -45,6 +54,12 @@ int rt_graph_check_task_param(struct rt_graph_info *rtinfo, struct pevent *peven | |||
| 45 | struct record *record, gint *pid, | 54 | struct record *record, gint *pid, |
| 46 | unsigned long long *wcet, | 55 | unsigned long long *wcet, |
| 47 | unsigned long long *period); | 56 | unsigned long long *period); |
| 57 | int rt_graph_check_task_switch_to(struct rt_graph_info *rtinfo, struct pevent *pevent, | ||
| 58 | struct record *record, gint *pid, gint *job, | ||
| 59 | unsigned long long *when); | ||
| 60 | int rt_graph_check_task_switch_away(struct rt_graph_info *rtinfo, struct pevent *pevent, | ||
| 61 | struct record *record, gint *pid, gint *job, | ||
| 62 | unsigned long long *when); | ||
| 48 | int rt_graph_check_task_release(struct rt_graph_info *rtinfo, struct pevent *pevent, | 63 | int rt_graph_check_task_release(struct rt_graph_info *rtinfo, struct pevent *pevent, |
| 49 | struct record *record, gint *pid, gint *job, | 64 | struct record *record, gint *pid, gint *job, |
| 50 | unsigned long long *release, | 65 | unsigned long long *release, |
diff --git a/rt-plot-task.c b/rt-plot-task.c index d63c872..d1af3d6 100644 --- a/rt-plot-task.c +++ b/rt-plot-task.c | |||
| @@ -1,13 +1,290 @@ | |||
| 1 | #include "trace-graph.h" | 1 | #include "trace-graph.h" |
| 2 | 2 | ||
| 3 | #define LLABEL 30 | ||
| 4 | |||
| 5 | /* Ok to do it this way as long as it remains single threaded */ | ||
| 6 | static void update_job(struct rt_task_info *rtt_info, int job) | ||
| 7 | { | ||
| 8 | if (job < rtt_info->last_job) { | ||
| 9 | die("Inconsistent job state for %d:%d -> %d\n", | ||
| 10 | rtt_info->base.pid, rtt_info->last_job, job); | ||
| 11 | } | ||
| 12 | if (job > rtt_info->last_job) { | ||
| 13 | rtt_info->last_job = job; | ||
| 14 | snprintf(rtt_info->label, LLABEL, "%d:%d", | ||
| 15 | rtt_info->base.pid, rtt_info->last_job); | ||
| 16 | } | ||
| 17 | } | ||
| 18 | |||
| 19 | static inline void create_job_label(char *label, int pid, int job) | ||
| 20 | { | ||
| 21 | label = malloc_or_die(20); | ||
| 22 | snprintf(label, 20, "%d:%d", pid, job); | ||
| 23 | } | ||
| 24 | |||
| 25 | static int try_param(struct graph_info *ginfo, struct rt_task_info *rtt_info, | ||
| 26 | struct record *record, struct plot_info *info) | ||
| 27 | { | ||
| 28 | int pid, match, ret = 0; | ||
| 29 | unsigned long long wcet, period; | ||
| 30 | |||
| 31 | /* Only 1 param record per event */ | ||
| 32 | if (rtt_info->params_found) | ||
| 33 | goto out; | ||
| 34 | |||
| 35 | match = rt_graph_check_task_param(&ginfo->rtinfo, ginfo->pevent, | ||
| 36 | record, &pid, &wcet, &period); | ||
| 37 | if (match && pid == rtt_info->base.pid) { | ||
| 38 | rtt_info->wcet = wcet; | ||
| 39 | rtt_info->period = period; | ||
| 40 | rtt_info->params_found = TRUE; | ||
| 41 | update_job(rtt_info, 0); | ||
| 42 | ret = 1; | ||
| 43 | } | ||
| 44 | out: | ||
| 45 | return ret; | ||
| 46 | } | ||
| 47 | |||
| 48 | |||
| 49 | static int try_release(struct graph_info *ginfo, struct rt_task_info *rtt_info, | ||
| 50 | struct record *record, struct plot_info *info) | ||
| 51 | { | ||
| 52 | int pid, job, match, ret = 0; | ||
| 53 | unsigned long long release, deadline; | ||
| 54 | |||
| 55 | match = rt_graph_check_task_release(&ginfo->rtinfo, ginfo->pevent, | ||
| 56 | record, &pid, &job, | ||
| 57 | &release, &deadline); | ||
| 58 | if (match && pid == rtt_info->base.pid) { | ||
| 59 | info->release = TRUE; | ||
| 60 | info->rtime = release; | ||
| 61 | info->rlabel = rtt_info->label; | ||
| 62 | |||
| 63 | info->deadline = TRUE; | ||
| 64 | info->dtime = deadline; | ||
| 65 | info->dlabel = rtt_info->label; | ||
| 66 | |||
| 67 | update_job(rtt_info, job); | ||
| 68 | ret = 1; | ||
| 69 | } | ||
| 70 | return ret; | ||
| 71 | } | ||
| 72 | |||
| 73 | static int try_completion(struct graph_info *ginfo, | ||
| 74 | struct rt_task_info *rtt_info, | ||
| 75 | struct record *record, struct plot_info *info) | ||
| 76 | { | ||
| 77 | int pid, job, match, ret = 0; | ||
| 78 | unsigned long long when; | ||
| 79 | |||
| 80 | match = rt_graph_check_task_completion(&ginfo->rtinfo, ginfo->pevent, | ||
| 81 | record, &pid, &job, &when); | ||
| 82 | if (match && pid == rtt_info->base.pid) { | ||
| 83 | info->completion = TRUE; | ||
| 84 | info->ctime = when; | ||
| 85 | info->clabel = rtt_info->label; | ||
| 86 | update_job(rtt_info, job); | ||
| 87 | ret = 1; | ||
| 88 | } | ||
| 89 | return ret; | ||
| 90 | } | ||
| 91 | |||
| 92 | static int try_block(struct graph_info *ginfo, struct rt_task_info *rtt_info, | ||
| 93 | struct record *record, struct plot_info *info) | ||
| 94 | { | ||
| 95 | int pid, match, ret = 0; | ||
| 96 | unsigned long long when; | ||
| 97 | |||
| 98 | match = rt_graph_check_task_block(&ginfo->rtinfo, ginfo->pevent, | ||
| 99 | record, &pid, &when); | ||
| 100 | if (match && pid == rtt_info->base.pid) { | ||
| 101 | rtt_info->block_time = when; | ||
| 102 | ret = 1; | ||
| 103 | } | ||
| 104 | return ret; | ||
| 105 | } | ||
| 106 | |||
| 107 | static int try_resume(struct graph_info *ginfo, struct rt_task_info *rtt_info, | ||
| 108 | struct record *record, struct plot_info *info) | ||
| 109 | { | ||
| 110 | int pid, match, ret = 0; | ||
| 111 | unsigned long long when; | ||
| 112 | |||
| 113 | match = rt_graph_check_task_resume(&ginfo->rtinfo, ginfo->pevent, | ||
| 114 | record, &pid, &when); | ||
| 115 | if (match && pid == rtt_info->base.pid) { | ||
| 116 | rtt_info->block_time = when; | ||
| 117 | info->box = TRUE; | ||
| 118 | info->bcolor = 0x0; | ||
| 119 | info->bfill = TRUE; | ||
| 120 | info->bthin = TRUE; | ||
| 121 | info->bstart = rtt_info->block_time; | ||
| 122 | info->bend = when; | ||
| 123 | |||
| 124 | rtt_info->block_time = -1; | ||
| 125 | |||
| 126 | ret = 1; | ||
| 127 | } | ||
| 128 | return ret; | ||
| 129 | } | ||
| 130 | |||
| 131 | static int try_other(struct graph_info *ginfo, struct rt_task_info *rtt_info, | ||
| 132 | struct record *record, struct plot_info *info) | ||
| 133 | { | ||
| 134 | int pid, is_sched, is_wakeup, rec_pid, sched_pid, match, ret = 0; | ||
| 135 | struct task_plot_info *task_info = &rtt_info->base; | ||
| 136 | |||
| 137 | pid = task_info->pid; | ||
| 138 | match = record_matches_pid(ginfo, record, pid, &rec_pid, | ||
| 139 | &sched_pid, &is_sched, &is_wakeup); | ||
| 140 | if (match) { | ||
| 141 | info->line = TRUE; | ||
| 142 | info->lcolor = hash_pid(rec_pid); | ||
| 143 | info->ltime = record->ts; | ||
| 144 | ret = 1; | ||
| 145 | |||
| 146 | update_last_task_record(ginfo, task_info, record); | ||
| 147 | |||
| 148 | if (is_wakeup) { | ||
| 149 | /* Another task is running on this CPU now */ | ||
| 150 | info->ltime = hash_pid(rec_pid); | ||
| 151 | if (task_info->last_cpu == record->cpu) { | ||
| 152 | info->box = TRUE; | ||
| 153 | info->bcolor = hash_cpu(task_info->last_cpu); | ||
| 154 | info->bstart = task_info->last_time; | ||
| 155 | info->bend = record->ts; | ||
| 156 | task_info->last_cpu = -1; | ||
| 157 | } | ||
| 158 | goto out; | ||
| 159 | } | ||
| 160 | |||
| 161 | if (task_info->last_cpu != record->cpu) { | ||
| 162 | /* Switched cpus */ | ||
| 163 | if (task_info->last_cpu >= 0) { | ||
| 164 | info->box = TRUE; | ||
| 165 | info->bcolor = hash_cpu(task_info->last_cpu); | ||
| 166 | info->bstart = task_info->last_time; | ||
| 167 | info->bend = record->ts; | ||
| 168 | } | ||
| 169 | task_info->last_time = record->ts; | ||
| 170 | } | ||
| 171 | |||
| 172 | task_info->last_cpu = record->cpu; | ||
| 173 | if (is_sched) { | ||
| 174 | if (rec_pid != pid) { | ||
| 175 | /* Scheduled in */ | ||
| 176 | task_info->last_cpu = record->cpu; | ||
| 177 | task_info->last_time = record->ts; | ||
| 178 | } else if (!info->box) { | ||
| 179 | /* Scheduled out */ | ||
| 180 | info->box = TRUE; | ||
| 181 | info->bcolor = hash_cpu(task_info->last_cpu); | ||
| 182 | info->bstart = task_info->last_time; | ||
| 183 | info->bend = record->ts; | ||
| 184 | task_info->last_cpu = -1; | ||
| 185 | } | ||
| 186 | } | ||
| 187 | } | ||
| 188 | out: | ||
| 189 | if (info->box) { | ||
| 190 | info->blabel = rtt_info->label; | ||
| 191 | } | ||
| 192 | return ret; | ||
| 193 | } | ||
| 194 | |||
| 195 | int rt_task_plot_event(struct graph_info *ginfo, struct graph_plot *plot, | ||
| 196 | struct record *record, struct plot_info *info) | ||
| 197 | { | ||
| 198 | struct rt_task_info *rtt_info = plot->private; | ||
| 199 | struct task_plot_info *task_info = &rtt_info->base; | ||
| 200 | int match, cpu; | ||
| 201 | |||
| 202 | /* No more records, finish what we started */ | ||
| 203 | if (!record) { | ||
| 204 | update_last_task_record(ginfo, task_info, record); | ||
| 205 | if (task_info->last_cpu >= 0) { | ||
| 206 | info->box = TRUE; | ||
| 207 | info->bstart = task_info->last_time; | ||
| 208 | info->bend = ginfo->view_end_time; | ||
| 209 | info->bcolor = hash_cpu(task_info->last_cpu); | ||
| 210 | } | ||
| 211 | for (cpu = 0; cpu < ginfo->cpus; cpu++) { | ||
| 212 | free_record(task_info->last_records[cpu]); | ||
| 213 | task_info->last_records[cpu] = NULL; | ||
| 214 | } | ||
| 215 | return 0; | ||
| 216 | } | ||
| 217 | |||
| 218 | match = try_param(ginfo, rtt_info, record, info) || | ||
| 219 | try_release(ginfo, rtt_info, record, info) || | ||
| 220 | try_completion(ginfo, rtt_info, record, info) || | ||
| 221 | try_block(ginfo, rtt_info, record, info) || | ||
| 222 | try_resume(ginfo, rtt_info, record, info) || | ||
| 223 | try_other(ginfo, rtt_info, record, info); | ||
| 224 | |||
| 225 | /* This record is neither on our CPU nor related to us, useless */ | ||
| 226 | if (!match && record->cpu != task_info->last_cpu) { | ||
| 227 | if (!task_info->last_records[record->cpu]) { | ||
| 228 | task_info->last_records[record->cpu] = record; | ||
| 229 | tracecmd_record_ref(record); | ||
| 230 | } | ||
| 231 | return 0; | ||
| 232 | } | ||
| 233 | |||
| 234 | if (!match) { | ||
| 235 | cpu = record->cpu; | ||
| 236 | /* We need some record, use this if none exist */ | ||
| 237 | if (!task_info->last_records[cpu]) { | ||
| 238 | free_record(task_info->last_records[cpu]); | ||
| 239 | task_info->last_records[cpu] = record; | ||
| 240 | } | ||
| 241 | |||
| 242 | /* We were on a CPU, now scheduled out */ | ||
| 243 | if (task_info->last_cpu >= 0) { | ||
| 244 | info->box = TRUE; | ||
| 245 | info->bcolor = hash_cpu(task_info->last_cpu); | ||
| 246 | info->bstart = task_info->last_time; | ||
| 247 | info->bend = record->ts; | ||
| 248 | task_info->last_cpu = -1; | ||
| 249 | } | ||
| 250 | } else { | ||
| 251 | update_last_task_record(ginfo, task_info, record); | ||
| 252 | } | ||
| 253 | out: | ||
| 254 | return 1; | ||
| 255 | } | ||
| 256 | |||
| 257 | void rt_task_plot_start(struct graph_info *ginfo, struct graph_plot *plot, | ||
| 258 | unsigned long long time) | ||
| 259 | { | ||
| 260 | struct rt_task_info *rtt_info = plot->private; | ||
| 261 | |||
| 262 | task_plot_start(ginfo, plot, time); | ||
| 263 | |||
| 264 | rtt_info->wcet = 0ULL; | ||
| 265 | rtt_info->period = 0ULL; | ||
| 266 | rtt_info->block_time = 0ULL; | ||
| 267 | rtt_info->last_job = -1; | ||
| 268 | rtt_info->params_found = FALSE; | ||
| 269 | update_job(rtt_info, 0); | ||
| 270 | } | ||
| 271 | |||
| 272 | void rt_task_plot_destroy(struct graph_info *ginfo, struct graph_plot *plot) | ||
| 273 | { | ||
| 274 | struct rt_task_info *rtt_info = plot->private; | ||
| 275 | free(rtt_info->label); | ||
| 276 | task_plot_destroy(ginfo, plot); | ||
| 277 | } | ||
| 278 | |||
| 3 | static const struct plot_callbacks rt_task_cb = { | 279 | static const struct plot_callbacks rt_task_cb = { |
| 280 | .plot_event = rt_task_plot_event, | ||
| 281 | .start = rt_task_plot_start, | ||
| 282 | .destroy = rt_task_plot_destroy, | ||
| 283 | |||
| 4 | .match_time = task_plot_match_time, | 284 | .match_time = task_plot_match_time, |
| 5 | .plot_event = task_plot_event, | ||
| 6 | .start = task_plot_start, | ||
| 7 | .display_last_event = task_plot_display_last_event, | 285 | .display_last_event = task_plot_display_last_event, |
| 8 | .find_record = task_plot_find_record, | 286 | .find_record = task_plot_find_record, |
| 9 | .display_info = task_plot_display_info, | 287 | .display_info = task_plot_display_info, |
| 10 | .destroy = task_plot_destroy | ||
| 11 | }; | 288 | }; |
| 12 | 289 | ||
| 13 | void rt_plot_task_update_callback(gboolean accept, | 290 | void rt_plot_task_update_callback(gboolean accept, |
| @@ -27,7 +304,7 @@ void rt_plot_task_plotted(struct graph_info *ginfo, gint **plotted) | |||
| 27 | void rt_plot_task(struct graph_info *ginfo, int pid, int pos) | 304 | void rt_plot_task(struct graph_info *ginfo, int pid, int pos) |
| 28 | { | 305 | { |
| 29 | struct rt_graph_info *rtinfo = &ginfo->rtinfo; | 306 | struct rt_graph_info *rtinfo = &ginfo->rtinfo; |
| 30 | struct rt_task_info *rt_task; | 307 | struct rt_task_info *rtt_info; |
| 31 | struct graph_plot *plot; | 308 | struct graph_plot *plot; |
| 32 | const char *comm; | 309 | const char *comm; |
| 33 | char *label; | 310 | char *label; |
| @@ -36,9 +313,10 @@ void rt_plot_task(struct graph_info *ginfo, int pid, int pos) | |||
| 36 | if (!find_task_list(rtinfo->tasks, pid)) | 313 | if (!find_task_list(rtinfo->tasks, pid)) |
| 37 | die("Cannot create RT plot of non-RT task %d!\n", pid); | 314 | die("Cannot create RT plot of non-RT task %d!\n", pid); |
| 38 | 315 | ||
| 39 | rt_task = malloc_or_die(sizeof(*rt_task)); | 316 | rtt_info = malloc_or_die(sizeof(*rtt_info)); |
| 317 | rtt_info->label = malloc_or_die(LLABEL); | ||
| 40 | 318 | ||
| 41 | init_task_plot_info(ginfo, &rt_task->base, TASK_PLOT_RT, pid); | 319 | init_task_plot_info(ginfo, &rtt_info->base, TASK_PLOT_RT, pid); |
| 42 | 320 | ||
| 43 | comm = pevent_data_comm_from_pid(ginfo->pevent, pid); | 321 | comm = pevent_data_comm_from_pid(ginfo->pevent, pid); |
| 44 | len = strlen(comm) + 100; | 322 | len = strlen(comm) + 100; |
| @@ -46,9 +324,8 @@ void rt_plot_task(struct graph_info *ginfo, int pid, int pos) | |||
| 46 | snprintf(label, len, "*%s-%d", comm, pid); | 324 | snprintf(label, len, "*%s-%d", comm, pid); |
| 47 | 325 | ||
| 48 | plot = trace_graph_plot_insert(ginfo, pos, label, PLOT_TYPE_TASK, | 326 | plot = trace_graph_plot_insert(ginfo, pos, label, PLOT_TYPE_TASK, |
| 49 | &rt_task_cb, rt_task); | 327 | &rt_task_cb, rtt_info); |
| 50 | free(label); | 328 | free(label); |
| 51 | 329 | ||
| 52 | trace_graph_plot_add_all_recs(ginfo, plot); | 330 | trace_graph_plot_add_all_recs(ginfo, plot); |
| 53 | } | 331 | } |
| 54 | |||
diff --git a/rt-plot-task.h b/rt-plot-task.h index 4cb957a..a11d347 100644 --- a/rt-plot-task.h +++ b/rt-plot-task.h | |||
| @@ -9,14 +9,12 @@ struct rt_task_info { | |||
| 9 | unsigned long long period; | 9 | unsigned long long period; |
| 10 | unsigned long long block_time; | 10 | unsigned long long block_time; |
| 11 | int last_job; | 11 | int last_job; |
| 12 | gboolean params_found; | ||
| 13 | char *label; | ||
| 12 | }; | 14 | }; |
| 13 | 15 | ||
| 14 | void rt_plot_task(struct graph_info *ginfo, int pid, int pos); | 16 | void rt_plot_task(struct graph_info *ginfo, int pid, int pos); |
| 15 | void rt_plot_task_plotted(struct graph_info *ginfo, | 17 | void rt_plot_task_plotted(struct graph_info *ginfo, gint **plotted); |
| 16 | gint **plotted); | 18 | void rt_plot_task_update_callback(gboolean accept, gint *selected, |
| 17 | void rt_plot_task_update_callback(gboolean accept, | 19 | gint *non_select, gpointer data); |
| 18 | gint *selected, | ||
| 19 | gint *non_select, | ||
| 20 | gpointer data); | ||
| 21 | |||
| 22 | #endif | 20 | #endif |
diff --git a/trace-graph.h b/trace-graph.h index a0c5c54..ee57be6 100644 --- a/trace-graph.h +++ b/trace-graph.h | |||
| @@ -49,11 +49,26 @@ struct plot_info { | |||
| 49 | gboolean line; | 49 | gboolean line; |
| 50 | int lcolor; | 50 | int lcolor; |
| 51 | unsigned long long ltime; | 51 | unsigned long long ltime; |
| 52 | |||
| 52 | gboolean box; | 53 | gboolean box; |
| 53 | int bcolor; | 54 | int bcolor; |
| 54 | unsigned long long bstart; | 55 | unsigned long long bstart; |
| 55 | unsigned long long bend; | 56 | unsigned long long bend; |
| 56 | gboolean bfill; | 57 | gboolean bfill; |
| 58 | gboolean bthin; | ||
| 59 | char *blabel; | ||
| 60 | |||
| 61 | gboolean release; | ||
| 62 | unsigned long long rtime; | ||
| 63 | char *rlabel; | ||
| 64 | |||
| 65 | gboolean deadline; | ||
| 66 | unsigned long long dtime; | ||
| 67 | char *dlabel; | ||
| 68 | |||
| 69 | gboolean completion; | ||
| 70 | unsigned long long ctime; | ||
| 71 | char *clabel; | ||
| 57 | }; | 72 | }; |
| 58 | 73 | ||
| 59 | /* | 74 | /* |
diff --git a/trace-plot-cpu.c b/trace-plot-cpu.c index c7a37f5..00f07af 100644 --- a/trace-plot-cpu.c +++ b/trace-plot-cpu.c | |||
| @@ -80,12 +80,8 @@ static int filter_record(struct graph_info *ginfo, | |||
| 80 | int wake_pid; | 80 | int wake_pid; |
| 81 | int filter; | 81 | int filter; |
| 82 | gint rpid; | 82 | gint rpid; |
| 83 | gint job; | ||
| 84 | unsigned long long release; | ||
| 85 | unsigned long long deadline; | ||
| 86 | unsigned long long period; | 83 | unsigned long long period; |
| 87 | unsigned long long wcet; | 84 | unsigned long long wcet; |
| 88 | unsigned long long when; | ||
| 89 | 85 | ||
| 90 | *orig_pid = pevent_data_pid(ginfo->pevent, record); | 86 | *orig_pid = pevent_data_pid(ginfo->pevent, record); |
| 91 | 87 | ||
| @@ -95,14 +91,6 @@ static int filter_record(struct graph_info *ginfo, | |||
| 95 | /* Load real-time records */ | 91 | /* Load real-time records */ |
| 96 | rt_graph_check_task_param(&ginfo->rtinfo, ginfo->pevent, record, | 92 | rt_graph_check_task_param(&ginfo->rtinfo, ginfo->pevent, record, |
| 97 | &rpid, &wcet, &period); | 93 | &rpid, &wcet, &period); |
| 98 | rt_graph_check_task_release(&ginfo->rtinfo, ginfo->pevent, record, | ||
| 99 | &rpid, &job, &release, &deadline); | ||
| 100 | rt_graph_check_task_completion(&ginfo->rtinfo, ginfo->pevent, record, | ||
| 101 | &rpid, &job, &when); | ||
| 102 | rt_graph_check_task_block(&ginfo->rtinfo, ginfo->pevent, record, | ||
| 103 | &rpid, &when); | ||
| 104 | rt_graph_check_task_resume(&ginfo->rtinfo, ginfo->pevent, record, | ||
| 105 | &rpid, &when); | ||
| 106 | 94 | ||
| 107 | if (trace_graph_check_sched_switch(ginfo, record, sched_pid, &comm)) { | 95 | if (trace_graph_check_sched_switch(ginfo, record, sched_pid, &comm)) { |
| 108 | is_sched_switch = TRUE; | 96 | is_sched_switch = TRUE; |
diff --git a/trace-plot-task.c b/trace-plot-task.c index e4ac13a..068fd91 100644 --- a/trace-plot-task.c +++ b/trace-plot-task.c | |||
| @@ -40,10 +40,10 @@ gboolean is_running(struct graph_info *ginfo, struct record *record) | |||
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | gboolean record_matches_pid(struct graph_info *ginfo, | 42 | gboolean record_matches_pid(struct graph_info *ginfo, |
| 43 | struct record *record, int match_pid, | 43 | struct record *record, int match_pid, |
| 44 | int *pid, int *sched_pid, | 44 | int *pid, int *sched_pid, |
| 45 | gboolean *is_sched, | 45 | gboolean *is_sched, |
| 46 | gboolean *wakeup) | 46 | gboolean *wakeup) |
| 47 | { | 47 | { |
| 48 | const char *comm; | 48 | const char *comm; |
| 49 | 49 | ||
| @@ -208,9 +208,9 @@ find_record(struct graph_info *ginfo, gint pid, guint64 time) | |||
| 208 | } | 208 | } |
| 209 | 209 | ||
| 210 | int task_plot_display_last_event(struct graph_info *ginfo, | 210 | int task_plot_display_last_event(struct graph_info *ginfo, |
| 211 | struct graph_plot *plot, | 211 | struct graph_plot *plot, |
| 212 | struct trace_seq *s, | 212 | struct trace_seq *s, |
| 213 | unsigned long long time) | 213 | unsigned long long time) |
| 214 | { | 214 | { |
| 215 | struct task_plot_info *task_info = plot->private; | 215 | struct task_plot_info *task_info = plot->private; |
| 216 | struct event_format *event; | 216 | struct event_format *event; |
| @@ -294,8 +294,8 @@ void task_plot_start(struct graph_info *ginfo, struct graph_plot *plot, | |||
| 294 | } | 294 | } |
| 295 | 295 | ||
| 296 | void update_last_task_record(struct graph_info *ginfo, | 296 | void update_last_task_record(struct graph_info *ginfo, |
| 297 | struct task_plot_info *task_info, | 297 | struct task_plot_info *task_info, |
| 298 | struct record *record) | 298 | struct record *record) |
| 299 | { | 299 | { |
| 300 | struct tracecmd_input *handle = ginfo->handle; | 300 | struct tracecmd_input *handle = ginfo->handle; |
| 301 | struct record *trecord, *t2record; | 301 | struct record *trecord, *t2record; |
| @@ -375,9 +375,9 @@ void update_last_task_record(struct graph_info *ginfo, | |||
| 375 | } | 375 | } |
| 376 | 376 | ||
| 377 | int task_plot_event(struct graph_info *ginfo, | 377 | int task_plot_event(struct graph_info *ginfo, |
| 378 | struct graph_plot *plot, | 378 | struct graph_plot *plot, |
| 379 | struct record *record, | 379 | struct record *record, |
| 380 | struct plot_info *info) | 380 | struct plot_info *info) |
| 381 | { | 381 | { |
| 382 | struct task_plot_info *task_info = plot->private; | 382 | struct task_plot_info *task_info = plot->private; |
| 383 | gboolean match; | 383 | gboolean match; |
| @@ -409,7 +409,6 @@ int task_plot_event(struct graph_info *ginfo, | |||
| 409 | match = record_matches_pid(ginfo, record, pid, &rec_pid, | 409 | match = record_matches_pid(ginfo, record, pid, &rec_pid, |
| 410 | &sched_pid, &is_sched, &is_wakeup); | 410 | &sched_pid, &is_sched, &is_wakeup); |
| 411 | 411 | ||
| 412 | |||
| 413 | if (!match && record->cpu != task_info->last_cpu) { | 412 | if (!match && record->cpu != task_info->last_cpu) { |
| 414 | if (!task_info->last_records[record->cpu]) { | 413 | if (!task_info->last_records[record->cpu]) { |
| 415 | task_info->last_records[record->cpu] = record; | 414 | task_info->last_records[record->cpu] = record; |
diff --git a/trace-plot-task.h b/trace-plot-task.h index 3232339..78ff68f 100644 --- a/trace-plot-task.h +++ b/trace-plot-task.h | |||
| @@ -41,9 +41,9 @@ struct task_plot_info { | |||
| 41 | 41 | ||
| 42 | /* Querying records */ | 42 | /* Querying records */ |
| 43 | gboolean is_running(struct graph_info *ginfo, struct record *record); | 43 | gboolean is_running(struct graph_info *ginfo, struct record *record); |
| 44 | gboolean record_matches_pid(struct graph_info *ginfo, struct record *record, | 44 | /* gboolean record_matches_pid(struct graph_info *ginfo, struct record *record, */ |
| 45 | int match_pid, int *pid, int *sched_pid, | 45 | /* int match_pid, int *pid, int *sched_pid, */ |
| 46 | gboolean *is_sched, gboolean *wakeup); | 46 | /* gboolean *is_sched, gboolean *wakeup); */ |
| 47 | 47 | ||
| 48 | /* State maintenance */ | 48 | /* State maintenance */ |
| 49 | void update_last_task_record(struct graph_info *ginfo, struct task_plot_info *task_info, | 49 | void update_last_task_record(struct graph_info *ginfo, struct task_plot_info *task_info, |
| @@ -58,6 +58,9 @@ struct record *find_previous_record(struct graph_info *ginfo, | |||
| 58 | int pid, int cpu); | 58 | int pid, int cpu); |
| 59 | struct record *get_display_record(struct graph_info *ginfo, int pid, | 59 | struct record *get_display_record(struct graph_info *ginfo, int pid, |
| 60 | unsigned long long time); | 60 | unsigned long long time); |
| 61 | gboolean record_matches_pid(struct graph_info *ginfo, struct record *record, | ||
| 62 | int match_pid, int *pid, int *sched_pid, | ||
| 63 | gboolean *is_sched, gboolean *wakeup); | ||
| 61 | 64 | ||
| 62 | /* Seeking in data file */ | 65 | /* Seeking in data file */ |
| 63 | void set_cpu_to_time(int cpu, struct graph_info *ginfo, unsigned long long time); | 66 | void set_cpu_to_time(int cpu, struct graph_info *ginfo, unsigned long long time); |
