summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'driver/gator_annotate.c')
-rw-r--r--driver/gator_annotate.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/driver/gator_annotate.c b/driver/gator_annotate.c
index b2288b3..b444789 100644
--- a/driver/gator_annotate.c
+++ b/driver/gator_annotate.c
@@ -43,9 +43,9 @@ static ssize_t annotate_write(struct file *file, char const __user *buf, size_t
43 if (*offset) 43 if (*offset)
44 return -EINVAL; 44 return -EINVAL;
45 45
46 if (!collect_annotations) { 46 if (!collect_annotations)
47 // Not collecting annotations, tell the caller everything was written
47 return count_orig; 48 return count_orig;
48 }
49 49
50 cpu = 0; // Annotation only uses a single per-cpu buffer as the data must be in order to the engine 50 cpu = 0; // Annotation only uses a single per-cpu buffer as the data must be in order to the engine
51 51
@@ -64,6 +64,8 @@ static ssize_t annotate_write(struct file *file, char const __user *buf, size_t
64 size = count < available ? count : available; 64 size = count < available ? count : available;
65 65
66 if (size <= 0) { 66 if (size <= 0) {
67 // Buffer is full but don't return an error. Instead return 0 so the
68 // caller knows nothing was written and they can try again.
67 size = 0; 69 size = 0;
68 goto annotate_write_out; 70 goto annotate_write_out;
69 } 71 }
@@ -115,8 +117,9 @@ static int annotate_release(struct inode *inode, struct file *file)
115 // synchronize between cores 117 // synchronize between cores
116 spin_lock(&annotate_lock); 118 spin_lock(&annotate_lock);
117 119
118 if (per_cpu(gator_buffer, cpu)[ANNOTATE_BUF] && buffer_check_space(cpu, ANNOTATE_BUF, MAXSIZE_PACK64 + 2 * MAXSIZE_PACK32)) { 120 if (per_cpu(gator_buffer, cpu)[ANNOTATE_BUF] && buffer_check_space(cpu, ANNOTATE_BUF, MAXSIZE_PACK64 + 3 * MAXSIZE_PACK32)) {
119 uint32_t tid = current->pid; 121 uint32_t tid = current->pid;
122 gator_buffer_write_packed_int(cpu, ANNOTATE_BUF, smp_processor_id());
120 gator_buffer_write_packed_int(cpu, ANNOTATE_BUF, tid); 123 gator_buffer_write_packed_int(cpu, ANNOTATE_BUF, tid);
121 gator_buffer_write_packed_int64(cpu, ANNOTATE_BUF, 0); // time 124 gator_buffer_write_packed_int64(cpu, ANNOTATE_BUF, 0); // time
122 gator_buffer_write_packed_int(cpu, ANNOTATE_BUF, 0); // size 125 gator_buffer_write_packed_int(cpu, ANNOTATE_BUF, 0); // size