]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
misc: tegra-profiler: enable multiprocess support
authorArul Sekar <aruls@nvidia.com>
Tue, 10 May 2016 18:21:24 +0000 (11:21 -0700)
committermobile promotions <svcmobile_promotions@nvidia.com>
Tue, 26 Jul 2016 23:59:57 +0000 (16:59 -0700)
- support multi process profiling requests from user
- uses trace_all_tasks parameter
- skip kernel swapper (pid == 0) tasks

Bug 1764640

Change-Id: I1f0e2d4432d095b1e6e4db0781be9ce355bf23ed
Signed-off-by: Arul Sekar <aruls@nvidia.com>
(cherry picked from commit f0799d139c2d32ce44efd4b544fca20fed7c08af)
Reviewed-on: http://git-master/r/1161158
Tested-by: Anatoly Nikiforov <anikiforov@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
GVS: Gerrit_Virtual_Submit
(cherry picked from commit 6ff5f51d2604b5a443f898b2f7c1a2cac34edc10)
Reviewed-on: http://git-master/r/1175198

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

index 3c78dcf425b91d988b80508ac3387a2dfb949e7e..08190c41bf29e398ab9ccc830fec32573745ba02 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * drivers/misc/tegra-profiler/hrt.c
  *
- * Copyright (c) 2015, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 2016, NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -245,6 +245,7 @@ put_sched_sample(struct task_struct *task, int is_sched_in)
        s->sched_in = is_sched_in ? 1 : 0;
        s->time = quadd_get_time();
        s->pid = task->pid;
+       s->tgid = task->tgid;
 
        s->reserved = 0;
 
@@ -278,6 +279,7 @@ static int get_sample_data(struct quadd_sample_data *sample,
        sample->time = quadd_get_time();
        sample->reserved = 0;
        sample->pid = task->pid;
+       sample->tgid = task->tgid;
        sample->in_interrupt = in_interrupt() ? 1 : 0;
 
        return 0;
@@ -495,7 +497,7 @@ read_all_sources(struct pt_regs *regs, struct task_struct *task)
 }
 
 static inline int
-is_profile_process(struct task_struct *task)
+is_sample_process(struct task_struct *task)
 {
        int i;
        pid_t pid, profile_pid;
@@ -514,6 +516,32 @@ is_profile_process(struct task_struct *task)
        return 0;
 }
 
+static inline int
+is_swapper_task(struct task_struct *task)
+{
+       if (task->pid == 0)
+               return 1;
+
+       return 0;
+}
+
+static inline int
+is_trace_process(struct task_struct *task)
+{
+       struct quadd_ctx *ctx = hrt.quadd_ctx;
+
+       if (!task)
+               return 0;
+
+       if (is_swapper_task(task))
+               return 0;
+
+       if (ctx->param.trace_all_tasks)
+               return 1;
+
+       return is_sample_process(task);
+}
+
 static int
 add_active_thread(struct quadd_cpu_context *cpu_ctx, pid_t pid, pid_t tgid)
 {
@@ -565,9 +593,10 @@ void __quadd_task_sched_in(struct task_struct *prev,
                        (unsigned int)task->tgid);
 */
 
-       if (is_profile_process(task)) {
+       if (is_trace_process(task))
                put_sched_sample(task, 1);
 
+       if (is_sample_process(task)) {
                add_active_thread(cpu_ctx, task->pid, task->tgid);
                atomic_inc(&cpu_ctx->nr_active);
 
@@ -603,7 +632,7 @@ void __quadd_task_sched_out(struct task_struct *prev,
                        (unsigned int)next->tgid);
 */
 
-       if (is_profile_process(prev)) {
+       if (is_sample_process(prev)) {
                user_regs = task_pt_regs(prev);
                if (user_regs)
                        read_all_sources(user_regs, prev);
@@ -618,9 +647,10 @@ void __quadd_task_sched_out(struct task_struct *prev,
                        if (ctx->pmu)
                                ctx->pmu->stop();
                }
+       }
 
+       if (is_trace_process(prev))
                put_sched_sample(prev, 0);
-       }
 }
 
 void __quadd_event_mmap(struct vm_area_struct *vma)
@@ -630,7 +660,7 @@ void __quadd_event_mmap(struct vm_area_struct *vma)
        if (likely(!atomic_read(&hrt.active)))
                return;
 
-       if (!is_profile_process(current))
+       if (!is_sample_process(current))
                return;
 
        param = &hrt.quadd_ctx->param;
index a189422cd918d263b829045796a9073b5a6f86a3..72425e616de7310656d9cb4450c940e21387d552 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * drivers/misc/tegra-profiler/hrt.h
  *
- * Copyright (c) 2013-2015, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 2013-2016, NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -18,7 +18,7 @@
 #ifndef __QUADD_VERSION_H
 #define __QUADD_VERSION_H
 
-#define QUADD_MODULE_VERSION           "1.105"
+#define QUADD_MODULE_VERSION           "1.107"
 #define QUADD_MODULE_BRANCH            "Dev"
 
 #endif /* __QUADD_VERSION_H */
index 04a8d2e7ec5822da26004d94b5565815be323b53..76640812bac4739af6d5634c3b6a8d5df9316ed1 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * include/linux/tegra_profiler.h
  *
- * Copyright (c) 2013-2015, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 2013-2016, NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -19,8 +19,8 @@
 
 #include <linux/ioctl.h>
 
-#define QUADD_SAMPLES_VERSION  35
-#define QUADD_IO_VERSION       19
+#define QUADD_SAMPLES_VERSION  36
+#define QUADD_IO_VERSION       20
 
 #define QUADD_IO_VERSION_DYNAMIC_RB            5
 #define QUADD_IO_VERSION_RB_MAX_FILL_COUNT     6
@@ -37,6 +37,7 @@
 #define QUADD_IO_VERSION_SECTIONS_INFO         17
 #define QUADD_IO_VERSION_UNW_METHODS_OPT       18
 #define QUADD_IO_VERSION_PER_CPU_SETUP          19
+#define QUADD_IO_VERSION_TRACE_ALL_TASKS        20
 
 #define QUADD_SAMPLE_VERSION_THUMB_MODE_FLAG   17
 #define QUADD_SAMPLE_VERSION_GROUP_SAMPLES     18
@@ -55,6 +56,7 @@
 #define QUADD_SAMPLE_VERSION_URCS              33
 #define QUADD_SAMPLE_VERSION_HOTPLUG           34
 #define QUADD_SAMPLE_VERSION_PER_CPU_SETUP      35
+#define QUADD_SAMPLE_VERSION_REPORT_TGID        36
 
 #define QUADD_MMAP_HEADER_VERSION              1
 
@@ -233,6 +235,7 @@ enum {
 struct quadd_sample_data {
        u64 ip;
        u32 pid;
+       u32 tgid;
        u64 time;
 
        u16     cpu:6,
@@ -298,6 +301,7 @@ enum {
 
 struct quadd_sched_data {
        u32 pid;
+       u32 tgid;
        u64 time;
 
        u32     cpu:6,
@@ -414,7 +418,8 @@ struct quadd_parameters {
        u64     backtrace:1,
                use_freq:1,
                system_wide:1,
-               debug_samples:1;
+               debug_samples:1,
+               trace_all_tasks:1;
 
        u32 pids[QUADD_MAX_PROCESS];
        u32 nr_pids;