diff options
Diffstat (limited to 'driver/gator_annotate.c')
-rw-r--r-- | driver/gator_annotate.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/driver/gator_annotate.c b/driver/gator_annotate.c index f2f0465..42f9951 100644 --- a/driver/gator_annotate.c +++ b/driver/gator_annotate.c @@ -44,21 +44,23 @@ static ssize_t annotate_write(struct file *file, char const __user *buf, size_t return -EINVAL; } - // Annotation is not supported in interrupt context + // Annotations are not supported in interrupt context if (in_interrupt()) { + printk(KERN_WARNING "gator: Annotations are not supported in interrupt context\n"); return -EINVAL; } - // synchronize between cores and with collect_annotations + // synchronize between cores and with collect_annotations spin_lock(&annotate_lock); - if (!collect_annotations) { + if (!collect_annotations) { // Not collecting annotations, tell the caller everything was written size = count_orig; - goto annotate_write_out; + goto annotate_write_out; } - cpu = 0; // Annotation only uses a single per-cpu buffer as the data must be in order to the engine + // Annotation only uses a single per-cpu buffer as the data must be in order to the engine + cpu = 0; if (current == NULL) { pid = 0; @@ -129,18 +131,21 @@ static int annotate_release(struct inode *inode, struct file *file) uint32_t pid = current->pid; gator_buffer_write_packed_int(cpu, ANNOTATE_BUF, smp_processor_id()); gator_buffer_write_packed_int(cpu, ANNOTATE_BUF, pid); - gator_buffer_write_packed_int64(cpu, ANNOTATE_BUF, 0); // time - gator_buffer_write_packed_int(cpu, ANNOTATE_BUF, 0); // size + gator_buffer_write_packed_int64(cpu, ANNOTATE_BUF, 0); // time + gator_buffer_write_packed_int(cpu, ANNOTATE_BUF, 0); // size } + // Check and commit; commit is set to occur once buffer is 3/4 full + buffer_check(cpu, ANNOTATE_BUF); + spin_unlock(&annotate_lock); return 0; } static const struct file_operations annotate_fops = { - .write = annotate_write, - .release = annotate_release + .write = annotate_write, + .release = annotate_release }; static int gator_annotate_create_files(struct super_block *sb, struct dentry *root) @@ -156,8 +161,8 @@ static int gator_annotate_start(void) static void gator_annotate_stop(void) { - // the spinlock here will ensure that when this function exits, we are not in the middle of an annotation - spin_lock(&annotate_lock); + // the spinlock here will ensure that when this function exits, we are not in the middle of an annotation + spin_lock(&annotate_lock); collect_annotations = false; - spin_unlock(&annotate_lock); + spin_unlock(&annotate_lock); } |