diff options
| author | Ingo Molnar <mingo@elte.hu> | 2008-05-12 15:20:49 -0400 |
|---|---|---|
| committer | Thomas Gleixner <tglx@linutronix.de> | 2008-05-23 17:40:22 -0400 |
| commit | d618b3e6e50970a6248ac857653fdd49bcd3c045 (patch) | |
| tree | 1bf01a4c4092b9db9b3690a980b5260170ec6567 /kernel/trace | |
| parent | 9f6b4e3f4a24f2590f1c96f117fc45fbea9b0fa4 (diff) | |
ftrace: sysprof updates
make the sample period configurable.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/trace')
| -rw-r--r-- | kernel/trace/trace.c | 3 | ||||
| -rw-r--r-- | kernel/trace/trace.h | 2 | ||||
| -rw-r--r-- | kernel/trace/trace_sysprof.c | 70 |
3 files changed, 73 insertions, 2 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 3271916ff033..95b7c48a9a1d 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
| @@ -2800,6 +2800,9 @@ static __init void tracer_init_debugfs(void) | |||
| 2800 | pr_warning("Could not create debugfs " | 2800 | pr_warning("Could not create debugfs " |
| 2801 | "'dyn_ftrace_total_info' entry\n"); | 2801 | "'dyn_ftrace_total_info' entry\n"); |
| 2802 | #endif | 2802 | #endif |
| 2803 | #ifdef CONFIG_SYSPROF_TRACER | ||
| 2804 | init_tracer_sysprof_debugfs(d_tracer); | ||
| 2805 | #endif | ||
| 2803 | } | 2806 | } |
| 2804 | 2807 | ||
| 2805 | static int trace_alloc_page(void) | 2808 | static int trace_alloc_page(void) |
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index b2198bc830ae..b7f85d9c80d7 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
| @@ -188,6 +188,8 @@ struct trace_iterator { | |||
| 188 | void tracing_reset(struct trace_array_cpu *data); | 188 | void tracing_reset(struct trace_array_cpu *data); |
| 189 | int tracing_open_generic(struct inode *inode, struct file *filp); | 189 | int tracing_open_generic(struct inode *inode, struct file *filp); |
| 190 | struct dentry *tracing_init_dentry(void); | 190 | struct dentry *tracing_init_dentry(void); |
| 191 | void init_tracer_sysprof_debugfs(struct dentry *d_tracer); | ||
| 192 | |||
| 191 | void ftrace(struct trace_array *tr, | 193 | void ftrace(struct trace_array *tr, |
| 192 | struct trace_array_cpu *data, | 194 | struct trace_array_cpu *data, |
| 193 | unsigned long ip, | 195 | unsigned long ip, |
diff --git a/kernel/trace/trace_sysprof.c b/kernel/trace/trace_sysprof.c index f9a09fe705b0..19406236b67b 100644 --- a/kernel/trace/trace_sysprof.c +++ b/kernel/trace/trace_sysprof.c | |||
| @@ -20,11 +20,12 @@ static struct trace_array *sysprof_trace; | |||
| 20 | static int __read_mostly tracer_enabled; | 20 | static int __read_mostly tracer_enabled; |
| 21 | 21 | ||
| 22 | /* | 22 | /* |
| 23 | * 10 msecs for now: | 23 | * 1 msec sample interval by default: |
| 24 | */ | 24 | */ |
| 25 | static const unsigned long sample_period = 1000000; | 25 | static unsigned long sample_period = 1000000; |
| 26 | static const unsigned int sample_max_depth = 512; | 26 | static const unsigned int sample_max_depth = 512; |
| 27 | 27 | ||
| 28 | static DEFINE_MUTEX(sample_timer_lock); | ||
| 28 | /* | 29 | /* |
| 29 | * Per CPU hrtimers that do the profiling: | 30 | * Per CPU hrtimers that do the profiling: |
| 30 | */ | 31 | */ |
| @@ -166,15 +167,19 @@ static notrace void stack_reset(struct trace_array *tr) | |||
| 166 | 167 | ||
| 167 | static notrace void start_stack_trace(struct trace_array *tr) | 168 | static notrace void start_stack_trace(struct trace_array *tr) |
| 168 | { | 169 | { |
| 170 | mutex_lock(&sample_timer_lock); | ||
| 169 | stack_reset(tr); | 171 | stack_reset(tr); |
| 170 | start_stack_timers(); | 172 | start_stack_timers(); |
| 171 | tracer_enabled = 1; | 173 | tracer_enabled = 1; |
| 174 | mutex_unlock(&sample_timer_lock); | ||
| 172 | } | 175 | } |
| 173 | 176 | ||
| 174 | static notrace void stop_stack_trace(struct trace_array *tr) | 177 | static notrace void stop_stack_trace(struct trace_array *tr) |
| 175 | { | 178 | { |
| 179 | mutex_lock(&sample_timer_lock); | ||
| 176 | stop_stack_timers(); | 180 | stop_stack_timers(); |
| 177 | tracer_enabled = 0; | 181 | tracer_enabled = 0; |
| 182 | mutex_unlock(&sample_timer_lock); | ||
| 178 | } | 183 | } |
| 179 | 184 | ||
| 180 | static notrace void stack_trace_init(struct trace_array *tr) | 185 | static notrace void stack_trace_init(struct trace_array *tr) |
| @@ -216,3 +221,64 @@ __init static int init_stack_trace(void) | |||
| 216 | return register_tracer(&stack_trace); | 221 | return register_tracer(&stack_trace); |
| 217 | } | 222 | } |
| 218 | device_initcall(init_stack_trace); | 223 | device_initcall(init_stack_trace); |
| 224 | |||
| 225 | #define MAX_LONG_DIGITS 22 | ||
| 226 | |||
| 227 | static ssize_t | ||
| 228 | sysprof_sample_read(struct file *filp, char __user *ubuf, | ||
| 229 | size_t cnt, loff_t *ppos) | ||
| 230 | { | ||
| 231 | char buf[MAX_LONG_DIGITS]; | ||
| 232 | int r; | ||
| 233 | |||
| 234 | r = sprintf(buf, "%ld\n", nsecs_to_usecs(sample_period)); | ||
| 235 | |||
| 236 | return simple_read_from_buffer(ubuf, cnt, ppos, buf, r); | ||
| 237 | } | ||
| 238 | |||
| 239 | static ssize_t | ||
| 240 | sysprof_sample_write(struct file *filp, const char __user *ubuf, | ||
| 241 | size_t cnt, loff_t *ppos) | ||
| 242 | { | ||
| 243 | char buf[MAX_LONG_DIGITS]; | ||
| 244 | unsigned long val; | ||
| 245 | |||
| 246 | if (cnt > MAX_LONG_DIGITS-1) | ||
| 247 | cnt = MAX_LONG_DIGITS-1; | ||
| 248 | |||
| 249 | if (copy_from_user(&buf, ubuf, cnt)) | ||
| 250 | return -EFAULT; | ||
| 251 | |||
| 252 | buf[cnt] = 0; | ||
| 253 | |||
| 254 | val = simple_strtoul(buf, NULL, 10); | ||
| 255 | /* | ||
| 256 | * Enforce a minimum sample period of 100 usecs: | ||
| 257 | */ | ||
| 258 | if (val < 100) | ||
| 259 | val = 100; | ||
| 260 | |||
| 261 | mutex_lock(&sample_timer_lock); | ||
| 262 | stop_stack_timers(); | ||
| 263 | sample_period = val * 1000; | ||
| 264 | start_stack_timers(); | ||
| 265 | mutex_unlock(&sample_timer_lock); | ||
| 266 | |||
| 267 | return cnt; | ||
| 268 | } | ||
| 269 | |||
| 270 | static struct file_operations sysprof_sample_fops = { | ||
| 271 | .read = sysprof_sample_read, | ||
| 272 | .write = sysprof_sample_write, | ||
| 273 | }; | ||
| 274 | |||
| 275 | void init_tracer_sysprof_debugfs(struct dentry *d_tracer) | ||
| 276 | { | ||
| 277 | struct dentry *entry; | ||
| 278 | |||
| 279 | entry = debugfs_create_file("sysprof_sample_period", 0644, | ||
| 280 | d_tracer, NULL, &sysprof_sample_fops); | ||
| 281 | if (entry) | ||
| 282 | return; | ||
| 283 | pr_warning("Could not create debugfs 'dyn_ftrace_total_info' entry\n"); | ||
| 284 | } | ||
