diff options
author | Igor Nabirushkin <inabirushkin@nvidia.com> | 2013-10-05 01:35:23 +0400 |
---|---|---|
committer | Riham Haidar <rhaidar@nvidia.com> | 2013-10-10 19:28:35 -0700 |
commit | 9cdf6b4fdb5cf30267a62f8b795eb83ea06d5637 (patch) | |
tree | 9ac7b50713edbb1c44032211ebabe3ef8d798cbf | |
parent | 5d0f7164f4b3e7690cc174fdeb4873453d3e99f0 (diff) |
misc: tegra-profiler: kprobes is no longer used
Tegra Profiler: kprobes is no longer used
Use callbacks from the scheduler instead of kprobes
Bug 1343930
Change-Id: I67589dbe972cc5c853addfb6ed82c488529eed55
Signed-off-by: Igor Nabirushkin <inabirushkin@nvidia.com>
Reviewed-on: http://git-master/r/281941
Reviewed-by: Daniel Horowitz <dhorowitz@nvidia.com>
Reviewed-by: Eric Miao <emiao@nvidia.com>
Tested-by: Eric Miao <emiao@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Dan Willemsen <dwillemsen@nvidia.com>
-rw-r--r-- | drivers/misc/tegra-profiler/Kconfig | 1 | ||||
-rw-r--r-- | drivers/misc/tegra-profiler/hrt.c | 140 | ||||
-rw-r--r-- | drivers/misc/tegra-profiler/hrt.h | 4 | ||||
-rw-r--r-- | drivers/misc/tegra-profiler/ma.c | 1 | ||||
-rw-r--r-- | drivers/misc/tegra-profiler/main.c | 1 | ||||
-rw-r--r-- | drivers/misc/tegra-profiler/mmap.c | 3 | ||||
-rw-r--r-- | drivers/misc/tegra-profiler/version.h | 2 | ||||
-rw-r--r-- | include/linux/tegra_profiler.h | 29 | ||||
-rw-r--r-- | kernel/sched/core.c | 3 |
9 files changed, 79 insertions, 105 deletions
diff --git a/drivers/misc/tegra-profiler/Kconfig b/drivers/misc/tegra-profiler/Kconfig index 312b75e9b848..d07cb3c3169b 100644 --- a/drivers/misc/tegra-profiler/Kconfig +++ b/drivers/misc/tegra-profiler/Kconfig @@ -1,6 +1,5 @@ config TEGRA_PROFILER bool "Enable Tegra profiler" depends on ARCH_TEGRA - select KPROBES help This option enables Tegra profiler diff --git a/drivers/misc/tegra-profiler/hrt.c b/drivers/misc/tegra-profiler/hrt.c index fdfbb96f5910..f0a8b277b5f7 100644 --- a/drivers/misc/tegra-profiler/hrt.c +++ b/drivers/misc/tegra-profiler/hrt.c @@ -374,121 +374,75 @@ static int remove_active_thread(struct quadd_cpu_context *cpu_ctx, pid_t pid) return 0; } -static int task_sched_in(struct kprobe *kp, struct pt_regs *regs) +void __quadd_task_sched_in(struct task_struct *prev, + struct task_struct *task) { - int n, prev_flag, current_flag; - struct task_struct *prev, *task; - int prev_nr_active, new_nr_active; + int current_flag; struct quadd_cpu_context *cpu_ctx = this_cpu_ptr(hrt.cpu_ctx); struct quadd_ctx *ctx = hrt.quadd_ctx; struct event_data events[QUADD_MAX_COUNTERS]; /* static DEFINE_RATELIMIT_STATE(ratelimit_state, 5 * HZ, 2); */ - if (hrt.active == 0) - return 0; - - prev = (struct task_struct *)regs->ARM_r1; - task = current; + if (likely(hrt.active == 0)) + return; /* if (__ratelimit(&ratelimit_state)) - pr_info("cpu: %d, prev: %u (%u) \t--> curr: %u (%u)\n", + pr_info("sch_in, cpu: %d, prev: %u (%u) \t--> curr: %u (%u)\n", quadd_get_processor_id(), (unsigned int)prev->pid, (unsigned int)prev->tgid, (unsigned int)task->pid, (unsigned int)task->tgid); */ - if (!prev || !prev->real_parent || !prev->group_leader || - prev->group_leader->tgid != prev->tgid) { - pr_err_once("Warning\n"); - return 0; - } - - prev_flag = is_profile_process(prev->tgid); current_flag = is_profile_process(task->tgid); - if (prev_flag || current_flag) { - prev_nr_active = atomic_read(&cpu_ctx->nr_active); - qm_debug_task_sched_in(prev->pid, task->pid, prev_nr_active); - - if (prev_flag) { - n = remove_active_thread(cpu_ctx, prev->pid); - atomic_sub(n, &cpu_ctx->nr_active); - } - if (current_flag) { - add_active_thread(cpu_ctx, task->pid, task->tgid); - atomic_inc(&cpu_ctx->nr_active); - } - - new_nr_active = atomic_read(&cpu_ctx->nr_active); - if (prev_nr_active != new_nr_active) { - if (prev_nr_active == 0) { - if (ctx->pmu) - ctx->pmu->start(); + if (current_flag) { + add_active_thread(cpu_ctx, task->pid, task->tgid); + atomic_inc(&cpu_ctx->nr_active); - if (ctx->pl310) - ctx->pl310->read(events); + if (atomic_read(&cpu_ctx->nr_active) == 1) { + if (ctx->pmu) + ctx->pmu->start(); - start_hrtimer(cpu_ctx); - atomic_inc(&hrt.nr_active_all_core); - } else if (new_nr_active == 0) { - cancel_hrtimer(cpu_ctx); - atomic_dec(&hrt.nr_active_all_core); + if (ctx->pl310) + ctx->pl310->read(events); - if (ctx->pmu) - ctx->pmu->stop(); - } + start_hrtimer(cpu_ctx); + atomic_inc(&hrt.nr_active_all_core); } } - - return 0; } -static int handler_fault(struct kprobe *kp, struct pt_regs *regs, int trapnr) +void __quadd_task_sched_out(struct task_struct *prev, + struct task_struct *next) { - pr_err_once("addr: %p, symbol: %s\n", kp->addr, kp->symbol_name); - return 0; -} - -static int start_instr(void) -{ - int err; - - memset(&hrt.kp_in, 0, sizeof(struct kprobe)); + int n, prev_flag; + struct quadd_cpu_context *cpu_ctx = this_cpu_ptr(hrt.cpu_ctx); + struct quadd_ctx *ctx = hrt.quadd_ctx; + /* static DEFINE_RATELIMIT_STATE(ratelimit_state, 5 * HZ, 2); */ - hrt.kp_in.pre_handler = task_sched_in; - hrt.kp_in.fault_handler = handler_fault; - hrt.kp_in.addr = 0; - hrt.kp_in.symbol_name = QUADD_HRT_SCHED_IN_FUNC; + if (likely(hrt.active == 0)) + return; +/* + if (__ratelimit(&ratelimit_state)) + pr_info("sch_out: cpu: %d, prev: %u (%u) \t--> next: %u (%u)\n", + quadd_get_processor_id(), (unsigned int)prev->pid, + (unsigned int)prev->tgid, (unsigned int)next->pid, + (unsigned int)next->tgid); +*/ - err = register_kprobe(&hrt.kp_in); - if (err) { - pr_err("register_kprobe error, symbol_name: %s\n", - hrt.kp_in.symbol_name); - return err; - } - return 0; -} + prev_flag = is_profile_process(prev->tgid); -static void stop_instr(void) -{ - unregister_kprobe(&hrt.kp_in); -} + if (prev_flag) { + n = remove_active_thread(cpu_ctx, prev->pid); + atomic_sub(n, &cpu_ctx->nr_active); -static int init_instr(void) -{ - int err; + if (atomic_read(&cpu_ctx->nr_active) == 0) { + cancel_hrtimer(cpu_ctx); + atomic_dec(&hrt.nr_active_all_core); - err = start_instr(); - if (err) { - pr_err("Init instr failed\n"); - return err; + if (ctx->pmu) + ctx->pmu->stop(); + } } - stop_instr(); - return 0; -} - -static int deinit_instr(void) -{ - return 0; } static void reset_cpu_ctx(void) @@ -512,7 +466,6 @@ static void reset_cpu_ctx(void) int quadd_hrt_start(void) { - int err; u64 period; long freq; struct quadd_ctx *ctx = hrt.quadd_ctx; @@ -531,12 +484,6 @@ int quadd_hrt_start(void) reset_cpu_ctx(); - err = start_instr(); - if (err) { - pr_err("error: start_instr is failed\n"); - return err; - } - put_header(); if (ctx->pl310) @@ -563,7 +510,6 @@ void quadd_hrt_stop(void) quadd_ma_stop(&hrt); hrt.active = 0; - stop_instr(); atomic64_set(&hrt.counter_samples, 0); @@ -575,7 +521,6 @@ void quadd_hrt_deinit(void) if (hrt.active) quadd_hrt_stop(); - deinit_instr(); free_percpu(hrt.cpu_ctx); } @@ -622,8 +567,5 @@ struct quadd_hrt_ctx *quadd_hrt_init(struct quadd_ctx *ctx) init_hrtimer(cpu_ctx); } - if (init_instr()) - return NULL; - return &hrt; } diff --git a/drivers/misc/tegra-profiler/hrt.h b/drivers/misc/tegra-profiler/hrt.h index f113b8846a02..7eff30a6ec85 100644 --- a/drivers/misc/tegra-profiler/hrt.h +++ b/drivers/misc/tegra-profiler/hrt.h @@ -23,7 +23,6 @@ #include <linux/hrtimer.h> #include <linux/limits.h> -#include <linux/kprobes.h> #include "backtrace.h" @@ -53,9 +52,6 @@ struct quadd_hrt_ctx { struct quadd_cpu_context * __percpu cpu_ctx; u64 sample_period; - struct kprobe kp_in; - /* struct kinstr ki_out; */ - struct quadd_ctx *quadd_ctx; int active; diff --git a/drivers/misc/tegra-profiler/ma.c b/drivers/misc/tegra-profiler/ma.c index 2021954ace58..d561a2411c5a 100644 --- a/drivers/misc/tegra-profiler/ma.c +++ b/drivers/misc/tegra-profiler/ma.c @@ -19,6 +19,7 @@ #include <linux/module.h> #include <linux/mm.h> #include <linux/timer.h> +#include <linux/sched.h> #include <linux/tegra_profiler.h> diff --git a/drivers/misc/tegra-profiler/main.c b/drivers/misc/tegra-profiler/main.c index 823fa4db82cc..2b84dd036d81 100644 --- a/drivers/misc/tegra-profiler/main.c +++ b/drivers/misc/tegra-profiler/main.c @@ -19,6 +19,7 @@ #include <linux/init.h> #include <linux/module.h> #include <linux/err.h> +#include <linux/sched.h> #include <linux/tegra_profiler.h> diff --git a/drivers/misc/tegra-profiler/mmap.c b/drivers/misc/tegra-profiler/mmap.c index 370508b84f2b..2b73e5cd9c0a 100644 --- a/drivers/misc/tegra-profiler/mmap.c +++ b/drivers/misc/tegra-profiler/mmap.c @@ -22,6 +22,7 @@ #include <linux/fs.h> #include <linux/slab.h> #include <linux/err.h> +#include <linux/sched.h> #include <linux/tegra_profiler.h> @@ -145,6 +146,7 @@ char *quadd_get_mmap(struct quadd_cpu_context *cpu_ctx, break; } } else { +#ifdef CONFIG_MODULES struct module *mod; preempt_disable(); @@ -159,6 +161,7 @@ char *quadd_get_mmap(struct quadd_cpu_context *cpu_ctx, sample->pgoff = 0; } } +#endif } if (file_name) { diff --git a/drivers/misc/tegra-profiler/version.h b/drivers/misc/tegra-profiler/version.h index 3c03b2978711..8d2eec0e2c2d 100644 --- a/drivers/misc/tegra-profiler/version.h +++ b/drivers/misc/tegra-profiler/version.h @@ -18,7 +18,7 @@ #ifndef __QUADD_VERSION_H #define __QUADD_VERSION_H -#define QUADD_MODULE_VERSION "1.30" +#define QUADD_MODULE_VERSION "1.31" #define QUADD_MODULE_BRANCH "Dev" #endif /* __QUADD_VERSION_H */ diff --git a/include/linux/tegra_profiler.h b/include/linux/tegra_profiler.h index e8f17ad75792..5840ba3a8824 100644 --- a/include/linux/tegra_profiler.h +++ b/include/linux/tegra_profiler.h @@ -305,4 +305,33 @@ struct quadd_module_version { #pragma pack(pop) +#ifdef CONFIG_TEGRA_PROFILER +extern void __quadd_task_sched_in(struct task_struct *prev, + struct task_struct *task); +extern void __quadd_task_sched_out(struct task_struct *prev, + struct task_struct *next); + +static inline void quadd_task_sched_in(struct task_struct *prev, + struct task_struct *task) +{ + __quadd_task_sched_in(prev, task); +} + +static inline void quadd_task_sched_out(struct task_struct *prev, + struct task_struct *next) +{ + __quadd_task_sched_out(prev, next); +} +#else +static inline void quadd_task_sched_in(struct task_struct *prev, + struct task_struct *task) +{ +} + +static inline void quadd_task_sched_out(struct task_struct *prev, + struct task_struct *next) +{ +} +#endif + #endif /* __TEGRA_PROFILER_H */ diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 8fbbe9cfa1c9..872cf2e019df 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -72,6 +72,7 @@ #include <linux/slab.h> #include <linux/init_task.h> #include <linux/binfmts.h> +#include <linux/tegra_profiler.h> #include <asm/switch_to.h> #include <asm/tlb.h> @@ -1914,6 +1915,7 @@ prepare_task_switch(struct rq *rq, struct task_struct *prev, { sched_info_switch(prev, next); perf_event_task_sched_out(prev, next); + quadd_task_sched_out(prev, next); fire_sched_out_preempt_notifiers(prev, next); prepare_lock_switch(rq, next); prepare_arch_switch(next); @@ -1960,6 +1962,7 @@ static void finish_task_switch(struct rq *rq, struct task_struct *prev) local_irq_disable(); #endif /* __ARCH_WANT_INTERRUPTS_ON_CTXSW */ perf_event_task_sched_in(prev, current); + quadd_task_sched_in(prev, current); #ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW local_irq_enable(); #endif /* __ARCH_WANT_INTERRUPTS_ON_CTXSW */ |