diff options
Diffstat (limited to 'driver/gator_annotate.c')
-rw-r--r-- | driver/gator_annotate.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/driver/gator_annotate.c b/driver/gator_annotate.c index d8d86af..e096d15 100644 --- a/driver/gator_annotate.c +++ b/driver/gator_annotate.c @@ -22,6 +22,7 @@ static char *annotateBuf0; static char *annotateBuf1; static int annotatePos; static int annotateSel; +static bool collect_annotations = false; static ssize_t annotate_write(struct file *file, char const __user *buf, size_t count, loff_t *offset) { @@ -45,16 +46,13 @@ static ssize_t annotate_write(struct file *file, char const __user *buf, size_t if (retval == 0) { // synchronize shared variables annotateBuf and annotatePos spin_lock(&annotate_lock); - if (annotateBuf) { + if (collect_annotations && annotateBuf) { uint32_t tid = current->pid; - uint32_t tick = gator_master_tick; uint64_t time = gator_get_time(); uint32_t cpuid = smp_processor_id(); int pos = annotatePos; pos += gator_write_packed_int(&annotateBuf[pos], tid); - pos += gator_write_packed_int(&annotateBuf[pos], tick); - pos += gator_write_packed_int(&annotateBuf[pos], time); - pos += gator_write_packed_int(&annotateBuf[pos], time >> 32); + pos += gator_write_packed_int64(&annotateBuf[pos], time); pos += gator_write_packed_int(&annotateBuf[pos], cpuid); pos += gator_write_packed_int(&annotateBuf[pos], size); memcpy(&annotateBuf[pos], tempBuffer, size); @@ -81,12 +79,9 @@ static int annotate_release(struct inode *inode, struct file *file) spin_lock(&annotate_lock); if (annotateBuf) { uint32_t tid = current->pid; - uint32_t tick = gator_master_tick; int pos = annotatePos; pos += gator_write_packed_int(&annotateBuf[pos], tid); - pos += gator_write_packed_int(&annotateBuf[pos], tick); - pos += gator_write_packed_int(&annotateBuf[pos], 0); // time - pos += gator_write_packed_int(&annotateBuf[pos], 0); // time + pos += gator_write_packed_int64(&annotateBuf[pos], 0); // time pos += gator_write_packed_int(&annotateBuf[pos], 0); // cpuid pos += gator_write_packed_int(&annotateBuf[pos], 0); // size annotatePos = pos; @@ -118,13 +113,21 @@ static int gator_annotate_init(void) static int gator_annotate_start(void) { - annotatePos = annotateSel = 0; + annotateSel = 0; + annotatePos = 1; annotateBuf = annotateBuf0; + annotateBuf[0] = FRAME_ANNOTATE; + collect_annotations = true; return 0; } static void gator_annotate_stop(void) { + collect_annotations = false; +} + +static void gator_annotate_shutdown(void) +{ spin_lock(&annotate_lock); annotateBuf = NULL; spin_unlock(&annotate_lock); @@ -141,7 +144,7 @@ static void gator_annotate_exit(void) static int gator_annotate_ready(void) { - return annotatePos && annotateBuf; + return annotatePos > 1 && annotateBuf; } static int gator_annotate_read(char **buffer) @@ -158,8 +161,9 @@ static int gator_annotate_read(char **buffer) spin_lock(&annotate_lock); len = annotatePos; - annotatePos = 0; annotateBuf = annotateSel ? annotateBuf1 : annotateBuf0; + annotateBuf[0] = FRAME_ANNOTATE; + annotatePos = 1; spin_unlock(&annotate_lock); return len; |