aboutsummaryrefslogtreecommitdiffstats
path: root/rt-plot-cpu.c
diff options
context:
space:
mode:
Diffstat (limited to 'rt-plot-cpu.c')
-rw-r--r--rt-plot-cpu.c123
1 files changed, 74 insertions, 49 deletions
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;