diff options
author | Jon Medhurst <tixy@linaro.org> | 2014-10-30 18:07:34 +0000 |
---|---|---|
committer | Jon Medhurst <tixy@linaro.org> | 2014-10-30 18:07:34 +0000 |
commit | 715db954c8f2d97a6742ff13be91c99db22135e9 (patch) | |
tree | e8cd428e662cdeec5e8376d1aac3ab07eb5edbce /drivers/gator/gator_annotate.c | |
parent | ed30f24e8d07d30aa3e69d1f508f4d7bd2e8ea14 (diff) | |
parent | 560679f5923495a049796b7501038911bd8eb2cb (diff) |
Merge branch 'lsk-3.10-gator-5.20' into lsk-3.10-gator
Diffstat (limited to 'drivers/gator/gator_annotate.c')
-rw-r--r-- | drivers/gator/gator_annotate.c | 67 |
1 files changed, 35 insertions, 32 deletions
diff --git a/drivers/gator/gator_annotate.c b/drivers/gator/gator_annotate.c index 7e2c6e5d8715..ff9a3cef7b2e 100644 --- a/drivers/gator/gator_annotate.c +++ b/drivers/gator/gator_annotate.c @@ -11,12 +11,12 @@ #include <linux/fs.h> #include <linux/mm.h> #include <linux/sched.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <asm/current.h> #include <linux/spinlock.h> static DEFINE_SPINLOCK(annotate_lock); -static bool collect_annotations = false; +static bool collect_annotations; static int annotate_copy(struct file *file, char const __user *buf, size_t count) { @@ -24,10 +24,10 @@ static int annotate_copy(struct file *file, char const __user *buf, size_t count int write = per_cpu(gator_buffer_write, cpu)[ANNOTATE_BUF]; if (file == NULL) { - // copy from kernel + /* copy from kernel */ memcpy(&per_cpu(gator_buffer, cpu)[ANNOTATE_BUF][write], buf, count); } else { - // copy from user space + /* copy from user space */ if (copy_from_user(&per_cpu(gator_buffer, cpu)[ANNOTATE_BUF][write], buf, count) != 0) return -1; } @@ -41,70 +41,70 @@ static ssize_t annotate_write(struct file *file, char const __user *buf, size_t int pid, cpu, header_size, available, contiguous, length1, length2, size, count = count_orig & 0x7fffffff; bool interrupt_context; - if (*offset) { + if (*offset) return -EINVAL; - } interrupt_context = in_interrupt(); - // Annotations are not supported in interrupt context, but may work if you comment out the the next four lines of code. - // By doing so, annotations in interrupt context can result in deadlocks and lost data. + /* Annotations are not supported in interrupt context, but may work + * if you comment out the the next four lines of code. By doing so, + * annotations in interrupt context can result in deadlocks and lost + * data. + */ if (interrupt_context) { - printk(KERN_WARNING "gator: Annotations are not supported in interrupt context. Edit gator_annotate.c in the gator driver to enable annotations in interrupt context.\n"); + pr_warning("gator: Annotations are not supported in interrupt context. Edit gator_annotate.c in the gator driver to enable annotations in interrupt context.\n"); return -EINVAL; } retry: - // synchronize between cores and with collect_annotations + /* synchronize between cores and with collect_annotations */ spin_lock(&annotate_lock); if (!collect_annotations) { - // Not collecting annotations, tell the caller everything was written + /* Not collecting annotations, tell the caller everything was written */ size = count_orig; goto annotate_write_out; } - // 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) { + if (current == NULL) pid = 0; - } else { + else pid = current->pid; - } - // determine total size of the payload + /* determine total size of the payload */ header_size = MAXSIZE_PACK32 * 3 + MAXSIZE_PACK64; available = buffer_bytes_available(cpu, ANNOTATE_BUF) - header_size; size = count < available ? count : available; if (size <= 0) { - // Buffer is full, wait until space is available + /* Buffer is full, wait until space is available */ spin_unlock(&annotate_lock); - // Drop the annotation as blocking is not allowed in interrupt context - if (interrupt_context) { + /* Drop the annotation as blocking is not allowed in interrupt context */ + if (interrupt_context) return -EINVAL; - } wait_event_interruptible(gator_annotate_wait, buffer_bytes_available(cpu, ANNOTATE_BUF) > header_size || !collect_annotations); - // Check to see if a signal is pending - if (signal_pending(current)) { + /* Check to see if a signal is pending */ + if (signal_pending(current)) return -EINTR; - } goto retry; } - // synchronize shared variables annotateBuf and annotatePos + /* synchronize shared variables annotateBuf and annotatePos */ if (per_cpu(gator_buffer, cpu)[ANNOTATE_BUF]) { u64 time = gator_get_time(); + gator_buffer_write_packed_int(cpu, ANNOTATE_BUF, get_physical_cpu()); gator_buffer_write_packed_int(cpu, ANNOTATE_BUF, pid); gator_buffer_write_packed_int64(cpu, ANNOTATE_BUF, time); gator_buffer_write_packed_int(cpu, ANNOTATE_BUF, size); - // determine the sizes to capture, length1 + length2 will equal size + /* determine the sizes to capture, length1 + length2 will equal size */ contiguous = contiguous_space_available(cpu, ANNOTATE_BUF); if (size < contiguous) { length1 = size; @@ -124,14 +124,14 @@ static ssize_t annotate_write(struct file *file, char const __user *buf, size_t goto annotate_write_out; } - // Check and commit; commit is set to occur once buffer is 3/4 full + /* Check and commit; commit is set to occur once buffer is 3/4 full */ buffer_check(cpu, ANNOTATE_BUF, time); } annotate_write_out: spin_unlock(&annotate_lock); - // return the number of bytes written + /* return the number of bytes written */ return size; } @@ -141,18 +141,21 @@ static int annotate_release(struct inode *inode, struct file *file) { int cpu = 0; - // synchronize between cores + /* synchronize between cores */ spin_lock(&annotate_lock); if (per_cpu(gator_buffer, cpu)[ANNOTATE_BUF] && buffer_check_space(cpu, ANNOTATE_BUF, MAXSIZE_PACK64 + 3 * MAXSIZE_PACK32)) { uint32_t pid = current->pid; + gator_buffer_write_packed_int(cpu, ANNOTATE_BUF, get_physical_cpu()); 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 + /* time */ + gator_buffer_write_packed_int64(cpu, ANNOTATE_BUF, 0); + /* size */ + gator_buffer_write_packed_int(cpu, ANNOTATE_BUF, 0); } - // Check and commit; commit is set to occur once buffer is 3/4 full + /* Check and commit; commit is set to occur once buffer is 3/4 full */ buffer_check(cpu, ANNOTATE_BUF, gator_get_time()); spin_unlock(&annotate_lock); @@ -178,7 +181,7 @@ 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 + /* 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; wake_up(&gator_annotate_wait); |