aboutsummaryrefslogtreecommitdiffstats
path: root/trace-plot-cpu.c
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-02-08 16:15:46 -0500
committerSteven Rostedt <rostedt@goodmis.org>2010-02-10 10:58:45 -0500
commit73dcd1f86fceb6343958629800139f60c3ded267 (patch)
tree9e921bcc1781001132ef466ef719a3601fc9af73 /trace-plot-cpu.c
parentb391d4e5acbf1f243b316f6f024137fa614a0d2d (diff)
trace-graph: Move display event info into plot structures
Move the code to show what to display into the plot sturctures. Have the plot structure determine what to show. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'trace-plot-cpu.c')
-rw-r--r--trace-plot-cpu.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/trace-plot-cpu.c b/trace-plot-cpu.c
index 5d37950..6918ae4 100644
--- a/trace-plot-cpu.c
+++ b/trace-plot-cpu.c
@@ -18,6 +18,13 @@ static gint hash_pid(gint val)
18 return trace_hash(val); 18 return trace_hash(val);
19} 19}
20 20
21static void convert_nano(unsigned long long time, unsigned long *sec,
22 unsigned long *usec)
23{
24 *sec = time / 1000000000ULL;
25 *usec = (time / 1000) % 1000000;
26}
27
21static int cpu_plot_match_time(struct graph_info *ginfo, struct graph_plot *plot, 28static int cpu_plot_match_time(struct graph_info *ginfo, struct graph_plot *plot,
22 unsigned long long time) 29 unsigned long long time)
23{ 30{
@@ -312,12 +319,90 @@ cpu_plot_find_record(struct graph_info *ginfo, struct graph_plot *plot,
312 return find_record_on_cpu(ginfo, cpu, time); 319 return find_record_on_cpu(ginfo, cpu, time);
313} 320}
314 321
322int cpu_plot_display_info(struct graph_info *ginfo,
323 struct graph_plot *plot,
324 struct trace_seq *s,
325 unsigned long long time)
326{
327 struct cpu_plot_info *cpu_info = plot->private;
328 struct event_format *event;
329 struct record *record;
330 struct pevent *pevent;
331 unsigned long sec, usec;
332 const char *comm;
333 int type;
334 int pid;
335 int cpu;
336 int ret = 0;
337
338 cpu = cpu_info->cpu;
339
340 record = find_record_on_cpu(ginfo, cpu, time);
341
342 if (!record) {
343 /* try last record */
344 record = tracecmd_read_cpu_last(ginfo->handle, cpu);
345 if (record && record->ts < time) {
346 if (!trace_graph_check_sched_switch(ginfo, record, &pid, &comm)) {
347 pid = pevent_data_pid(ginfo->pevent, record);
348 comm = pevent_data_comm_from_pid(ginfo->pevent, pid);
349 }
350
351 trace_seq_printf(s, "%lu.%06lu", sec, usec);
352 if (pid)
353 trace_seq_printf(s, " %s-%d", comm, pid);
354 else
355 trace_seq_puts(s, " <idle>");
356 ret = 1;
357 }
358 free_record(record);
359 return ret;
360 }
361
362 pevent = ginfo->pevent;
363
364 pid = pevent_data_pid(ginfo->pevent, record);
365 comm = pevent_data_comm_from_pid(ginfo->pevent, pid);
366
367 if (record->ts > time - 2/ginfo->resolution &&
368 record->ts < time + 2/ginfo->resolution) {
369
370 convert_nano(record->ts, &sec, &usec);
371
372 type = pevent_data_type(pevent, record);
373 event = pevent_data_event_from_type(pevent, type);
374 if (event) {
375 trace_seq_puts(s, event->name);
376 trace_seq_putc(s, '\n');
377 pevent_data_lat_fmt(pevent, s, record);
378 trace_seq_putc(s, '\n');
379 pevent_event_info(s, event, record);
380 trace_seq_putc(s, '\n');
381 } else
382 trace_seq_printf(s, "UNKNOW EVENT %d\n", type);
383 } else {
384 if (record->ts < time)
385 trace_graph_check_sched_switch(ginfo, record, &pid, &comm);
386 }
387
388 trace_seq_printf(s, "%lu.%06lu", sec, usec);
389 if (pid)
390 trace_seq_printf(s, " %s-%d", comm, pid);
391 else
392 trace_seq_puts(s, " <idle>");
393
394 free_record(record);
395
396 return 1;
397}
398
315static const struct plot_callbacks cpu_plot_cb = { 399static const struct plot_callbacks cpu_plot_cb = {
316 .match_time = cpu_plot_match_time, 400 .match_time = cpu_plot_match_time,
317 .plot_event = cpu_plot_event, 401 .plot_event = cpu_plot_event,
318 .start = cpu_plot_start, 402 .start = cpu_plot_start,
319 .display_last_event = cpu_plot_display_last_event, 403 .display_last_event = cpu_plot_display_last_event,
320 .find_record = cpu_plot_find_record, 404 .find_record = cpu_plot_find_record,
405 .display_info = cpu_plot_display_info,
321}; 406};
322 407
323void graph_plot_init_cpus(struct graph_info *ginfo, int cpus) 408void graph_plot_init_cpus(struct graph_info *ginfo, int cpus)