diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-03-18 01:59:56 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-03-18 01:59:56 -0400 |
commit | 327019b01e068d66dada6a8b2571180ab3674d20 (patch) | |
tree | c81354a509d6962f6878145fcf3cdbe50a000a89 /kernel/trace/trace.c | |
parent | 03418c7efaa429dc7647ac93e3862e3fe1816873 (diff) | |
parent | 62524d55e5b9ffe36e3bf3dd7a594114f150b449 (diff) |
Merge branch 'tip/tracing/ftrace' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace into tracing/ftrace
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r-- | kernel/trace/trace.c | 55 |
1 files changed, 44 insertions, 11 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 1ce6208fd727..a2d13e8c8fd8 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -155,13 +155,6 @@ ns2usecs(cycle_t nsec) | |||
155 | return nsec; | 155 | return nsec; |
156 | } | 156 | } |
157 | 157 | ||
158 | cycle_t ftrace_now(int cpu) | ||
159 | { | ||
160 | u64 ts = ring_buffer_time_stamp(cpu); | ||
161 | ring_buffer_normalize_time_stamp(cpu, &ts); | ||
162 | return ts; | ||
163 | } | ||
164 | |||
165 | /* | 158 | /* |
166 | * The global_trace is the descriptor that holds the tracing | 159 | * The global_trace is the descriptor that holds the tracing |
167 | * buffers for the live tracing. For each CPU, it contains | 160 | * buffers for the live tracing. For each CPU, it contains |
@@ -178,6 +171,20 @@ static struct trace_array global_trace; | |||
178 | 171 | ||
179 | static DEFINE_PER_CPU(struct trace_array_cpu, global_trace_cpu); | 172 | static DEFINE_PER_CPU(struct trace_array_cpu, global_trace_cpu); |
180 | 173 | ||
174 | cycle_t ftrace_now(int cpu) | ||
175 | { | ||
176 | u64 ts; | ||
177 | |||
178 | /* Early boot up does not have a buffer yet */ | ||
179 | if (!global_trace.buffer) | ||
180 | return trace_clock_local(); | ||
181 | |||
182 | ts = ring_buffer_time_stamp(global_trace.buffer, cpu); | ||
183 | ring_buffer_normalize_time_stamp(global_trace.buffer, cpu, &ts); | ||
184 | |||
185 | return ts; | ||
186 | } | ||
187 | |||
181 | /* | 188 | /* |
182 | * The max_tr is used to snapshot the global_trace when a maximum | 189 | * The max_tr is used to snapshot the global_trace when a maximum |
183 | * latency is reached. Some tracers will use this to store a maximum | 190 | * latency is reached. Some tracers will use this to store a maximum |
@@ -308,6 +315,7 @@ static const char *trace_options[] = { | |||
308 | "printk-msg-only", | 315 | "printk-msg-only", |
309 | "context-info", | 316 | "context-info", |
310 | "latency-format", | 317 | "latency-format", |
318 | "global-clock", | ||
311 | NULL | 319 | NULL |
312 | }; | 320 | }; |
313 | 321 | ||
@@ -2244,6 +2252,34 @@ static int set_tracer_option(struct tracer *trace, char *cmp, int neg) | |||
2244 | return 0; | 2252 | return 0; |
2245 | } | 2253 | } |
2246 | 2254 | ||
2255 | static void set_tracer_flags(unsigned int mask, int enabled) | ||
2256 | { | ||
2257 | /* do nothing if flag is already set */ | ||
2258 | if (!!(trace_flags & mask) == !!enabled) | ||
2259 | return; | ||
2260 | |||
2261 | if (enabled) | ||
2262 | trace_flags |= mask; | ||
2263 | else | ||
2264 | trace_flags &= ~mask; | ||
2265 | |||
2266 | if (mask == TRACE_ITER_GLOBAL_CLK) { | ||
2267 | u64 (*func)(void); | ||
2268 | |||
2269 | if (enabled) | ||
2270 | func = trace_clock_global; | ||
2271 | else | ||
2272 | func = trace_clock_local; | ||
2273 | |||
2274 | mutex_lock(&trace_types_lock); | ||
2275 | ring_buffer_set_clock(global_trace.buffer, func); | ||
2276 | |||
2277 | if (max_tr.buffer) | ||
2278 | ring_buffer_set_clock(max_tr.buffer, func); | ||
2279 | mutex_unlock(&trace_types_lock); | ||
2280 | } | ||
2281 | } | ||
2282 | |||
2247 | static ssize_t | 2283 | static ssize_t |
2248 | tracing_trace_options_write(struct file *filp, const char __user *ubuf, | 2284 | tracing_trace_options_write(struct file *filp, const char __user *ubuf, |
2249 | size_t cnt, loff_t *ppos) | 2285 | size_t cnt, loff_t *ppos) |
@@ -2271,10 +2307,7 @@ tracing_trace_options_write(struct file *filp, const char __user *ubuf, | |||
2271 | int len = strlen(trace_options[i]); | 2307 | int len = strlen(trace_options[i]); |
2272 | 2308 | ||
2273 | if (strncmp(cmp, trace_options[i], len) == 0) { | 2309 | if (strncmp(cmp, trace_options[i], len) == 0) { |
2274 | if (neg) | 2310 | set_tracer_flags(1 << i, !neg); |
2275 | trace_flags &= ~(1 << i); | ||
2276 | else | ||
2277 | trace_flags |= (1 << i); | ||
2278 | break; | 2311 | break; |
2279 | } | 2312 | } |
2280 | } | 2313 | } |