23 #include <sys/types.h> 45 int enable_fd, current_tracer_fd, data_fd;
47 struct timespec ts, ts2;
48 char *trace_enable =
"/debug/tracing/tracing_enabled";
49 char *current_tracer =
"/debug/tracing/current_tracer";
50 char *trace_data =
"/debug/tracing/trace";
51 f64 realtime, monotonic;
52 f64 freq, secs_per_clock;
62 enable_fd = open (trace_enable, O_RDWR);
69 if (write (enable_fd,
"0\n", 2) != 2)
80 data_fd = open (trace_data, O_RDWR | O_TRUNC);
89 current_tracer_fd = open (current_tracer, O_RDWR);
91 if (current_tracer_fd < 0)
98 len = strlen(kernel_tracer);
100 if (write (current_tracer_fd, kernel_tracer, len) != len)
103 close(current_tracer_fd);
108 close(current_tracer_fd);
118 syscall (SYS_clock_gettime, CLOCK_MONOTONIC, &ts);
121 if (write (enable_fd,
"1\n", 2) != 2)
136 s =
format (s,
"cpu %d task %10s type %s timestamp %12.6f\n",
144 u8 *cp = tdata + *index;
149 static u8 *task_name;
155 while (cp < limit && (*cp ==
' ' && *cp ==
'\t'))
163 while (cp < limit && (*cp !=
'\n'))
174 while (cp < limit && *cp !=
']')
187 while (cp < limit && (*cp ==
' ' && *cp ==
'\t'))
197 while (cp < limit && (*cp !=
'.'))
213 for (i = 0; i < 3; i++)
215 while (cp < limit && *cp !=
':')
257 while (cp < limit && (*cp ==
' ' || *cp ==
'\t'))
262 for (i = 0; i < 2; i++)
264 while (cp < limit && *cp !=
':')
281 while (cp < limit && (*cp !=
' ' && *cp !=
'\n'))
300 mhash_t * h = &em->string_table_hash;
302 if (! em->string_table_hash.hash)
315 int enable_fd, data_fd;
316 char *trace_enable =
"/debug/tracing/tracing_enabled";
317 char *trace_data =
"/debug/tracing/trace";
320 int bytes, total_bytes;
327 enable_fd = open (trace_enable, O_RDWR);
334 if (write (enable_fd,
"0\n", 2) != 2)
343 data_fd = open (trace_data, O_RDWR);
359 bytes = read(data_fd, data+pos, 4096);
363 total_bytes += bytes;
364 _vec_len(data) = total_bytes;
383 .format =
"%d: %s %s",
384 .format_args =
"i4T4t4",
386 .enum_strings = {
"running",
"wakeup", },
388 struct {
u32 cpu, string_table_offset, which; } * ed;
395 ed->which = evt->
type;
397 _vec_len(evt->
task) = 0;
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
u8 * format_sched_event(u8 *s, va_list *va)
sll srl srl sll sra u16x4 i
elog_time_stamp_t init_time
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
always_inline uword mhash_set(mhash_t *h, void *key, uword new_value, uword *old_value)
void kelog_collect_sched_switch_trace(elog_main_t *em)
static u32 elog_id_for_pid(elog_main_t *em, u8 *name, u32 pid)
void elog_init(elog_main_t *em, u32 n_events)
#define clib_warning(format, args...)
void kelog_init(elog_main_t *em, char *kernel_tracer, u32 n_events)
sched_event_t * parse_sched_switch_trace(u8 *tdata, u32 *index)
void clib_time_init(clib_time_t *c)
always_inline void * elog_event_data_not_inline(elog_main_t *em, elog_event_type_t *type, elog_track_t *track, u64 cpu_time)
void mhash_init(mhash_t *h, uword n_value_bytes, uword n_key_bytes)
#define clib_unix_warning(format, args...)
#define ELOG_TYPE_DECLARE(f)
u32 elog_string(elog_main_t *em, char *fmt,...)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
elog_track_t default_track
always_inline uword * mhash_get(mhash_t *h, void *key)