From: Igor Nabirushkin Date: Wed, 5 Nov 2014 17:10:43 +0000 (+0400) Subject: misc: tegra-profiler: add lower bound of memory X-Git-Tag: tegra-l4t-r21-er-2015-02-02~5 X-Git-Url: http://rtime.felk.cvut.cz/gitweb/sojka/nv-tegra/linux-3.10.git/commitdiff_plain/7bfbc9fa064adf129312e1f37e60ec5f8d17e9ee misc: tegra-profiler: add lower bound of memory Tegra Profiler: add lower bound of memory for unwinding. Bug 1574379 Bug 1598009 Change-Id: Ia3c412caa0c2adfe603c08b3916bd57f3ea14255 Signed-off-by: Igor Nabirushkin Reviewed-on: http://git-master/r/594457 (cherry picked from commit e94dc4b70c045322c27d83fbe56a3c9690258443) Reviewed-on: http://git-master/r/672029 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Venkat Moganty --- diff --git a/drivers/misc/tegra-profiler/backtrace.c b/drivers/misc/tegra-profiler/backtrace.c index e9f01471a59..5c03114ee75 100644 --- a/drivers/misc/tegra-profiler/backtrace.c +++ b/drivers/misc/tegra-profiler/backtrace.c @@ -26,6 +26,7 @@ #include "backtrace.h" #include "eh_unwind.h" #include "dwarf_unwind.h" +#include "hrt.h" static inline int is_thumb_mode(struct pt_regs *regs) @@ -92,7 +93,9 @@ int quadd_callchain_store(struct quadd_callchain *cc, unsigned long ip, unsigned int type) { - if (!validate_pc_addr(ip, sizeof(unsigned long))) { + unsigned long low_addr = cc->hrt->low_addr; + + if (ip < low_addr || !validate_pc_addr(ip, sizeof(unsigned long))) { cc->unw_rc = QUADD_URC_PC_INCORRECT; return 0; } diff --git a/drivers/misc/tegra-profiler/backtrace.h b/drivers/misc/tegra-profiler/backtrace.h index 23348043654..3046ac60fdb 100644 --- a/drivers/misc/tegra-profiler/backtrace.h +++ b/drivers/misc/tegra-profiler/backtrace.h @@ -25,6 +25,8 @@ #define QUADD_UNW_TYPES_SIZE \ DIV_ROUND_UP(QUADD_MAX_STACK_DEPTH * 4, sizeof(u32) * BITS_PER_BYTE) +struct quadd_hrt_ctx; + struct quadd_callchain { int nr; @@ -43,6 +45,8 @@ struct quadd_callchain { unsigned long curr_sp; unsigned long curr_fp; unsigned long curr_pc; + + struct quadd_hrt_ctx *hrt; }; struct quadd_ctx; diff --git a/drivers/misc/tegra-profiler/hrt.c b/drivers/misc/tegra-profiler/hrt.c index e781147367c..1850f3f8003 100644 --- a/drivers/misc/tegra-profiler/hrt.c +++ b/drivers/misc/tegra-profiler/hrt.c @@ -720,7 +720,7 @@ struct quadd_hrt_ctx *quadd_hrt_init(struct quadd_ctx *ctx) if (!hrt.cpu_ctx) return ERR_PTR(-ENOMEM); - for (cpu_id = 0; cpu_id < nr_cpu_ids; cpu_id++) { + for_each_possible_cpu(cpu_id) { cpu_ctx = per_cpu_ptr(hrt.cpu_ctx, cpu_id); atomic_set(&cpu_ctx->nr_active, 0); @@ -728,6 +728,8 @@ struct quadd_hrt_ctx *quadd_hrt_init(struct quadd_ctx *ctx) cpu_ctx->active_thread.pid = -1; cpu_ctx->active_thread.tgid = -1; + cpu_ctx->cc.hrt = &hrt; + init_hrtimer(cpu_ctx); } diff --git a/drivers/misc/tegra-profiler/hrt.h b/drivers/misc/tegra-profiler/hrt.h index baff679550e..47662fbf768 100644 --- a/drivers/misc/tegra-profiler/hrt.h +++ b/drivers/misc/tegra-profiler/hrt.h @@ -43,7 +43,9 @@ struct timecounter; struct quadd_hrt_ctx { struct quadd_cpu_context * __percpu cpu_ctx; + u64 sample_period; + unsigned long low_addr; struct quadd_ctx *quadd_ctx; diff --git a/drivers/misc/tegra-profiler/main.c b/drivers/misc/tegra-profiler/main.c index ff4bdd18375..1e967a419be 100644 --- a/drivers/misc/tegra-profiler/main.c +++ b/drivers/misc/tegra-profiler/main.c @@ -167,13 +167,13 @@ validate_freq(unsigned int freq) static int set_parameters(struct quadd_parameters *p, uid_t *debug_app_uid) { - int i, err; + int i, err, uid = 0; int pmu_events_id[QUADD_MAX_COUNTERS]; int pl310_events_id; int nr_pmu = 0, nr_pl310 = 0; - int uid = 0; struct task_struct *task; unsigned int extra; + u64 *low_addr_p; if (!validate_freq(p->freq)) { pr_err("%s: incorrect frequency: %u\n", __func__, p->freq); @@ -297,6 +297,10 @@ set_parameters(struct quadd_parameters *p, uid_t *debug_app_uid) if (extra & QUADD_PARAM_EXTRA_BT_MIXED) pr_info("unwinding: mixed mode\n"); + low_addr_p = (u64 *)&p->reserved[QUADD_PARAM_IDX_BT_LOWER_BOUND]; + ctx.hrt->low_addr = (unsigned long)*low_addr_p; + pr_info("bt lower bound: %#lx\n", ctx.hrt->low_addr); + err = quadd_unwind_start(task); if (err) return err; diff --git a/drivers/misc/tegra-profiler/version.h b/drivers/misc/tegra-profiler/version.h index e6238bb56a7..1c12e5afb60 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.82" +#define QUADD_MODULE_VERSION "1.83" #define QUADD_MODULE_BRANCH "Dev" #endif /* __QUADD_VERSION_H */ diff --git a/include/linux/tegra_profiler.h b/include/linux/tegra_profiler.h index affbec553a6..ad62d9a8e91 100644 --- a/include/linux/tegra_profiler.h +++ b/include/linux/tegra_profiler.h @@ -20,7 +20,7 @@ #include #define QUADD_SAMPLES_VERSION 30 -#define QUADD_IO_VERSION 14 +#define QUADD_IO_VERSION 15 #define QUADD_IO_VERSION_DYNAMIC_RB 5 #define QUADD_IO_VERSION_RB_MAX_FILL_COUNT 6 @@ -32,6 +32,7 @@ #define QUADD_IO_VERSION_EXTABLES_MMAP 12 #define QUADD_IO_VERSION_ARCH_TIMER_OPT 13 #define QUADD_IO_VERSION_DATA_MMAP 14 +#define QUADD_IO_VERSION_BT_LOWER_BOUND 15 #define QUADD_SAMPLE_VERSION_THUMB_MODE_FLAG 17 #define QUADD_SAMPLE_VERSION_GROUP_SAMPLES 18 @@ -345,6 +346,7 @@ struct quadd_record_data { enum { QUADD_PARAM_IDX_SIZE_OF_RB = 0, QUADD_PARAM_IDX_EXTRA = 1, + QUADD_PARAM_IDX_BT_LOWER_BOUND = 2, }; #define QUADD_PARAM_EXTRA_GET_MMAP (1 << 0)