diff options
Diffstat (limited to 'drivers/oprofile')
-rw-r--r-- | drivers/oprofile/oprof.c | 58 | ||||
-rw-r--r-- | drivers/oprofile/oprof.h | 4 | ||||
-rw-r--r-- | drivers/oprofile/oprofile_files.c | 39 |
3 files changed, 6 insertions, 95 deletions
diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c index b2fa5df64a62..2c645170f06e 100644 --- a/drivers/oprofile/oprof.c +++ b/drivers/oprofile/oprof.c | |||
@@ -12,8 +12,6 @@ | |||
12 | #include <linux/init.h> | 12 | #include <linux/init.h> |
13 | #include <linux/oprofile.h> | 13 | #include <linux/oprofile.h> |
14 | #include <linux/moduleparam.h> | 14 | #include <linux/moduleparam.h> |
15 | #include <linux/workqueue.h> | ||
16 | #include <linux/time.h> | ||
17 | #include <asm/mutex.h> | 15 | #include <asm/mutex.h> |
18 | 16 | ||
19 | #include "oprof.h" | 17 | #include "oprof.h" |
@@ -21,18 +19,13 @@ | |||
21 | #include "cpu_buffer.h" | 19 | #include "cpu_buffer.h" |
22 | #include "buffer_sync.h" | 20 | #include "buffer_sync.h" |
23 | #include "oprofile_stats.h" | 21 | #include "oprofile_stats.h" |
24 | |||
25 | static unsigned long is_setup; | ||
26 | static void switch_worker(struct work_struct *work); | ||
27 | static DECLARE_DELAYED_WORK(switch_work, switch_worker); | ||
28 | static DEFINE_MUTEX(start_mutex); | ||
29 | 22 | ||
30 | struct oprofile_operations oprofile_ops; | 23 | struct oprofile_operations oprofile_ops; |
31 | 24 | ||
32 | unsigned long timeout_jiffies; | ||
33 | unsigned long oprofile_started; | 25 | unsigned long oprofile_started; |
34 | unsigned long backtrace_depth; | 26 | unsigned long backtrace_depth; |
35 | /* Multiplexing defaults at 1 msec*/ | 27 | static unsigned long is_setup; |
28 | static DEFINE_MUTEX(start_mutex); | ||
36 | 29 | ||
37 | /* timer | 30 | /* timer |
38 | 0 - use performance monitoring hardware if available | 31 | 0 - use performance monitoring hardware if available |
@@ -94,16 +87,6 @@ out: | |||
94 | return err; | 87 | return err; |
95 | } | 88 | } |
96 | 89 | ||
97 | static void start_switch_worker(void) | ||
98 | { | ||
99 | schedule_delayed_work(&switch_work, timeout_jiffies); | ||
100 | } | ||
101 | |||
102 | static void switch_worker(struct work_struct *work) | ||
103 | { | ||
104 | if (!oprofile_ops.switch_events()) | ||
105 | start_switch_worker(); | ||
106 | } | ||
107 | 90 | ||
108 | /* Actually start profiling (echo 1>/dev/oprofile/enable) */ | 91 | /* Actually start profiling (echo 1>/dev/oprofile/enable) */ |
109 | int oprofile_start(void) | 92 | int oprofile_start(void) |
@@ -111,6 +94,7 @@ int oprofile_start(void) | |||
111 | int err = -EINVAL; | 94 | int err = -EINVAL; |
112 | 95 | ||
113 | mutex_lock(&start_mutex); | 96 | mutex_lock(&start_mutex); |
97 | |||
114 | if (!is_setup) | 98 | if (!is_setup) |
115 | goto out; | 99 | goto out; |
116 | 100 | ||
@@ -124,9 +108,6 @@ int oprofile_start(void) | |||
124 | if ((err = oprofile_ops.start())) | 108 | if ((err = oprofile_ops.start())) |
125 | goto out; | 109 | goto out; |
126 | 110 | ||
127 | if (oprofile_ops.switch_events) | ||
128 | start_switch_worker(); | ||
129 | |||
130 | oprofile_started = 1; | 111 | oprofile_started = 1; |
131 | out: | 112 | out: |
132 | mutex_unlock(&start_mutex); | 113 | mutex_unlock(&start_mutex); |
@@ -142,7 +123,6 @@ void oprofile_stop(void) | |||
142 | goto out; | 123 | goto out; |
143 | oprofile_ops.stop(); | 124 | oprofile_ops.stop(); |
144 | oprofile_started = 0; | 125 | oprofile_started = 0; |
145 | cancel_delayed_work_sync(&switch_work); | ||
146 | /* wake up the daemon to read what remains */ | 126 | /* wake up the daemon to read what remains */ |
147 | wake_up_buffer_waiter(); | 127 | wake_up_buffer_waiter(); |
148 | out: | 128 | out: |
@@ -175,32 +155,6 @@ post_sync: | |||
175 | mutex_unlock(&start_mutex); | 155 | mutex_unlock(&start_mutex); |
176 | } | 156 | } |
177 | 157 | ||
178 | /* User inputs in ms, converts to jiffies */ | ||
179 | int oprofile_set_timeout(unsigned long val_msec) | ||
180 | { | ||
181 | int err = 0; | ||
182 | |||
183 | mutex_lock(&start_mutex); | ||
184 | |||
185 | if (oprofile_started) { | ||
186 | err = -EBUSY; | ||
187 | goto out; | ||
188 | } | ||
189 | |||
190 | if (!oprofile_ops.switch_events) { | ||
191 | err = -EINVAL; | ||
192 | goto out; | ||
193 | } | ||
194 | |||
195 | timeout_jiffies = msecs_to_jiffies(val_msec); | ||
196 | if (timeout_jiffies == MAX_JIFFY_OFFSET) | ||
197 | timeout_jiffies = msecs_to_jiffies(1); | ||
198 | |||
199 | out: | ||
200 | mutex_unlock(&start_mutex); | ||
201 | return err; | ||
202 | |||
203 | } | ||
204 | 158 | ||
205 | int oprofile_set_backtrace(unsigned long val) | 159 | int oprofile_set_backtrace(unsigned long val) |
206 | { | 160 | { |
@@ -225,16 +179,10 @@ out: | |||
225 | return err; | 179 | return err; |
226 | } | 180 | } |
227 | 181 | ||
228 | static void __init oprofile_switch_timer_init(void) | ||
229 | { | ||
230 | timeout_jiffies = msecs_to_jiffies(1); | ||
231 | } | ||
232 | |||
233 | static int __init oprofile_init(void) | 182 | static int __init oprofile_init(void) |
234 | { | 183 | { |
235 | int err; | 184 | int err; |
236 | 185 | ||
237 | oprofile_switch_timer_init(); | ||
238 | err = oprofile_arch_init(&oprofile_ops); | 186 | err = oprofile_arch_init(&oprofile_ops); |
239 | 187 | ||
240 | if (err < 0 || timer) { | 188 | if (err < 0 || timer) { |
diff --git a/drivers/oprofile/oprof.h b/drivers/oprofile/oprof.h index c4406a7366bb..18323650806e 100644 --- a/drivers/oprofile/oprof.h +++ b/drivers/oprofile/oprof.h | |||
@@ -27,8 +27,7 @@ extern unsigned long fs_buffer_watershed; | |||
27 | extern struct oprofile_operations oprofile_ops; | 27 | extern struct oprofile_operations oprofile_ops; |
28 | extern unsigned long oprofile_started; | 28 | extern unsigned long oprofile_started; |
29 | extern unsigned long backtrace_depth; | 29 | extern unsigned long backtrace_depth; |
30 | extern unsigned long timeout_jiffies; | 30 | |
31 | |||
32 | struct super_block; | 31 | struct super_block; |
33 | struct dentry; | 32 | struct dentry; |
34 | 33 | ||
@@ -36,6 +35,5 @@ void oprofile_create_files(struct super_block * sb, struct dentry * root); | |||
36 | void oprofile_timer_init(struct oprofile_operations * ops); | 35 | void oprofile_timer_init(struct oprofile_operations * ops); |
37 | 36 | ||
38 | int oprofile_set_backtrace(unsigned long depth); | 37 | int oprofile_set_backtrace(unsigned long depth); |
39 | int oprofile_set_timeout(unsigned long time); | ||
40 | 38 | ||
41 | #endif /* OPROF_H */ | 39 | #endif /* OPROF_H */ |
diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c index cc4f5a1f8ef2..ef953ba5ab6b 100644 --- a/drivers/oprofile/oprofile_files.c +++ b/drivers/oprofile/oprofile_files.c | |||
@@ -9,7 +9,6 @@ | |||
9 | 9 | ||
10 | #include <linux/fs.h> | 10 | #include <linux/fs.h> |
11 | #include <linux/oprofile.h> | 11 | #include <linux/oprofile.h> |
12 | #include <linux/jiffies.h> | ||
13 | 12 | ||
14 | #include "event_buffer.h" | 13 | #include "event_buffer.h" |
15 | #include "oprofile_stats.h" | 14 | #include "oprofile_stats.h" |
@@ -19,40 +18,6 @@ unsigned long fs_buffer_size = 131072; | |||
19 | unsigned long fs_cpu_buffer_size = 8192; | 18 | unsigned long fs_cpu_buffer_size = 8192; |
20 | unsigned long fs_buffer_watershed = 32768; /* FIXME: tune */ | 19 | unsigned long fs_buffer_watershed = 32768; /* FIXME: tune */ |
21 | 20 | ||
22 | static ssize_t timeout_read(struct file *file, char __user *buf, | ||
23 | size_t count, loff_t *offset) | ||
24 | { | ||
25 | return oprofilefs_ulong_to_user(jiffies_to_msecs(timeout_jiffies), | ||
26 | buf, count, offset); | ||
27 | } | ||
28 | |||
29 | |||
30 | static ssize_t timeout_write(struct file *file, char const __user *buf, | ||
31 | size_t count, loff_t *offset) | ||
32 | { | ||
33 | unsigned long val; | ||
34 | int retval; | ||
35 | |||
36 | if (*offset) | ||
37 | return -EINVAL; | ||
38 | |||
39 | retval = oprofilefs_ulong_from_user(&val, buf, count); | ||
40 | if (retval) | ||
41 | return retval; | ||
42 | |||
43 | retval = oprofile_set_timeout(val); | ||
44 | |||
45 | if (retval) | ||
46 | return retval; | ||
47 | return count; | ||
48 | } | ||
49 | |||
50 | static const struct file_operations timeout_fops = { | ||
51 | .read = timeout_read, | ||
52 | .write = timeout_write, | ||
53 | }; | ||
54 | |||
55 | |||
56 | static ssize_t depth_read(struct file * file, char __user * buf, size_t count, loff_t * offset) | 21 | static ssize_t depth_read(struct file * file, char __user * buf, size_t count, loff_t * offset) |
57 | { | 22 | { |
58 | return oprofilefs_ulong_to_user(backtrace_depth, buf, count, offset); | 23 | return oprofilefs_ulong_to_user(backtrace_depth, buf, count, offset); |
@@ -120,10 +85,11 @@ static ssize_t enable_write(struct file * file, char const __user * buf, size_t | |||
120 | 85 | ||
121 | if (*offset) | 86 | if (*offset) |
122 | return -EINVAL; | 87 | return -EINVAL; |
88 | |||
123 | retval = oprofilefs_ulong_from_user(&val, buf, count); | 89 | retval = oprofilefs_ulong_from_user(&val, buf, count); |
124 | if (retval) | 90 | if (retval) |
125 | return retval; | 91 | return retval; |
126 | 92 | ||
127 | if (val) | 93 | if (val) |
128 | retval = oprofile_start(); | 94 | retval = oprofile_start(); |
129 | else | 95 | else |
@@ -163,7 +129,6 @@ void oprofile_create_files(struct super_block * sb, struct dentry * root) | |||
163 | oprofilefs_create_file(sb, root, "cpu_type", &cpu_type_fops); | 129 | oprofilefs_create_file(sb, root, "cpu_type", &cpu_type_fops); |
164 | oprofilefs_create_file(sb, root, "backtrace_depth", &depth_fops); | 130 | oprofilefs_create_file(sb, root, "backtrace_depth", &depth_fops); |
165 | oprofilefs_create_file(sb, root, "pointer_size", &pointer_size_fops); | 131 | oprofilefs_create_file(sb, root, "pointer_size", &pointer_size_fops); |
166 | oprofilefs_create_file(sb, root, "timeout_ms", &timeout_fops); | ||
167 | oprofile_create_stats_files(sb, root); | 132 | oprofile_create_stats_files(sb, root); |
168 | if (oprofile_ops.create_files) | 133 | if (oprofile_ops.create_files) |
169 | oprofile_ops.create_files(sb, root); | 134 | oprofile_ops.create_files(sb, root); |