diff options
Diffstat (limited to 'trace-plot-task.c')
| -rw-r--r-- | trace-plot-task.c | 97 |
1 files changed, 42 insertions, 55 deletions
diff --git a/trace-plot-task.c b/trace-plot-task.c index 6b35586..45a0a32 100644 --- a/trace-plot-task.c +++ b/trace-plot-task.c | |||
| @@ -256,16 +256,11 @@ static void task_plot_start(struct graph_info *ginfo, struct graph_plot *plot, | |||
| 256 | 256 | ||
| 257 | static int task_plot_event(struct graph_info *ginfo, | 257 | static int task_plot_event(struct graph_info *ginfo, |
| 258 | struct graph_plot *plot, | 258 | struct graph_plot *plot, |
| 259 | gboolean *line, int *lcolor, | 259 | struct record *record, |
| 260 | unsigned long long *ltime, | 260 | struct plot_info *info) |
| 261 | gboolean *box, int *bcolor, | ||
| 262 | unsigned long long *bstart, | ||
| 263 | unsigned long long *bend) | ||
| 264 | { | 261 | { |
| 265 | struct task_plot_info *task_info = plot->private; | 262 | struct task_plot_info *task_info = plot->private; |
| 266 | struct record *record = NULL; | ||
| 267 | gboolean match; | 263 | gboolean match; |
| 268 | int next_cpu; | ||
| 269 | int sched_pid; | 264 | int sched_pid; |
| 270 | int rec_pid; | 265 | int rec_pid; |
| 271 | int is_wakeup; | 266 | int is_wakeup; |
| @@ -274,91 +269,83 @@ static int task_plot_event(struct graph_info *ginfo, | |||
| 274 | 269 | ||
| 275 | pid = task_info->pid; | 270 | pid = task_info->pid; |
| 276 | 271 | ||
| 277 | do { | 272 | if (!record) { |
| 278 | free_record(record); | 273 | /* no more records, finish a box if one was started */ |
| 279 | 274 | if (task_info->last_cpu >= 0) { | |
| 280 | record = tracecmd_read_next_data(ginfo->handle, &next_cpu); | 275 | info->box = TRUE; |
| 281 | 276 | info->bstart = task_info->last_time; | |
| 282 | if (!record) { | 277 | info->bend = ginfo->view_end_time; |
| 283 | /* no more records, finish a box if one was started */ | 278 | info->bcolor = hash_cpu(task_info->last_cpu); |
| 284 | if (task_info->last_cpu >= 0) { | ||
| 285 | *box = TRUE; | ||
| 286 | *bstart = task_info->last_time; | ||
| 287 | *bend = ginfo->view_end_time; | ||
| 288 | *bcolor = hash_cpu(task_info->last_cpu); | ||
| 289 | } | ||
| 290 | return 0; | ||
| 291 | } | 279 | } |
| 280 | return 0; | ||
| 281 | } | ||
| 292 | 282 | ||
| 293 | match = record_matches_pid(ginfo, record, pid, &rec_pid, | 283 | match = record_matches_pid(ginfo, record, pid, &rec_pid, |
| 294 | &sched_pid, &is_sched, &is_wakeup); | 284 | &sched_pid, &is_sched, &is_wakeup); |
| 295 | 285 | ||
| 296 | } while (!match && next_cpu != task_info->last_cpu); | 286 | if (!match && record->cpu != task_info->last_cpu) |
| 287 | return 0; | ||
| 297 | 288 | ||
| 298 | if (match) { | 289 | if (match) { |
| 299 | *line = TRUE; | 290 | info->line = TRUE; |
| 300 | *lcolor = hash_pid(rec_pid); | 291 | info->lcolor = hash_pid(rec_pid); |
| 301 | *ltime = record->ts; | 292 | info->ltime = record->ts; |
| 302 | 293 | ||
| 303 | if (is_wakeup) { | 294 | if (is_wakeup) { |
| 304 | /* Wake up but not task */ | 295 | /* Wake up but not task */ |
| 305 | *ltime = hash_pid(rec_pid); | 296 | info->ltime = hash_pid(rec_pid); |
| 306 | free_record(record); | ||
| 307 | 297 | ||
| 308 | /* Another task ? */ | 298 | /* Another task ? */ |
| 309 | if (task_info->last_cpu == next_cpu) { | 299 | if (task_info->last_cpu == record->cpu) { |
| 310 | *box = TRUE; | 300 | info->box = TRUE; |
| 311 | *bcolor = hash_cpu(task_info->last_cpu); | 301 | info->bcolor = hash_cpu(task_info->last_cpu); |
| 312 | *bstart = task_info->last_time; | 302 | info->bstart = task_info->last_time; |
| 313 | *bend = record->ts; | 303 | info->bend = record->ts; |
| 314 | task_info->last_cpu = -1; | 304 | task_info->last_cpu = -1; |
| 315 | } | 305 | } |
| 316 | 306 | ||
| 317 | return 1; | 307 | return 1; |
| 318 | } | 308 | } |
| 319 | 309 | ||
| 320 | if (task_info->last_cpu != next_cpu) { | 310 | if (task_info->last_cpu != record->cpu) { |
| 321 | if (task_info->last_cpu >= 0) { | 311 | if (task_info->last_cpu >= 0) { |
| 322 | /* Switched CPUs */ | 312 | /* Switched CPUs */ |
| 323 | *box = TRUE; | 313 | info->box = TRUE; |
| 324 | *bcolor = hash_cpu(task_info->last_cpu); | 314 | info->bcolor = hash_cpu(task_info->last_cpu); |
| 325 | *bstart = task_info->last_time; | 315 | info->bstart = task_info->last_time; |
| 326 | *bend = record->ts; | 316 | info->bend = record->ts; |
| 327 | } | 317 | } |
| 328 | task_info->last_time = record->ts; | 318 | task_info->last_time = record->ts; |
| 329 | } | 319 | } |
| 330 | 320 | ||
| 331 | task_info->last_cpu = next_cpu; | 321 | task_info->last_cpu = record->cpu; |
| 332 | if (is_sched) { | 322 | if (is_sched) { |
| 333 | if (rec_pid != pid) { | 323 | if (rec_pid != pid) { |
| 334 | /* Just got scheduled in */ | 324 | /* Just got scheduled in */ |
| 335 | task_info->last_cpu = next_cpu; | 325 | task_info->last_cpu = record->cpu; |
| 336 | task_info->last_time = record->ts; | 326 | task_info->last_time = record->ts; |
| 337 | } else if (!*box) { | 327 | } else if (!info->box) { |
| 338 | /* just got scheduled out */ | 328 | /* just got scheduled out */ |
| 339 | *box = TRUE; | 329 | info->box = TRUE; |
| 340 | *bcolor = hash_cpu(task_info->last_cpu); | 330 | info->bcolor = hash_cpu(task_info->last_cpu); |
| 341 | *bstart = task_info->last_time; | 331 | info->bstart = task_info->last_time; |
| 342 | *bend = record->ts; | 332 | info->bend = record->ts; |
| 343 | task_info->last_cpu = -1; | 333 | task_info->last_cpu = -1; |
| 344 | } | 334 | } |
| 345 | } | 335 | } |
| 346 | 336 | ||
| 347 | free_record(record); | ||
| 348 | return 1; | 337 | return 1; |
| 349 | } | 338 | } |
| 350 | 339 | ||
| 351 | /* not a match, and on the last CPU, scheduled out? */ | 340 | /* not a match, and on the last CPU, scheduled out? */ |
| 352 | if (task_info->last_cpu >= 0) { | 341 | if (task_info->last_cpu >= 0) { |
| 353 | *box = TRUE; | 342 | info->box = TRUE; |
| 354 | *bcolor = hash_cpu(task_info->last_cpu); | 343 | info->bcolor = hash_cpu(task_info->last_cpu); |
| 355 | *bstart = task_info->last_time; | 344 | info->bstart = task_info->last_time; |
| 356 | *bend = record->ts; | 345 | info->bend = record->ts; |
| 357 | task_info->last_cpu = -1; | 346 | task_info->last_cpu = -1; |
| 358 | } | 347 | } |
| 359 | 348 | ||
| 360 | free_record(record); | ||
| 361 | |||
| 362 | return 1; | 349 | return 1; |
| 363 | } | 350 | } |
| 364 | 351 | ||
| @@ -536,7 +523,7 @@ void task_plot_destroy(struct graph_info *ginfo, struct graph_plot *plot) | |||
| 536 | { | 523 | { |
| 537 | struct task_plot_info *task_info = plot->private; | 524 | struct task_plot_info *task_info = plot->private; |
| 538 | 525 | ||
| 539 | trace_graph_plot_remove_task(ginfo, plot, task_info->pid); | 526 | trace_graph_plot_remove_all_recs(ginfo, plot); |
| 540 | 527 | ||
| 541 | free(task_info); | 528 | free(task_info); |
| 542 | } | 529 | } |
| @@ -587,5 +574,5 @@ void graph_plot_task(struct graph_info *ginfo, int pid) | |||
| 587 | snprintf(label, 100, "TASK %d", pid); | 574 | snprintf(label, 100, "TASK %d", pid); |
| 588 | plot = trace_graph_plot_append(ginfo, label, &task_plot_cb, task_info); | 575 | plot = trace_graph_plot_append(ginfo, label, &task_plot_cb, task_info); |
| 589 | 576 | ||
| 590 | trace_graph_plot_add_task(ginfo, plot, pid); | 577 | trace_graph_plot_add_all_recs(ginfo, plot); |
| 591 | } | 578 | } |
