aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel-shark.c2
-rw-r--r--rt-plot-cpu.c123
-rw-r--r--rt-plot-task.c22
-rw-r--r--rt-plot-task.h2
-rw-r--r--trace-plot-task.c3
5 files changed, 92 insertions, 60 deletions
diff --git a/kernel-shark.c b/kernel-shark.c
index ca1fcb8..dc5201c 100644
--- a/kernel-shark.c
+++ b/kernel-shark.c
@@ -1300,7 +1300,7 @@ plot_rt_tasks_clicked (gpointer data)
1300 1300
1301 rtg_info = &ginfo->rtg_info; 1301 rtg_info = &ginfo->rtg_info;
1302 tasks = task_list_pids(rtg_info->tasks); 1302 tasks = task_list_pids(rtg_info->tasks);
1303 rt_plot_task_plotted(ginfo, &selected); 1303 rt_plot_tasks_plotted(ginfo, &selected);
1304 1304
1305 trace_task_dialog(ginfo->handle, tasks, selected, 1305 trace_task_dialog(ginfo->handle, tasks, selected,
1306 rt_plot_task_update_callback, ginfo); 1306 rt_plot_task_update_callback, ginfo);
diff --git a/rt-plot-cpu.c b/rt-plot-cpu.c
index 82d03e6..7b201dc 100644
--- a/rt-plot-cpu.c
+++ b/rt-plot-cpu.c
@@ -12,6 +12,9 @@
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/*
16 * Return the next switch_away record after @time.
17 */
15static struct record* 18static struct record*
16next_sa_record(struct graph_info *ginfo, struct rt_cpu_info *rtc_info, 19next_sa_record(struct graph_info *ginfo, struct rt_cpu_info *rtc_info,
17 unsigned long long time, int *out_pid) 20 unsigned long long time, int *out_pid)
@@ -44,6 +47,9 @@ next_sa_record(struct graph_info *ginfo, struct rt_cpu_info *rtc_info,
44 return ret; 47 return ret;
45} 48}
46 49
50/*
51 * Return 1 if the name of @eid is displayed in the plot.
52 */
47static inline int 53static inline int
48is_displayed(struct graph_info *ginfo, int eid) 54is_displayed(struct graph_info *ginfo, int eid)
49{ 55{
@@ -79,19 +85,27 @@ __find_record(struct graph_info *ginfo, int cpu, unsigned long long time,
79 return record; 85 return record;
80} 86}
81 87
88/*
89 * Return the first record after @time on @cpu.
90 */
82static inline struct record* 91static inline struct record*
83find_record(struct graph_info *ginfo, int cpu, guint64 time) 92find_record(struct graph_info *ginfo, int cpu, guint64 time)
84{ 93{
85 return __find_record(ginfo, cpu, time, 0); 94 return __find_record(ginfo, cpu, time, 0);
86} 95}
87 96
97/*
98 * Return the first _displayed_ record after @time on @cpu.
99 */
88static inline struct record* 100static inline struct record*
89find_display_record(struct graph_info *ginfo, int cpu, guint64 time) 101find_display_record(struct graph_info *ginfo, int cpu, guint64 time)
90{ 102{
91 return __find_record(ginfo, cpu, time, 1); 103 return __find_record(ginfo, cpu, time, 1);
92} 104}
93 105
94 106/*
107 * Update fields in @rtc_info for the new @pid.
108 */
95static void update_pid(struct rt_cpu_info *rtc_info, int pid) 109static void update_pid(struct rt_cpu_info *rtc_info, int pid)
96{ 110{
97 rtc_info->fresh = FALSE; 111 rtc_info->fresh = FALSE;
@@ -101,6 +115,58 @@ static void update_pid(struct rt_cpu_info *rtc_info, int pid)
101 } 115 }
102} 116}
103 117
118/*
119 * Get information about the given @time.
120 * @out_pid: The running pid at @time
121 * @out_job: The running job at @time
122 * @out_record: The record at @time
123 *
124 * Return 1, @out_pid, and @out_job if the CPU is running at @time.
125 */
126static int get_time_info(struct graph_info *ginfo,
127 struct rt_cpu_info *rtc_info,
128 unsigned long long time,
129 int *out_pid, int *out_job,
130 struct record **out_record)
131{
132 struct record *record;
133 struct rt_graph_info *rtg_info = &ginfo->rtg_info;
134 unsigned long long dull, max_ts;
135 int cpu, is_running, pid, job;
136
137 cpu = rtc_info->cpu;
138 *out_pid = *out_job = is_running = 0;
139
140 record = find_record(ginfo, cpu, time);
141 *out_record = record;
142 if (!record)
143 goto out;
144
145 max_ts = time + SEARCH_PERIODS * rtg_info->max_period;
146 do {
147 if (get_rts(ginfo, record) > max_ts)
148 break;
149
150#define ARG rtg_info, ginfo->pevent, record, &pid, &job, &dull
151 if (rt_graph_check_switch_to(ARG)) {
152 /* Nothing is running */
153 goto out;
154 } else if (rt_graph_check_switch_away(ARG)) {
155 is_running = 1;
156 *out_pid = pid;
157 *out_job = job;
158 goto out;
159 }
160 if (*out_record != record)
161 free_record(record);
162#undef ARG
163 } while ((record = tracecmd_read_data(ginfo->handle, cpu)));
164 out:
165 if (*out_record != record)
166 free_record(record);
167 return is_running;
168}
169
104static int 170static int
105try_switch_away(struct graph_info *ginfo, struct rt_cpu_info *rtc_info, 171try_switch_away(struct graph_info *ginfo, struct rt_cpu_info *rtc_info,
106 struct record *record, struct plot_info *info) 172 struct record *record, struct plot_info *info)
@@ -179,7 +245,6 @@ try_sched_switch(struct graph_info *ginfo, struct rt_cpu_info *rtc_info,
179 info->box = TRUE; 245 info->box = TRUE;
180 info->bthin = TRUE; 246 info->bthin = TRUE;
181 info->bcolor = 0x0; 247 info->bcolor = 0x0;
182 /* info->blabel = rtc_info->label; */
183 info->bstart = rtc_info->reg_run_time; 248 info->bstart = rtc_info->reg_run_time;
184 info->bend = get_rts(ginfo, record); 249 info->bend = get_rts(ginfo, record);
185 } 250 }
@@ -274,7 +339,7 @@ static int rt_cpu_plot_event(struct graph_info *ginfo, struct graph_plot *plot,
274 339
275 if (!match) { 340 if (!match) {
276 /* Have to call checks to ensure ids are loaded. Otherwise, 341 /* Have to call checks to ensure ids are loaded. Otherwise,
277 * is_displayed will not work in any methods. 342 * is_displayed will not work here or in any other methods.
278 */ 343 */
279#define ARG rtg_info, ginfo->pevent, record, &pid 344#define ARG rtg_info, ginfo->pevent, record, &pid
280 rt_graph_check_task_release(ARG, &dint, &dull, &dull); 345 rt_graph_check_task_release(ARG, &dint, &dull, &dull);
@@ -325,7 +390,6 @@ rt_cpu_plot_display_last_event(struct graph_info *ginfo, struct graph_plot *plot
325 return 1; 390 return 1;
326} 391}
327 392
328
329struct record* 393struct record*
330rt_cpu_plot_find_record(struct graph_info *ginfo, struct graph_plot *plot, 394rt_cpu_plot_find_record(struct graph_info *ginfo, struct graph_plot *plot,
331 unsigned long long time) 395 unsigned long long time)
@@ -334,50 +398,6 @@ rt_cpu_plot_find_record(struct graph_info *ginfo, struct graph_plot *plot,
334 return find_record(ginfo, rtc_info->cpu, time); 398 return find_record(ginfo, rtc_info->cpu, time);
335} 399}
336 400
337static int get_time_info(struct graph_info *ginfo,
338 struct rt_cpu_info *rtc_info,
339 unsigned long long time,
340 int *out_pid, int *out_job,
341 struct record **out_record)
342{
343 struct record *record;
344 struct rt_graph_info *rtg_info = &ginfo->rtg_info;
345 unsigned long long dull, max_ts;
346 int cpu, is_running, pid, job;
347
348 cpu = rtc_info->cpu;
349 *out_pid = *out_job = is_running = 0;
350
351 record = find_record(ginfo, cpu, time);
352 *out_record = record;
353 if (!record)
354 goto out;
355
356 max_ts = time + SEARCH_PERIODS * rtg_info->max_period;
357 do {
358 if (get_rts(ginfo, record) > max_ts)
359 break;
360
361#define ARG rtg_info, ginfo->pevent, record, &pid, &job, &dull
362 if (rt_graph_check_switch_to(ARG)) {
363 /* Nothing is running */
364 goto out;
365 } else if (rt_graph_check_switch_away(ARG)) {
366 is_running = 1;
367 *out_pid = pid;
368 *out_job = job;
369 goto out;
370 }
371 if (*out_record != record)
372 free_record(record);
373#undef ARG
374 } while ((record = tracecmd_read_data(ginfo->handle, cpu)));
375 out:
376 if (*out_record != record)
377 free_record(record);
378 return is_running;
379}
380
381static int 401static int
382rt_cpu_plot_display_info(struct graph_info *ginfo, struct graph_plot *plot, 402rt_cpu_plot_display_info(struct graph_info *ginfo, struct graph_plot *plot,
383 struct trace_seq *s, unsigned long long time) 403 struct trace_seq *s, unsigned long long time)
@@ -495,6 +515,9 @@ void rt_plot_cpus_update_callback(gboolean accept,
495 trace_graph_refresh(ginfo); 515 trace_graph_refresh(ginfo);
496} 516}
497 517
518/**
519 * rt_plot_cpus_plotted - return the cpus plotted.
520 */
498void rt_plot_cpus_plotted(struct graph_info *ginfo, 521void rt_plot_cpus_plotted(struct graph_info *ginfo,
499 gboolean *all_cpus, guint64 **cpu_mask) 522 gboolean *all_cpus, guint64 **cpu_mask)
500{ 523{
@@ -517,7 +540,9 @@ void rt_plot_cpus_plotted(struct graph_info *ginfo,
517 TRUE : FALSE; 540 TRUE : FALSE;
518} 541}
519 542
520 543/**
544 * rt_plot_cpu - create a plot for @cpu.
545 */
521void rt_plot_cpu(struct graph_info *ginfo, int cpu) 546void rt_plot_cpu(struct graph_info *ginfo, int cpu)
522{ 547{
523 struct rt_cpu_info *rtc_info; 548 struct rt_cpu_info *rtc_info;
diff --git a/rt-plot-task.c b/rt-plot-task.c
index 947e2e9..7132fb2 100644
--- a/rt-plot-task.c
+++ b/rt-plot-task.c
@@ -197,11 +197,15 @@ get_previous_release(struct graph_info *ginfo, struct rt_task_info *rtt_info,
197} 197}
198 198
199/* 199/*
200 * Return information for @time, returns @job, @release, @deadline, and @record. 200 * Get information about the given @time.
201 * @job: Job number at this time 201 * @out_job: Job number at this time
202 * @release: Job's release time 202 * @out_release: Job's release time
203 * @deadline: Job's deadline 203 * @out_deadline: Job's deadline
204 * @record: Matching record 204 * @out_record: Matching record
205 *
206 * Return 1 and @out_record if a record is found at @time.
207 * Return @out_job, @out_release, and @out_deadline if the current
208 * job could be calculated.
205 */ 209 */
206static int get_time_info(struct graph_info *ginfo, 210static int get_time_info(struct graph_info *ginfo,
207 struct rt_task_info *rtt_info, 211 struct rt_task_info *rtt_info,
@@ -766,7 +770,10 @@ void rt_plot_task_update_callback(gboolean accept,
766 trace_graph_refresh(ginfo); 770 trace_graph_refresh(ginfo);
767} 771}
768 772
769void rt_plot_task_plotted(struct graph_info *ginfo, gint **plotted) 773/**
774 * rt_plot_tasks_plotted - return the tasks plotted.
775 */
776void rt_plot_tasks_plotted(struct graph_info *ginfo, gint **plotted)
770{ 777{
771 struct task_plot_info *task_info; 778 struct task_plot_info *task_info;
772 struct graph_plot *plot; 779 struct graph_plot *plot;
@@ -783,6 +790,9 @@ void rt_plot_task_plotted(struct graph_info *ginfo, gint **plotted)
783 } 790 }
784} 791}
785 792
793/**
794 * rt_plot_task - create a plot for @pid.
795 */
786void rt_plot_task(struct graph_info *ginfo, int pid, int pos) 796void rt_plot_task(struct graph_info *ginfo, int pid, int pos)
787{ 797{
788 struct rt_graph_info *rtg_info = &ginfo->rtg_info; 798 struct rt_graph_info *rtg_info = &ginfo->rtg_info;
diff --git a/rt-plot-task.h b/rt-plot-task.h
index 9f031e9..ccbd208 100644
--- a/rt-plot-task.h
+++ b/rt-plot-task.h
@@ -26,7 +26,7 @@ struct rt_task_info {
26}; 26};
27 27
28void rt_plot_task(struct graph_info *ginfo, int pid, int pos); 28void rt_plot_task(struct graph_info *ginfo, int pid, int pos);
29void rt_plot_task_plotted(struct graph_info *ginfo, gint **plotted); 29void rt_plot_tasks_plotted(struct graph_info *ginfo, gint **plotted);
30void rt_plot_task_update_callback(gboolean accept, gint *selected, 30void rt_plot_task_update_callback(gboolean accept, gint *selected,
31 gint *non_select, gpointer data); 31 gint *non_select, gpointer data);
32#endif 32#endif
diff --git a/trace-plot-task.c b/trace-plot-task.c
index 096b792..ec0029d 100644
--- a/trace-plot-task.c
+++ b/trace-plot-task.c
@@ -23,9 +23,6 @@
23#include "trace-graph.h" 23#include "trace-graph.h"
24#include "trace-filter.h" 24#include "trace-filter.h"
25 25
26#define RED 0xff
27#define GREEN (0xff<<16)
28
29gboolean is_running(struct graph_info *ginfo, struct record *record) 26gboolean is_running(struct graph_info *ginfo, struct record *record)
30{ 27{
31 unsigned long long val; 28 unsigned long long val;