diff options
author | Igor Nabirushkin <inabirushkin@nvidia.com> | 2014-01-26 23:46:41 +0400 |
---|---|---|
committer | Riham Haidar <rhaidar@nvidia.com> | 2014-02-19 16:09:38 -0800 |
commit | 7e3458cef594184e0244627a3f40f4a22cfeedf5 (patch) | |
tree | 07366d9b63f49fab0ab8ed80d9da6287ce24bd80 /drivers | |
parent | 056f21a1bf29856cf4619439631d3c7d353ff42d (diff) |
misc: tegra-profiler: add sched_out sampling
Tegra Profiler: add sampling at the ending of the time slices
Bug 1447648
Change-Id: I03bea8b9d28aef7aaa1d2b676baa19ddd1247c1d
Signed-off-by: Igor Nabirushkin <inabirushkin@nvidia.com>
Reviewed-on: http://git-master/r/365857
(cherry picked from commit f926e880ddaf6197e988b024ad9ef962748efc5e)
Reviewed-on: http://git-master/r/368211
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Tested-by: Maxim Morin <mmorin@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/misc/tegra-profiler/hrt.c | 60 | ||||
-rw-r--r-- | drivers/misc/tegra-profiler/hrt.h | 7 | ||||
-rw-r--r-- | drivers/misc/tegra-profiler/version.h | 2 |
3 files changed, 8 insertions, 61 deletions
diff --git a/drivers/misc/tegra-profiler/hrt.c b/drivers/misc/tegra-profiler/hrt.c index 04fcf1316f11..945708cb3fef 100644 --- a/drivers/misc/tegra-profiler/hrt.c +++ b/drivers/misc/tegra-profiler/hrt.c @@ -42,10 +42,6 @@ static struct quadd_hrt_ctx hrt; static void read_all_sources(struct pt_regs *regs, pid_t pid); -static void sample_time_prepare(void); -static void sample_time_finish(void); -static void sample_time_reset(struct quadd_cpu_context *cpu_ctx); - struct hrt_event_value { int event_id; u32 value; @@ -62,11 +58,8 @@ static enum hrtimer_restart hrtimer_handler(struct hrtimer *hrtimer) qm_debug_handler_sample(regs); - if (regs) { - sample_time_prepare(); + if (regs) read_all_sources(regs, -1); - sample_time_finish(); - } hrtimer_forward_now(hrtimer, ns_to_ktime(hrt.sample_period)); qm_debug_timer_forward(regs, hrt.sample_period); @@ -78,8 +71,6 @@ static void start_hrtimer(struct quadd_cpu_context *cpu_ctx) { u64 period = hrt.sample_period; - sample_time_reset(cpu_ctx); - hrtimer_start(&cpu_ctx->hrtimer, ns_to_ktime(period), HRTIMER_MODE_REL_PINNED); qm_debug_timer_start(NULL, period); @@ -93,8 +84,6 @@ static void cancel_hrtimer(struct quadd_cpu_context *cpu_ctx) static void init_hrtimer(struct quadd_cpu_context *cpu_ctx) { - sample_time_reset(cpu_ctx); - hrtimer_init(&cpu_ctx->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); cpu_ctx->hrtimer.function = hrtimer_handler; } @@ -107,44 +96,6 @@ u64 quadd_get_time(void) return timespec_to_ns(&ts); } -static u64 get_sample_time(void) -{ -#ifndef QUADD_USE_CORRECT_SAMPLE_TS - return quadd_get_time(); -#else - struct quadd_cpu_context *cpu_ctx = this_cpu_ptr(hrt.cpu_ctx); - return cpu_ctx->current_time; -#endif -} - -static void sample_time_prepare(void) -{ -#ifdef QUADD_USE_CORRECT_SAMPLE_TS - struct quadd_cpu_context *cpu_ctx = this_cpu_ptr(hrt.cpu_ctx); - - if (cpu_ctx->prev_time == ULLONG_MAX) - cpu_ctx->current_time = quadd_get_time(); - else - cpu_ctx->current_time = cpu_ctx->prev_time + hrt.sample_period; -#endif -} - -static void sample_time_finish(void) -{ -#ifdef QUADD_USE_CORRECT_SAMPLE_TS - struct quadd_cpu_context *cpu_ctx = this_cpu_ptr(hrt.cpu_ctx); - cpu_ctx->prev_time = cpu_ctx->current_time; -#endif -} - -static void sample_time_reset(struct quadd_cpu_context *cpu_ctx) -{ -#ifdef QUADD_USE_CORRECT_SAMPLE_TS - cpu_ctx->prev_time = ULLONG_MAX; - cpu_ctx->current_time = ULLONG_MAX; -#endif -} - static void put_header(void) { int nr_events = 0, max_events = QUADD_MAX_COUNTERS; @@ -233,7 +184,7 @@ static int get_sample_data(struct quadd_sample_data *sample, else sample->ip = instruction_pointer(regs); - sample->time = get_sample_time(); + sample->time = quadd_get_time(); sample->reserved = 0; if (pid > 0) { @@ -449,6 +400,7 @@ void __quadd_task_sched_out(struct task_struct *prev, struct task_struct *next) { int n, prev_flag; + struct pt_regs *user_regs; 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); */ @@ -465,6 +417,10 @@ void __quadd_task_sched_out(struct task_struct *prev, prev_flag = is_profile_process(prev->tgid); if (prev_flag) { + user_regs = task_pt_regs(prev); + if (user_regs) + read_all_sources(user_regs, prev->pid); + n = remove_active_thread(cpu_ctx, prev->pid); atomic_sub(n, &cpu_ctx->nr_active); @@ -492,8 +448,6 @@ static void reset_cpu_ctx(void) t_data->pid = -1; t_data->tgid = -1; - - sample_time_reset(cpu_ctx); } } diff --git a/drivers/misc/tegra-profiler/hrt.h b/drivers/misc/tegra-profiler/hrt.h index 1e3eb72fa04c..ed8c99a391c7 100644 --- a/drivers/misc/tegra-profiler/hrt.h +++ b/drivers/misc/tegra-profiler/hrt.h @@ -26,8 +26,6 @@ #include "backtrace.h" -#define QUADD_USE_CORRECT_SAMPLE_TS 1 - struct quadd_thread_data { pid_t pid; pid_t tgid; @@ -41,11 +39,6 @@ struct quadd_cpu_context { struct quadd_thread_data active_thread; atomic_t nr_active; - -#ifdef QUADD_USE_CORRECT_SAMPLE_TS - u64 prev_time; - u64 current_time; -#endif }; struct quadd_hrt_ctx { diff --git a/drivers/misc/tegra-profiler/version.h b/drivers/misc/tegra-profiler/version.h index 090ff1bf3d6f..b90b524339b7 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.42" +#define QUADD_MODULE_VERSION "1.43" #define QUADD_MODULE_BRANCH "Dev" #endif /* __QUADD_VERSION_H */ |