]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
misc: tegra-profiler: fix debug preempt warnings origin/l4t/l4t-r21 tegra-l4t-r21-er-2015-02-02 tegra-l4t-r21.3
authorIgor Nabirushkin <inabirushkin@nvidia.com>
Mon, 29 Dec 2014 08:16:30 +0000 (12:16 +0400)
committerWinnie Hsu <whsu@nvidia.com>
Fri, 30 Jan 2015 06:05:27 +0000 (22:05 -0800)
Tegra Profiler: fix warnings with CONFIG_DEBUG_PREEMPT=y

* Add the missing preempt_disable/enable() pairs in start/stop ioctls.
* Untie mmap and some other samples from the current cpu.

Bug 200067410
Bug 1598009

Change-Id: I9f03facf3a0ecee20432019ea8094a349c7897d1
Signed-off-by: Igor Nabirushkin <inabirushkin@nvidia.com>
Reviewed-on: http://git-master/r/668123
(cherry picked from commit ee3374eb9983d1ccadbf3a54c977d3e6db97ec4a)
Reviewed-on: http://git-master/r/672042
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Venkat Moganty <vmoganty@nvidia.com>
drivers/misc/tegra-profiler/debug.c
drivers/misc/tegra-profiler/hrt.c
drivers/misc/tegra-profiler/hrt.h
drivers/misc/tegra-profiler/main.c
drivers/misc/tegra-profiler/mmap.c
drivers/misc/tegra-profiler/version.h

index b7acd9499934bcccbf6586d548879d55e40c8f3d..50c3d1d6c041c96e794af716d557eac9fa8498e7 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * drivers/misc/tegra-profiler/debug.c
  *
- * Copyright (c) 2014, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 2015, 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,
@@ -68,7 +68,7 @@ void qm_debug_handler_sample(struct pt_regs *regs)
 
        s->type = QM_DEBUG_SAMPLE_TYPE_TIMER_HANDLE;
 
-       quadd_put_sample(&record, NULL, 0);
+       quadd_put_sample_this_cpu(&record, NULL, 0);
 }
 
 void qm_debug_timer_forward(struct pt_regs *regs, u64 period)
@@ -80,7 +80,7 @@ void qm_debug_timer_forward(struct pt_regs *regs, u64 period)
 
        s->type = QM_DEBUG_SAMPLE_TYPE_TIMER_FORWARD;
 
-       quadd_put_sample(&record, NULL, 0);
+       quadd_put_sample_this_cpu(&record, NULL, 0);
 }
 
 void qm_debug_timer_start(struct pt_regs *regs, u64 period)
@@ -92,7 +92,7 @@ void qm_debug_timer_start(struct pt_regs *regs, u64 period)
 
        s->type = QM_DEBUG_SAMPLE_TYPE_TIMER_START;
 
-       quadd_put_sample(&record, NULL, 0);
+       quadd_put_sample_this_cpu(&record, NULL, 0);
 }
 
 void qm_debug_timer_cancel(void)
@@ -104,7 +104,7 @@ void qm_debug_timer_cancel(void)
 
        s->type = QM_DEBUG_SAMPLE_TYPE_TIMER_CANCEL;
 
-       quadd_put_sample(&record, NULL, 0);
+       quadd_put_sample_this_cpu(&record, NULL, 0);
 }
 
 void
@@ -124,7 +124,7 @@ qm_debug_task_sched_in(pid_t prev_pid, pid_t current_pid, int prev_nr_active)
        vec.base = &prev_nr_active;
        vec.len = s->extra_length = sizeof(prev_nr_active);
 
-       quadd_put_sample(&record, &vec, 1);
+       quadd_put_sample_this_cpu(&record, &vec, 1);
 }
 
 void qm_debug_read_counter(int event_id, u32 prev_val, u32 val)
@@ -143,7 +143,7 @@ void qm_debug_read_counter(int event_id, u32 prev_val, u32 val)
        vec.base = &val;
        vec.len = s->extra_length = sizeof(val);
 
-       quadd_put_sample(&record, &vec, 1);
+       quadd_put_sample_this_cpu(&record, &vec, 1);
 }
 
 void qm_debug_start_source(int source_type)
@@ -156,7 +156,7 @@ void qm_debug_start_source(int source_type)
        s->type = QM_DEBUG_SAMPLE_TYPE_SOURCE_START;
        s->extra_value[0] = source_type;
 
-       quadd_put_sample(&record, NULL, 0);
+       quadd_put_sample_this_cpu(&record, NULL, 0);
 }
 
 void qm_debug_stop_source(int source_type)
@@ -169,7 +169,7 @@ void qm_debug_stop_source(int source_type)
        s->type = QM_DEBUG_SAMPLE_TYPE_SOURCE_STOP;
        s->extra_value[0] = source_type;
 
-       quadd_put_sample(&record, NULL, 0);
+       quadd_put_sample_this_cpu(&record, NULL, 0);
 }
 
 #endif /* QM_DEBUG_SAMPLES_ENABLE */
index b7bd00c795ace63fd9718420f17aa5fb9b7291c3..8081a03cd6b1bb9980c6dc1545f13fbe44626b68 100644 (file)
@@ -120,9 +120,9 @@ u64 quadd_get_time(void)
 }
 
 static void
