aboutsummaryrefslogtreecommitdiffstats
path: root/trace-graph.c
diff options
context:
space:
mode:
Diffstat (limited to 'trace-graph.c')
-rw-r--r--trace-graph.c91
1 files changed, 4 insertions, 87 deletions
diff --git a/trace-graph.c b/trace-graph.c
index 6dafadf..819482e 100644
--- a/trace-graph.c
+++ b/trace-graph.c
@@ -70,91 +70,6 @@ static GdkGC *red;
70static void redraw_pixmap_backend(struct graph_info *ginfo); 70static void redraw_pixmap_backend(struct graph_info *ginfo);
71static void update_label_window(struct graph_info *ginfo); 71static void update_label_window(struct graph_info *ginfo);
72 72
73struct task_list {
74 struct task_list *next;
75 gint pid;
76};
77
78static guint get_task_hash_key(gint pid)
79{
80 return trace_hash(pid) % TASK_HASH_SIZE;
81}
82
83static struct task_list *find_task_hash(struct graph_info *ginfo,
84 gint key, gint pid)
85{
86 struct task_list *list;
87
88 for (list = ginfo->tasks[key]; list; list = list->next) {
89 if (list->pid == pid)
90 return list;
91 }
92
93 return NULL;
94}
95
96static struct task_list *add_task_hash(struct graph_info *ginfo,
97 int pid)
98{
99 struct task_list *list;
100 guint key = get_task_hash_key(pid);
101
102 list = find_task_hash(ginfo, key, pid);
103 if (list)
104 return list;
105
106 list = malloc_or_die(sizeof(*list));
107 list->pid = pid;
108 list->next = ginfo->tasks[key];
109 ginfo->tasks[key] = list;
110
111 return list;
112}
113
114static void free_task_hash(struct graph_info *ginfo)
115{
116 struct task_list *list;
117 int i;
118
119 for (i = 0; i < TASK_HASH_SIZE; i++) {
120 while (ginfo->tasks[i]) {
121 list = ginfo->tasks[i];
122 ginfo->tasks[i] = list->next;
123 free(list);
124 }
125 }
126}
127
128/**
129 * trace_graph_task_list - return an allocated list of all found tasks
130 * @ginfo: The graph info structure
131 *
132 * Returns an allocated list of pids found in the graph, ending
133 * with a -1. This array must be freed with free().
134 */
135gint *trace_graph_task_list(struct graph_info *ginfo)
136{
137 struct task_list *list;
138 gint *pids;
139 gint count = 0;
140 gint i;
141
142 for (i = 0; i < TASK_HASH_SIZE; i++) {
143 list = ginfo->tasks[i];
144 while (list) {
145 if (count)
146 pids = realloc(pids, sizeof(*pids) * (count + 2));
147 else
148 pids = malloc(sizeof(*pids) * 2);
149 pids[count++] = list->pid;
150 pids[count] = -1;
151 list = list->next;
152 }
153 }
154
155 return pids;
156}
157
158static void convert_nano(unsigned long long time, unsigned long *sec, 73static void convert_nano(unsigned long long time, unsigned long *sec,
159 unsigned long *usec) 74 unsigned long *usec)
160{ 75{
@@ -210,6 +125,8 @@ static void init_event_cache(struct graph_info *ginfo)
210 * it into the pevent command line list. 125 * it into the pevent command line list.
211 */ 126 */
212 ginfo->read_comms = TRUE; 127 ginfo->read_comms = TRUE;
128
129 init_rt_event_cache(&ginfo->rtinfo);
213} 130}
214 131
215struct filter_task_item * 132struct filter_task_item *
@@ -1082,7 +999,7 @@ int trace_graph_check_sched_switch(struct graph_info *ginfo,
1082 if (ginfo->read_comms) { 999 if (ginfo->read_comms) {
1083 /* record all pids, for task plots */ 1000 /* record all pids, for task plots */
1084 this_pid = pevent_data_pid(ginfo->pevent, record); 1001 this_pid = pevent_data_pid(ginfo->pevent, record);
1085 add_task_hash(ginfo, this_pid); 1002 add_task_hash(ginfo->tasks, this_pid);
1086 } 1003 }
1087 1004
1088 if (ginfo->event_sched_switch_id < 0) { 1005 if (ginfo->event_sched_switch_id < 0) {
@@ -2385,7 +2302,7 @@ void trace_graph_free_info(struct graph_info *ginfo)
2385 pevent_filter_free(ginfo->event_filter); 2302 pevent_filter_free(ginfo->event_filter);
2386 trace_graph_plot_free(ginfo); 2303 trace_graph_plot_free(ginfo);
2387 tracecmd_close(ginfo->handle); 2304 tracecmd_close(ginfo->handle);
2388 free_task_hash(ginfo); 2305 free_task_hash(ginfo->tasks);
2389 2306
2390 ginfo->cursor = 0; 2307 ginfo->cursor = 0;
2391 } 2308 }