diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/trace.c | 92 | ||||
-rw-r--r-- | kernel/trace/trace.h | 7 |
2 files changed, 79 insertions, 20 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 8ac204360a39..63dbc7ff213f 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -323,12 +323,21 @@ static const char *trace_options[] = { | |||
323 | "printk-msg-only", | 323 | "printk-msg-only", |
324 | "context-info", | 324 | "context-info", |
325 | "latency-format", | 325 | "latency-format", |
326 | "global-clock", | ||
327 | "sleep-time", | 326 | "sleep-time", |
328 | "graph-time", | 327 | "graph-time", |
329 | NULL | 328 | NULL |
330 | }; | 329 | }; |
331 | 330 | ||
331 | static struct { | ||
332 | u64 (*func)(void); | ||
333 | const char *name; | ||
334 | } trace_clocks[] = { | ||
335 | { trace_clock_local, "local" }, | ||
336 | { trace_clock_global, "global" }, | ||
337 | }; | ||
338 | |||
339 | int trace_clock_id; | ||
340 | |||
332 | /* | 341 | /* |
333 | * ftrace_max_lock is used to protect the swapping of buffers | 342 | * ftrace_max_lock is used to protect the swapping of buffers |
334 | * when taking a max snapshot. The buffers themselves are | 343 | * when taking a max snapshot. The buffers themselves are |
@@ -2159,22 +2168,6 @@ static void set_tracer_flags(unsigned int mask, int enabled) | |||
2159 | trace_flags |= mask; | 2168 | trace_flags |= mask; |
2160 | else | 2169 | else |
2161 | trace_flags &= ~mask; | 2170 | trace_flags &= ~mask; |
2162 | |||
2163 | if (mask == TRACE_ITER_GLOBAL_CLK) { | ||
2164 | u64 (*func)(void); | ||
2165 | |||
2166 | if (enabled) | ||
2167 | func = trace_clock_global; | ||
2168 | else | ||
2169 | func = trace_clock_local; | ||
2170 | |||
2171 | mutex_lock(&trace_types_lock); | ||
2172 | ring_buffer_set_clock(global_trace.buffer, func); | ||
2173 | |||
2174 | if (max_tr.buffer) | ||
2175 | ring_buffer_set_clock(max_tr.buffer, func); | ||
2176 | mutex_unlock(&trace_types_lock); | ||
2177 | } | ||
2178 | } | 2171 | } |
2179 | 2172 | ||
2180 | static ssize_t | 2173 | static ssize_t |
@@ -3142,6 +3135,62 @@ tracing_mark_write(struct file *filp, const char __user *ubuf, | |||
3142 | return cnt; | 3135 | return cnt; |
3143 | } | 3136 | } |
3144 | 3137 | ||
3138 | static ssize_t tracing_clock_read(struct file *filp, char __user *ubuf, | ||
3139 | size_t cnt, loff_t *ppos) | ||
3140 | { | ||
3141 | char buf[64]; | ||
3142 | int bufiter = 0; | ||
3143 | int i; | ||
3144 | |||
3145 | for (i = 0; i < ARRAY_SIZE(trace_clocks); i++) | ||
3146 | bufiter += snprintf(buf + bufiter, sizeof(buf) - bufiter, | ||
3147 | "%s%s%s%s", i ? " " : "", | ||
3148 | i == trace_clock_id ? "[" : "", trace_clocks[i].name, | ||
3149 | i == trace_clock_id ? "]" : ""); | ||
3150 | bufiter += snprintf(buf + bufiter, sizeof(buf) - bufiter, "\n"); | ||
3151 | |||
3152 | return simple_read_from_buffer(ubuf, cnt, ppos, buf, bufiter); | ||
3153 | } | ||
3154 | |||
3155 | static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf, | ||
3156 | size_t cnt, loff_t *fpos) | ||
3157 | { | ||
3158 | char buf[64]; | ||
3159 | const char *clockstr; | ||
3160 | int i; | ||
3161 | |||
3162 | if (cnt >= sizeof(buf)) | ||
3163 | return -EINVAL; | ||
3164 | |||
3165 | if (copy_from_user(&buf, ubuf, cnt)) | ||
3166 | return -EFAULT; | ||
3167 | |||
3168 | buf[cnt] = 0; | ||
3169 | |||
3170 | clockstr = strstrip(buf); | ||
3171 | |||
3172 | for (i = 0; i < ARRAY_SIZE(trace_clocks); i++) { | ||
3173 | if (strcmp(trace_clocks[i].name, clockstr) == 0) | ||
3174 | break; | ||
3175 | } | ||
3176 | if (i == ARRAY_SIZE(trace_clocks)) | ||
3177 | return -EINVAL; | ||
3178 | |||
3179 | trace_clock_id = i; | ||
3180 | |||
3181 | mutex_lock(&trace_types_lock); | ||
3182 | |||
3183 | ring_buffer_set_clock(global_trace.buffer, trace_clocks[i].func); | ||
3184 | if (max_tr.buffer) | ||
3185 | ring_buffer_set_clock(max_tr.buffer, trace_clocks[i].func); | ||
3186 | |||
3187 | mutex_unlock(&trace_types_lock); | ||
3188 | |||
3189 | *fpos += cnt; | ||
3190 | |||
3191 | return cnt; | ||
3192 | } | ||
3193 | |||
3145 | static const struct file_operations tracing_max_lat_fops = { | 3194 | static const struct file_operations tracing_max_lat_fops = { |
3146 | .open = tracing_open_generic, | 3195 | .open = tracing_open_generic, |
3147 | .read = tracing_max_lat_read, | 3196 | .read = tracing_max_lat_read, |
@@ -3179,6 +3228,12 @@ static const struct file_operations tracing_mark_fops = { | |||
3179 | .write = tracing_mark_write, | 3228 | .write = tracing_mark_write, |
3180 | }; | 3229 | }; |
3181 | 3230 | ||
3231 | static const struct file_operations trace_clock_fops = { | ||
3232 | .open = tracing_open_generic, | ||
3233 | .read = tracing_clock_read, | ||
3234 | .write = tracing_clock_write, | ||
3235 | }; | ||
3236 | |||
3182 | struct ftrace_buffer_info { | 3237 | struct ftrace_buffer_info { |
3183 | struct trace_array *tr; | 3238 | struct trace_array *tr; |
3184 | void *spare; | 3239 | void *spare; |
@@ -3918,6 +3973,9 @@ static __init int tracer_init_debugfs(void) | |||
3918 | trace_create_file("saved_cmdlines", 0444, d_tracer, | 3973 | trace_create_file("saved_cmdlines", 0444, d_tracer, |
3919 | NULL, &tracing_saved_cmdlines_fops); | 3974 | NULL, &tracing_saved_cmdlines_fops); |
3920 | 3975 | ||
3976 | trace_create_file("trace_clock", 0644, d_tracer, NULL, | ||
3977 | &trace_clock_fops); | ||
3978 | |||
3921 | #ifdef CONFIG_DYNAMIC_FTRACE | 3979 | #ifdef CONFIG_DYNAMIC_FTRACE |
3922 | trace_create_file("dyn_ftrace_total_info", 0444, d_tracer, | 3980 | trace_create_file("dyn_ftrace_total_info", 0444, d_tracer, |
3923 | &ftrace_update_tot_cnt, &tracing_dyn_info_fops); | 3981 | &ftrace_update_tot_cnt, &tracing_dyn_info_fops); |
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 64dda5709cb9..654fd657bd03 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
@@ -568,6 +568,8 @@ trace_vprintk(unsigned long ip, const char *fmt, va_list args); | |||
568 | 568 | ||
569 | extern unsigned long trace_flags; | 569 | extern unsigned long trace_flags; |
570 | 570 | ||
571 | extern int trace_clock_id; | ||
572 | |||
571 | /* Standard output formatting function used for function return traces */ | 573 | /* Standard output formatting function used for function return traces */ |
572 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER | 574 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
573 | extern enum print_line_t print_graph_function(struct trace_iterator *iter); | 575 | extern enum print_line_t print_graph_function(struct trace_iterator *iter); |
@@ -656,9 +658,8 @@ enum trace_iterator_flags { | |||
656 | TRACE_ITER_PRINTK_MSGONLY = 0x10000, | 658 | TRACE_ITER_PRINTK_MSGONLY = 0x10000, |
657 | TRACE_ITER_CONTEXT_INFO = 0x20000, /* Print pid/cpu/time */ | 659 | TRACE_ITER_CONTEXT_INFO = 0x20000, /* Print pid/cpu/time */ |
658 | TRACE_ITER_LATENCY_FMT = 0x40000, | 660 | TRACE_ITER_LATENCY_FMT = 0x40000, |
659 | TRACE_ITER_GLOBAL_CLK = 0x80000, | 661 | TRACE_ITER_SLEEP_TIME = 0x80000, |
660 | TRACE_ITER_SLEEP_TIME = 0x100000, | 662 | TRACE_ITER_GRAPH_TIME = 0x100000, |
661 | TRACE_ITER_GRAPH_TIME = 0x200000, | ||
662 | }; | 663 | }; |
663 | 664 | ||
664 | /* | 665 | /* |