-put_sample_cpu(struct quadd_record_data *data,
-              struct quadd_iovec *vec,
-              int vec_count, int cpu_id)
+__put_sample(struct quadd_record_data *data,
+            struct quadd_iovec *vec,
+            int vec_count, int cpu_id)
 {
        ssize_t err;
        struct quadd_comm_data_interface *comm = hrt.quadd_ctx->comm;
@@ -134,11 +134,18 @@ put_sample_cpu(struct quadd_record_data *data,
        atomic64_inc(&hrt.counter_samples);
 }
 
+void
+quadd_put_sample_this_cpu(struct quadd_record_data *data,
+                        struct quadd_iovec *vec, int vec_count)
+{
+       __put_sample(data, vec, vec_count, -1);
+}
+
 void
 quadd_put_sample(struct quadd_record_data *data,
                 struct quadd_iovec *vec, int vec_count)
 {
-       put_sample_cpu(data, vec, vec_count, -1);
+       __put_sample(data, vec, vec_count, 0);
 }
 
 static void put_header(void)
@@ -202,7 +209,7 @@ static void put_header(void)
        vec.len = nr_events * sizeof(events[0]);
 
        for_each_possible_cpu(cpu_id)
-               put_sample_cpu(&record, &vec, 1, cpu_id);
+               __put_sample(&record, &vec, 1, cpu_id);
 }
 
 static void
@@ -227,7 +234,7 @@ put_sched_sample(struct task_struct *task, int is_sched_in)
        s->data[0] = 0;
        s->data[1] = 0;
 
-       quadd_put_sample(&record, NULL, 0);
+       quadd_put_sample_this_cpu(&record, NULL, 0);
 }
 
 static int get_sample_data(struct quadd_sample_data *sample,
@@ -461,7 +468,7 @@ read_all_sources(struct pt_regs *regs, struct task_struct *task)
                s->state = 0;
        }
 
-       quadd_put_sample(&record_data, vec, vec_idx);
+       quadd_put_sample_this_cpu(&record_data, vec, vec_idx);
 }
 
 static inline int
index 9fd9c97d238a27ac0f082bb87a4998a1bbf982e5..172e2f1719dd99df9a9e53c283bfc814b00dda17 100644 (file)
@@ -83,8 +83,12 @@ void quadd_hrt_deinit(void);
 int quadd_hrt_start(void);
 void quadd_hrt_stop(void);
 
-void quadd_put_sample(struct quadd_record_data *data,
-                     struct quadd_iovec *vec, int vec_count);
+void
+quadd_put_sample_cur_cpu(struct quadd_record_data *data,
+                        struct quadd_iovec *vec, int vec_count);
+void
+quadd_put_sample(struct quadd_record_data *data,
+                struct quadd_iovec *vec, int vec_count);
 
 void quadd_hrt_get_state(struct quadd_module_state *state);
 u64 quadd_get_time(void);
index f0116af4903553711d1588f590bf72b667868270..0f1237fe57f4ea04f677df5195827eb96d27bf34 100644 (file)
@@ -85,6 +85,8 @@ static int start(void)
                return -EBUSY;
        }
 
+       preempt_disable();
+
        if (!atomic_cmpxchg(&ctx.started, 0, 1)) {
                if (ctx.pmu) {
                        err = ctx.pmu->enable();
@@ -117,16 +119,21 @@ static int start(void)
                }
        }
 
+       preempt_enable();
        return 0;
 
 errout:
        atomic_set(&ctx.started, 0);
        tegra_profiler_unlock();
+       preempt_enable();
+
        return err;
 }
 
 static void stop(void)
 {
+       preempt_disable();
+
        if (atomic_cmpxchg(&ctx.started, 1, 0)) {
                quadd_hrt_stop();
 
@@ -143,6 +150,8 @@ static void stop(void)
 
                tegra_profiler_unlock();
        }
+
+       preempt_enable();
 }
 
 static inline int is_event_supported(struct source_info *si, int event)
@@ -180,13 +189,7 @@ set_parameters(struct quadd_parameters *p, uid_t *debug_app_uid)
                return -EINVAL;
        }
 
-       ctx.param.freq = p->freq;
-       ctx.param.ma_freq = p->ma_freq;
-       ctx.param.backtrace = p->backtrace;
-       ctx.param.use_freq = p->use_freq;
-       ctx.param.system_wide = p->system_wide;
-       ctx.param.power_rate_freq = p->power_rate_freq;
-       ctx.param.debug_samples = p->debug_samples;
+       ctx.param = *p;
 
        for (i = 0; i < ARRAY_SIZE(p->reserved); i++)
                ctx.param.reserved[i] = p->reserved[i];
index 9e3e05f305a561540f05f3af4412c9d6124fdcd3..2347047d98736fc84e3fda87e0a29a907d3beff3 100644 (file)
@@ -76,7 +76,7 @@ void quadd_process_mmap(struct vm_area_struct *vma, pid_t pid)
        if (!(vma->vm_flags & VM_EXEC))
                return;
 
-       tmp_buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
+       tmp_buf = kzalloc(PATH_MAX + sizeof(u64), GFP_ATOMIC);
        if (!tmp_buf)
                return;
 
@@ -164,7 +164,7 @@ int quadd_get_current_mmap(pid_t pid)
 
        pr_info("Get mapped memory objects\n");
 
-       tmp_buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
+       tmp_buf = kzalloc(PATH_MAX + sizeof(u64), GFP_ATOMIC);
        if (!tmp_buf)
                return -ENOMEM;
 
index c96c50756d37c26f31d33663a426d4e4deea8c90..7b3fc20f6334b2c7d8f23347a6775706216cbaa2 100644 (file)
@@ -18,7 +18,7 @@
 #ifndef __QUADD_VERSION_H
 #define __QUADD_VERSION_H
 
-#define QUADD_MODULE_VERSION           "1.87"
+#define QUADD_MODULE_VERSION           "1.88"
 #define QUADD_MODULE_BRANCH            "Dev"
 
 #endif /* __QUADD_VERSION_H */