misc: tegra-profiler: add user_mode flag
Igor Nabirushkin [Mon, 27 Jan 2014 09:38:05 +0000 (13:38 +0400)]
Tegra Profiler: add user_mode flag into mmap sample

Bug 1447904

Change-Id: Ieba1025abac78b2682c0445e608fd0137dbe2379
Signed-off-by: Igor Nabirushkin <inabirushkin@nvidia.com>
Reviewed-on: http://git-master/r/365901
Reviewed-by: Automatic_Commit_Validation_User
Tested-by: Daniel Horowitz <dhorowitz@nvidia.com>
Reviewed-by: Gabby Lee <galee@nvidia.com>

drivers/misc/tegra-profiler/comm.c
drivers/misc/tegra-profiler/hrt.c
drivers/misc/tegra-profiler/mmap.c
drivers/misc/tegra-profiler/mmap.h
drivers/misc/tegra-profiler/version.h
include/linux/tegra_profiler.h

index ed2540c..98f17a2 100644 (file)
@@ -290,8 +290,10 @@ static ssize_t read_sample(char __user *buffer, size_t max_length)
                break;
 
        case QUADD_RECORD_TYPE_MMAP:
+               length_extra = sizeof(u64);
+
                if (record.mmap.filename_length > 0) {
-                       length_extra = record.mmap.filename_length;
+                       length_extra += record.mmap.filename_length;
                } else {
                        pr_err("Error: filename is empty\n");
                        goto out;
index 638d08d..c6e7bc4 100644 (file)
@@ -465,13 +465,16 @@ void __quadd_task_sched_out(struct task_struct *prev,
 
 void __quadd_event_mmap(struct vm_area_struct *vma)
 {
+       struct quadd_parameters *param;
+
        if (likely(!hrt.active))
                return;
 
        if (!is_profile_process(current))
                return;
 
-       quadd_process_mmap(vma);
+       param = &hrt.quadd_ctx->param;
+       quadd_process_mmap(vma, param->pids[0]);
 }
 EXPORT_SYMBOL(__quadd_event_mmap);
 
index 81abf36..cb513bf 100644 (file)
 
 static void
 put_mmap_sample(struct quadd_mmap_data *s, char *filename,
-               size_t length)
+               size_t length, unsigned long pgoff)
 {
        struct quadd_record_data r;
-       struct quadd_iovec vec;
+       struct quadd_iovec vec[2];
+       u64 pgoff_val = pgoff << PAGE_SHIFT;
 
        r.magic = QUADD_RECORD_MAGIC;
        r.record_type = QUADD_RECORD_TYPE_MMAP;
@@ -41,16 +42,19 @@ put_mmap_sample(struct quadd_mmap_data *s, char *filename,
        memcpy(&r.mmap, s, sizeof(*s));
        r.mmap.filename_length = length;
 
-       vec.base = filename;
-       vec.len = length;
+       vec[0].base = &pgoff_val;
+       vec[0].len = sizeof(pgoff_val);
 
-       pr_debug("MMAP: pid: %u, file_name: '%s', addr: %#llx - %#llx, len: %llx, pgoff: %#x\n",
-               s->pid, filename, s->addr, s->addr + s->len, s->len, s->pgoff);
+       vec[1].base = filename;
+       vec[1].len = length;
 
-       quadd_put_sample(&r, &vec, 1);
+       pr_debug("MMAP: pid: %u, file_name: '%s', addr: %#llx - %#llx, len: %llx, pgoff: %#lx\n",
+                s->pid, filename, s->addr, s->addr + s->len, s->len, pgoff);
+
+       quadd_put_sample(&r, vec, ARRAY_SIZE(vec));
 }
 
-void quadd_process_mmap(struct vm_area_struct *vma)
+void quadd_process_mmap(struct vm_area_struct *vma, pid_t pid)
 {
        struct file *vm_file;
        struct path *path;
@@ -81,14 +85,16 @@ void quadd_process_mmap(struct vm_area_struct *vma)
        if (strstr(file_name, " (deleted)"))
                goto out;
 
+       sample.pid = pid;
+       sample.user_mode = 1;
+
        sample.addr = vma->vm_start;
        sample.len = vma->vm_end - vma->vm_start;
-       sample.pgoff = vma->vm_pgoff;
 
        length = strlen(file_name) + 1;
        length_aligned = ALIGN(length, sizeof(u64));
 
-       put_mmap_sample(&sample, file_name, length_aligned);
+       put_mmap_sample(&sample, file_name, length_aligned, vma->vm_pgoff);
 
 out:
        kfree(tmp_buf);
@@ -147,11 +153,13 @@ int quadd_get_current_mmap(pid_t pid)
                length_aligned = ALIGN(length, sizeof(u64));
 
                sample.pid = pid;
+               sample.user_mode = 1;
+
                sample.addr = vma->vm_start;
                sample.len = vma->vm_end - vma->vm_start;
-               sample.pgoff = vma->vm_pgoff;
 
-               put_mmap_sample(&sample, file_name, length_aligned);
+               put_mmap_sample(&sample, file_name, length_aligned,
+                               vma->vm_pgoff);
        }
        kfree(tmp_buf);
 
index 51c1500..4928f93 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <linux/types.h>
 
-void quadd_process_mmap(struct vm_area_struct *vma);
+void quadd_process_mmap(struct vm_area_struct *vma, pid_t pid);
 int quadd_get_current_mmap(pid_t pid);
 
 #endif  /* __QUADD_MMAP_H */
index d4a6b60..46643a2 100644 (file)
@@ -18,7 +18,7 @@
 #ifndef __QUADD_VERSION_H
 #define __QUADD_VERSION_H
 
-#define QUADD_MODULE_VERSION           "1.46"
+#define QUADD_MODULE_VERSION           "1.48"
 #define QUADD_MODULE_BRANCH            "Dev"
 
 #endif /* __QUADD_VERSION_H */
index fd9a2b6..15205e7 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <linux/ioctl.h>
 
-#define QUADD_SAMPLES_VERSION  19
+#define QUADD_SAMPLES_VERSION  20
 #define QUADD_IO_VERSION       9
 
 #define QUADD_IO_VERSION_DYNAMIC_RB            5
@@ -151,10 +151,11 @@ struct quadd_sample_data {
 
 struct quadd_mmap_data {
        u32 pid;
+
        u64 addr;
        u64 len;
-       u32 pgoff;
 
+       u8 user_mode:1;
        u16 filename_length;
 };