misc: tegra-profiler: simpler task status checking
Dmitry Antipov [Fri, 20 Mar 2015 12:24:41 +0000 (15:24 +0300)]
Use PF_EXITING to check task status and simplify argument checking
in read_all_sources, adjust hrtimer_handler accordingly.

Bug 1625611

Signed-off-by: Dmitry Antipov <dantipov@nvidia.com>
Change-Id: Ida8f9e7ed5492f17868988e05328bfa8432a31e9
Reviewed-on: http://git-master/r/719460
(cherry picked from commit 316d507f4aaa04e9c91da3faa25c861260d6b194)
Reviewed-on: http://git-master/r/748088
GVS: Gerrit_Virtual_Submit
Reviewed-by: Andrey Trachenko <atrachenko@nvidia.com>
Tested-by: Igor Nabirushkin <inabirushkin@nvidia.com>
Reviewed-by: Winnie Hsu <whsu@nvidia.com>

drivers/misc/tegra-profiler/hrt.c

index 3c5221a..bd1bff6 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/ptrace.h>
 #include <linux/interrupt.h>
 #include <linux/err.h>
-#include <linux/nsproxy.h>
 #include <clocksource/arm_arch_timer.h>
 
 #include <asm/cputype.h>
@@ -68,7 +67,7 @@ static enum hrtimer_restart hrtimer_handler(struct hrtimer *hrtimer)
        qm_debug_handler_sample(regs);
 
        if (regs)
-               read_all_sources(regs, NULL);
+               read_all_sources(regs, current);
 
        hrtimer_forward_now(hrtimer, ns_to_ktime(hrt.sample_period));
        qm_debug_timer_forward(regs, hrt.sample_period);
@@ -357,25 +356,12 @@ read_all_sources(struct pt_regs *regs, struct task_struct *task)
        struct quadd_cpu_context *cpu_ctx = this_cpu_ptr(hrt.cpu_ctx);
        struct quadd_callchain *cc = &cpu_ctx->cc;
 
-       if (!regs)
-               return;
-
        if (atomic_read(&cpu_ctx->nr_active) == 0)
                return;
 
-       if (!task)
-               task = current;
-
-       if (task_is_dead(task))
+       if (task->flags & PF_EXITING)
                return;
 
-       rcu_read_lock();
-       if (!task_nsproxy(task)) {
-               rcu_read_unlock();
-               return;
-       }
-       rcu_read_unlock();
-
        if (ctx->pmu && ctx->pmu_info.active)
                nr_events += read_source(ctx->pmu, regs,
                                         events, QUADD_MAX_COUNTERS);