summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'driver/gator_marshaling.c')
-rw-r--r--driver/gator_marshaling.c97
1 files changed, 23 insertions, 74 deletions
diff --git a/driver/gator_marshaling.c b/driver/gator_marshaling.c
index af80ff6..fd413ad 100644
--- a/driver/gator_marshaling.c
+++ b/driver/gator_marshaling.c
@@ -1,5 +1,5 @@
1/** 1/**
2 * Copyright (C) ARM Limited 2012-2013. All rights reserved. 2 * Copyright (C) ARM Limited 2012-2014. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as 5 * it under the terms of the GNU General Public License version 2 as
@@ -29,6 +29,7 @@ static void marshal_summary(long long timestamp, long long uptime, long long mon
29 int cpu = 0; 29 int cpu = 0;
30 30
31 local_irq_save(flags); 31 local_irq_save(flags);
32 gator_buffer_write_packed_int(cpu, SUMMARY_BUF, MESSAGE_SUMMARY);
32 gator_buffer_write_string(cpu, SUMMARY_BUF, NEWLINE_CANARY); 33 gator_buffer_write_string(cpu, SUMMARY_BUF, NEWLINE_CANARY);
33 gator_buffer_write_packed_int64(cpu, SUMMARY_BUF, timestamp); 34 gator_buffer_write_packed_int64(cpu, SUMMARY_BUF, timestamp);
34 gator_buffer_write_packed_int64(cpu, SUMMARY_BUF, uptime); 35 gator_buffer_write_packed_int64(cpu, SUMMARY_BUF, uptime);
@@ -52,8 +53,8 @@ static void marshal_summary(long long timestamp, long long uptime, long long mon
52#endif 53#endif
53 gator_buffer_write_string(cpu, SUMMARY_BUF, ""); 54 gator_buffer_write_string(cpu, SUMMARY_BUF, "");
54 // Commit the buffer now so it can be one of the first frames read by Streamline 55 // Commit the buffer now so it can be one of the first frames read by Streamline
55 gator_commit_buffer(cpu, SUMMARY_BUF, gator_get_time());
56 local_irq_restore(flags); 56 local_irq_restore(flags);
57 gator_commit_buffer(cpu, SUMMARY_BUF, gator_get_time());
57} 58}
58 59
59static bool marshal_cookie_header(const char *text) 60static bool marshal_cookie_header(const char *text)
@@ -85,8 +86,8 @@ static void marshal_thread_name(int pid, char *name)
85 gator_buffer_write_packed_int(cpu, NAME_BUF, pid); 86 gator_buffer_write_packed_int(cpu, NAME_BUF, pid);
86 gator_buffer_write_string(cpu, NAME_BUF, name); 87 gator_buffer_write_string(cpu, NAME_BUF, name);
87 } 88 }
88 buffer_check(cpu, NAME_BUF, time);
89 local_irq_restore(flags); 89 local_irq_restore(flags);
90 buffer_check(cpu, NAME_BUF, time);
90} 91}
91 92
92static void marshal_link(int cookie, int tgid, int pid) 93static void marshal_link(int cookie, int tgid, int pid)
@@ -103,12 +104,12 @@ static void marshal_link(int cookie, int tgid, int pid)
103 gator_buffer_write_packed_int(cpu, NAME_BUF, tgid); 104 gator_buffer_write_packed_int(cpu, NAME_BUF, tgid);
104 gator_buffer_write_packed_int(cpu, NAME_BUF, pid); 105 gator_buffer_write_packed_int(cpu, NAME_BUF, pid);
105 } 106 }
107 local_irq_restore(flags);
106 // Check and commit; commit is set to occur once buffer is 3/4 full 108 // Check and commit; commit is set to occur once buffer is 3/4 full
107 buffer_check(cpu, NAME_BUF, time); 109 buffer_check(cpu, NAME_BUF, time);
108 local_irq_restore(flags);
109} 110}
110 111
111static bool marshal_backtrace_header(int exec_cookie, int tgid, int pid, int inKernel, u64 time) 112static bool marshal_backtrace_header(int exec_cookie, int tgid, int pid, u64 time)
112{ 113{
113 int cpu = get_physical_cpu(); 114 int cpu = get_physical_cpu();
114 if (!buffer_check_space(cpu, BACKTRACE_BUF, MAXSIZE_PACK64 + 5 * MAXSIZE_PACK32 + gator_backtrace_depth * 2 * MAXSIZE_PACK32)) { 115 if (!buffer_check_space(cpu, BACKTRACE_BUF, MAXSIZE_PACK64 + 5 * MAXSIZE_PACK32 + gator_backtrace_depth * 2 * MAXSIZE_PACK32)) {
@@ -122,14 +123,16 @@ static bool marshal_backtrace_header(int exec_cookie, int tgid, int pid, int inK
122 gator_buffer_write_packed_int(cpu, BACKTRACE_BUF, exec_cookie); 123 gator_buffer_write_packed_int(cpu, BACKTRACE_BUF, exec_cookie);
123 gator_buffer_write_packed_int(cpu, BACKTRACE_BUF, tgid); 124 gator_buffer_write_packed_int(cpu, BACKTRACE_BUF, tgid);
124 gator_buffer_write_packed_int(cpu, BACKTRACE_BUF, pid); 125 gator_buffer_write_packed_int(cpu, BACKTRACE_BUF, pid);
125 gator_buffer_write_packed_int(cpu, BACKTRACE_BUF, inKernel);
126 126
127 return true; 127 return true;
128} 128}
129 129
130static void marshal_backtrace(unsigned long address, int cookie) 130static void marshal_backtrace(unsigned long address, int cookie, int in_kernel)
131{ 131{
132 int cpu = get_physical_cpu(); 132 int cpu = get_physical_cpu();
133 if (cookie == 0 && !in_kernel) {
134 cookie = UNRESOLVED_COOKIE;
135 }
133 gator_buffer_write_packed_int(cpu, BACKTRACE_BUF, cookie); 136 gator_buffer_write_packed_int(cpu, BACKTRACE_BUF, cookie);
134 gator_buffer_write_packed_int64(cpu, BACKTRACE_BUF, address); 137 gator_buffer_write_packed_int64(cpu, BACKTRACE_BUF, address);
135} 138}
@@ -224,9 +227,9 @@ static void marshal_event_single(int core, int key, int value)
224 gator_buffer_write_packed_int(cpu, COUNTER_BUF, key); 227 gator_buffer_write_packed_int(cpu, COUNTER_BUF, key);
225 gator_buffer_write_packed_int(cpu, COUNTER_BUF, value); 228 gator_buffer_write_packed_int(cpu, COUNTER_BUF, value);
226 } 229 }
230 local_irq_restore(flags);
227 // Check and commit; commit is set to occur once buffer is 3/4 full 231 // Check and commit; commit is set to occur once buffer is 3/4 full
228 buffer_check(cpu, COUNTER_BUF, time); 232 buffer_check(cpu, COUNTER_BUF, time);
229 local_irq_restore(flags);
230} 233}
231#endif 234#endif
232 235
@@ -248,9 +251,9 @@ static void marshal_sched_gpu_start(int unit, int core, int tgid, int pid)
248 gator_buffer_write_packed_int(cpu, GPU_TRACE_BUF, tgid); 251 gator_buffer_write_packed_int(cpu, GPU_TRACE_BUF, tgid);
249 gator_buffer_write_packed_int(cpu, GPU_TRACE_BUF, pid); 252 gator_buffer_write_packed_int(cpu, GPU_TRACE_BUF, pid);
250 } 253 }
254 local_irq_restore(flags);
251 // Check and commit; commit is set to occur once buffer is 3/4 full 255 // Check and commit; commit is set to occur once buffer is 3/4 full
252 buffer_check(cpu, GPU_TRACE_BUF, time); 256 buffer_check(cpu, GPU_TRACE_BUF, time);
253 local_irq_restore(flags);
254} 257}
255 258
256static void marshal_sched_gpu_stop(int unit, int core) 259static void marshal_sched_gpu_stop(int unit, int core)
@@ -269,9 +272,9 @@ static void marshal_sched_gpu_stop(int unit, int core)
269 gator_buffer_write_packed_int(cpu, GPU_TRACE_BUF, unit); 272 gator_buffer_write_packed_int(cpu, GPU_TRACE_BUF, unit);
270 gator_buffer_write_packed_int(cpu, GPU_TRACE_BUF, core); 273 gator_buffer_write_packed_int(cpu, GPU_TRACE_BUF, core);
271 } 274 }
275 local_irq_restore(flags);
272 // Check and commit; commit is set to occur once buffer is 3/4 full 276 // Check and commit; commit is set to occur once buffer is 3/4 full
273 buffer_check(cpu, GPU_TRACE_BUF, time); 277 buffer_check(cpu, GPU_TRACE_BUF, time);
274 local_irq_restore(flags);
275} 278}
276 279
277static void marshal_sched_trace_start(int tgid, int pid, int cookie) 280static void marshal_sched_trace_start(int tgid, int pid, int cookie)
@@ -291,9 +294,9 @@ static void marshal_sched_trace_start(int tgid, int pid, int cookie)
291 gator_buffer_write_packed_int(cpu, SCHED_TRACE_BUF, pid); 294 gator_buffer_write_packed_int(cpu, SCHED_TRACE_BUF, pid);
292 gator_buffer_write_packed_int(cpu, SCHED_TRACE_BUF, cookie); 295 gator_buffer_write_packed_int(cpu, SCHED_TRACE_BUF, cookie);
293 } 296 }
297 local_irq_restore(flags);
294 // Check and commit; commit is set to occur once buffer is 3/4 full 298 // Check and commit; commit is set to occur once buffer is 3/4 full
295 buffer_check(cpu, SCHED_TRACE_BUF, time); 299 buffer_check(cpu, SCHED_TRACE_BUF, time);
296 local_irq_restore(flags);
297} 300}
298 301
299static void marshal_sched_trace_switch(int tgid, int pid, int cookie, int state) 302static void marshal_sched_trace_switch(int tgid, int pid, int cookie, int state)
@@ -314,9 +317,9 @@ static void marshal_sched_trace_switch(int tgid, int pid, int cookie, int state)
314 gator_buffer_write_packed_int(cpu, SCHED_TRACE_BUF, cookie); 317 gator_buffer_write_packed_int(cpu, SCHED_TRACE_BUF, cookie);
315 gator_buffer_write_packed_int(cpu, SCHED_TRACE_BUF, state); 318 gator_buffer_write_packed_int(cpu, SCHED_TRACE_BUF, state);
316 } 319 }
320 local_irq_restore(flags);
317 // Check and commit; commit is set to occur once buffer is 3/4 full 321 // Check and commit; commit is set to occur once buffer is 3/4 full
318 buffer_check(cpu, SCHED_TRACE_BUF, time); 322 buffer_check(cpu, SCHED_TRACE_BUF, time);
319 local_irq_restore(flags);
320} 323}
321 324
322static void marshal_sched_trace_exit(int tgid, int pid) 325static void marshal_sched_trace_exit(int tgid, int pid)
@@ -334,9 +337,9 @@ static void marshal_sched_trace_exit(int tgid, int pid)
334 gator_buffer_write_packed_int64(cpu, SCHED_TRACE_BUF, time); 337 gator_buffer_write_packed_int64(cpu, SCHED_TRACE_BUF, time);
335 gator_buffer_write_packed_int(cpu, SCHED_TRACE_BUF, pid); 338 gator_buffer_write_packed_int(cpu, SCHED_TRACE_BUF, pid);
336 } 339 }
340 local_irq_restore(flags);
337 // Check and commit; commit is set to occur once buffer is 3/4 full 341 // Check and commit; commit is set to occur once buffer is 3/4 full
338 buffer_check(cpu, SCHED_TRACE_BUF, time); 342 buffer_check(cpu, SCHED_TRACE_BUF, time);
339 local_irq_restore(flags);
340} 343}
341 344
342#if GATOR_CPU_FREQ_SUPPORT 345#if GATOR_CPU_FREQ_SUPPORT
@@ -353,80 +356,26 @@ static void marshal_idle(int core, int state)
353 gator_buffer_write_packed_int64(cpu, IDLE_BUF, time); 356 gator_buffer_write_packed_int64(cpu, IDLE_BUF, time);
354 gator_buffer_write_packed_int(cpu, IDLE_BUF, core); 357 gator_buffer_write_packed_int(cpu, IDLE_BUF, core);
355 } 358 }
359 local_irq_restore(flags);
356 // Check and commit; commit is set to occur once buffer is 3/4 full 360 // Check and commit; commit is set to occur once buffer is 3/4 full
357 buffer_check(cpu, IDLE_BUF, time); 361 buffer_check(cpu, IDLE_BUF, time);
358 local_irq_restore(flags);
359} 362}
360#endif 363#endif
361 364
362static void marshal_frame(int cpu, int buftype)
363{
364 int frame;
365
366 if (!per_cpu(gator_buffer, cpu)[buftype]) {
367 return;
368 }
369
370 switch (buftype) {
371 case SUMMARY_BUF:
372 frame = FRAME_SUMMARY;
373 break;
374 case BACKTRACE_BUF:
375 frame = FRAME_BACKTRACE;
376 break;
377 case NAME_BUF:
378 frame = FRAME_NAME;
379 break;
380 case COUNTER_BUF:
381 frame = FRAME_COUNTER;
382 break;
383 case BLOCK_COUNTER_BUF:
384 frame = FRAME_BLOCK_COUNTER;
385 break;
386 case ANNOTATE_BUF:
387 frame = FRAME_ANNOTATE;
388 break;
389 case SCHED_TRACE_BUF:
390 frame = FRAME_SCHED_TRACE;
391 break;
392 case GPU_TRACE_BUF:
393 frame = FRAME_GPU_TRACE;
394 break;
395 case IDLE_BUF:
396 frame = FRAME_IDLE;
397 break;
398 default:
399 frame = -1;
400 break;
401 }
402
403 // add response type
404 if (gator_response_type > 0) {
405 gator_buffer_write_packed_int(cpu, buftype, gator_response_type);
406 }
407
408 // leave space for 4-byte unpacked length
409 per_cpu(gator_buffer_write, cpu)[buftype] = (per_cpu(gator_buffer_write, cpu)[buftype] + sizeof(s32)) & gator_buffer_mask[buftype];
410
411 // add frame type and core number
412 gator_buffer_write_packed_int(cpu, buftype, frame);
413 gator_buffer_write_packed_int(cpu, buftype, cpu);
414}
415
416#if defined(__arm__) || defined(__aarch64__) 365#if defined(__arm__) || defined(__aarch64__)
417static void marshal_core_name(const int core, const int cpuid, const char *name) 366static void marshal_core_name(const int core, const int cpuid, const char *name)
418{ 367{
419 int cpu = get_physical_cpu(); 368 int cpu = get_physical_cpu();
420 unsigned long flags; 369 unsigned long flags;
421 local_irq_save(flags); 370 local_irq_save(flags);
422 if (buffer_check_space(cpu, NAME_BUF, MAXSIZE_PACK32 + MAXSIZE_CORE_NAME)) { 371 if (buffer_check_space(cpu, SUMMARY_BUF, MAXSIZE_PACK32 + MAXSIZE_CORE_NAME)) {
423 gator_buffer_write_packed_int(cpu, NAME_BUF, HRTIMER_CORE_NAME); 372 gator_buffer_write_packed_int(cpu, SUMMARY_BUF, MESSAGE_CORE_NAME);
424 gator_buffer_write_packed_int(cpu, NAME_BUF, core); 373 gator_buffer_write_packed_int(cpu, SUMMARY_BUF, core);
425 gator_buffer_write_packed_int(cpu, NAME_BUF, cpuid); 374 gator_buffer_write_packed_int(cpu, SUMMARY_BUF, cpuid);
426 gator_buffer_write_string(cpu, NAME_BUF, name); 375 gator_buffer_write_string(cpu, SUMMARY_BUF, name);
427 } 376 }
428 // Commit core names now so that they can show up in live 377 // Commit core names now so that they can show up in live
429 gator_commit_buffer(cpu, NAME_BUF, gator_get_time());
430 local_irq_restore(flags); 378 local_irq_restore(flags);
379 gator_commit_buffer(cpu, SUMMARY_BUF, gator_get_time());
431} 380}
432#endif 381#endif