diff options
Diffstat (limited to 'kernel/trace')
| -rw-r--r-- | kernel/trace/Kconfig | 112 | ||||
| -rw-r--r-- | kernel/trace/ftrace.c | 30 | ||||
| -rw-r--r-- | kernel/trace/power-traces.c | 2 | ||||
| -rw-r--r-- | kernel/trace/ring_buffer.c | 45 | ||||
| -rw-r--r-- | kernel/trace/trace.c | 307 | ||||
| -rw-r--r-- | kernel/trace/trace.h | 27 | ||||
| -rw-r--r-- | kernel/trace/trace_clock.c | 8 | ||||
| -rw-r--r-- | kernel/trace/trace_event_profile.c | 6 | ||||
| -rw-r--r-- | kernel/trace/trace_events.c | 41 | ||||
| -rw-r--r-- | kernel/trace/trace_export.c | 11 | ||||
| -rw-r--r-- | kernel/trace/trace_functions_graph.c | 169 | ||||
| -rw-r--r-- | kernel/trace/trace_hw_branches.c | 51 | ||||
| -rw-r--r-- | kernel/trace/trace_irqsoff.c | 2 | ||||
| -rw-r--r-- | kernel/trace/trace_kprobe.c | 84 | ||||
| -rw-r--r-- | kernel/trace/trace_ksym.c | 193 | ||||
| -rw-r--r-- | kernel/trace/trace_output.c | 75 | ||||
| -rw-r--r-- | kernel/trace/trace_sched_wakeup.c | 16 | ||||
| -rw-r--r-- | kernel/trace/trace_selftest.c | 4 | ||||
| -rw-r--r-- | kernel/trace/trace_stack.c | 16 | ||||
| -rw-r--r-- | kernel/trace/trace_syscalls.c | 18 | ||||
| -rw-r--r-- | kernel/trace/trace_sysprof.c | 1 |
21 files changed, 692 insertions, 526 deletions
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig index d006554888dc..6c22d8a2f289 100644 --- a/kernel/trace/Kconfig +++ b/kernel/trace/Kconfig | |||
| @@ -12,17 +12,17 @@ config NOP_TRACER | |||
| 12 | config HAVE_FTRACE_NMI_ENTER | 12 | config HAVE_FTRACE_NMI_ENTER |
| 13 | bool | 13 | bool |
| 14 | help | 14 | help |
| 15 | See Documentation/trace/ftrace-implementation.txt | 15 | See Documentation/trace/ftrace-design.txt |
| 16 | 16 | ||
| 17 | config HAVE_FUNCTION_TRACER | 17 | config HAVE_FUNCTION_TRACER |
| 18 | bool | 18 | bool |
| 19 | help | 19 | help |
| 20 | See Documentation/trace/ftrace-implementation.txt | 20 | See Documentation/trace/ftrace-design.txt |
| 21 | 21 | ||
| 22 | config HAVE_FUNCTION_GRAPH_TRACER | 22 | config HAVE_FUNCTION_GRAPH_TRACER |
| 23 | bool | 23 | bool |
| 24 | help | 24 | help |
| 25 | See Documentation/trace/ftrace-implementation.txt | 25 | See Documentation/trace/ftrace-design.txt |
| 26 | 26 | ||
| 27 | config HAVE_FUNCTION_GRAPH_FP_TEST | 27 | config HAVE_FUNCTION_GRAPH_FP_TEST |
| 28 | bool | 28 | bool |
| @@ -34,17 +34,17 @@ config HAVE_FUNCTION_GRAPH_FP_TEST | |||
| 34 | config HAVE_FUNCTION_TRACE_MCOUNT_TEST | 34 | config HAVE_FUNCTION_TRACE_MCOUNT_TEST |
| 35 | bool | 35 | bool |
| 36 | help | 36 | help |
| 37 | See Documentation/trace/ftrace-implementation.txt | 37 | See Documentation/trace/ftrace-design.txt |
| 38 | 38 | ||
| 39 | config HAVE_DYNAMIC_FTRACE | 39 | config HAVE_DYNAMIC_FTRACE |
| 40 | bool | 40 | bool |
| 41 | help | 41 | help |
| 42 | See Documentation/trace/ftrace-implementation.txt | 42 | See Documentation/trace/ftrace-design.txt |
| 43 | 43 | ||
| 44 | config HAVE_FTRACE_MCOUNT_RECORD | 44 | config HAVE_FTRACE_MCOUNT_RECORD |
| 45 | bool | 45 | bool |
| 46 | help | 46 | help |
| 47 | See Documentation/trace/ftrace-implementation.txt | 47 | See Documentation/trace/ftrace-design.txt |
| 48 | 48 | ||
| 49 | config HAVE_HW_BRANCH_TRACER | 49 | config HAVE_HW_BRANCH_TRACER |
| 50 | bool | 50 | bool |
| @@ -52,7 +52,7 @@ config HAVE_HW_BRANCH_TRACER | |||
| 52 | config HAVE_SYSCALL_TRACEPOINTS | 52 | config HAVE_SYSCALL_TRACEPOINTS |
| 53 | bool | 53 | bool |
| 54 | help | 54 | help |
| 55 | See Documentation/trace/ftrace-implementation.txt | 55 | See Documentation/trace/ftrace-design.txt |
| 56 | 56 | ||
| 57 | config TRACER_MAX_TRACE | 57 | config TRACER_MAX_TRACE |
| 58 | bool | 58 | bool |
| @@ -83,7 +83,7 @@ config RING_BUFFER_ALLOW_SWAP | |||
| 83 | # This allows those options to appear when no other tracer is selected. But the | 83 | # This allows those options to appear when no other tracer is selected. But the |
| 84 | # options do not appear when something else selects it. We need the two options | 84 | # options do not appear when something else selects it. We need the two options |
| 85 | # GENERIC_TRACER and TRACING to avoid circular dependencies to accomplish the | 85 | # GENERIC_TRACER and TRACING to avoid circular dependencies to accomplish the |
| 86 | # hidding of the automatic options. | 86 | # hiding of the automatic options. |
| 87 | 87 | ||
| 88 | config TRACING | 88 | config TRACING |
| 89 | bool | 89 | bool |
| @@ -119,7 +119,7 @@ menuconfig FTRACE | |||
| 119 | bool "Tracers" | 119 | bool "Tracers" |
| 120 | default y if DEBUG_KERNEL | 120 | default y if DEBUG_KERNEL |
| 121 | help | 121 | help |
| 122 | Enable the kernel tracing infrastructure. | 122 | Enable the kernel tracing infrastructure. |
| 123 | 123 | ||
| 124 | if FTRACE | 124 | if FTRACE |
| 125 | 125 | ||
| @@ -133,7 +133,7 @@ config FUNCTION_TRACER | |||
| 133 | help | 133 | help |
| 134 | Enable the kernel to trace every kernel function. This is done | 134 | Enable the kernel to trace every kernel function. This is done |
| 135 | by using a compiler feature to insert a small, 5-byte No-Operation | 135 | by using a compiler feature to insert a small, 5-byte No-Operation |
| 136 | instruction to the beginning of every kernel function, which NOP | 136 | instruction at the beginning of every kernel function, which NOP |
| 137 | sequence is then dynamically patched into a tracer call when | 137 | sequence is then dynamically patched into a tracer call when |
| 138 | tracing is enabled by the administrator. If it's runtime disabled | 138 | tracing is enabled by the administrator. If it's runtime disabled |
| 139 | (the bootup default), then the overhead of the instructions is very | 139 | (the bootup default), then the overhead of the instructions is very |
| @@ -150,7 +150,7 @@ config FUNCTION_GRAPH_TRACER | |||
| 150 | and its entry. | 150 | and its entry. |
| 151 | Its first purpose is to trace the duration of functions and | 151 | Its first purpose is to trace the duration of functions and |
| 152 | draw a call graph for each thread with some information like | 152 | draw a call graph for each thread with some information like |
| 153 | the return value. This is done by setting the current return | 153 | the return value. This is done by setting the current return |
| 154 | address on the current task structure into a stack of calls. | 154 | address on the current task structure into a stack of calls. |
| 155 | 155 | ||
| 156 | 156 | ||
| @@ -173,7 +173,7 @@ config IRQSOFF_TRACER | |||
| 173 | 173 | ||
| 174 | echo 0 > /sys/kernel/debug/tracing/tracing_max_latency | 174 | echo 0 > /sys/kernel/debug/tracing/tracing_max_latency |
| 175 | 175 | ||
| 176 | (Note that kernel size and overhead increases with this option | 176 | (Note that kernel size and overhead increase with this option |
| 177 | enabled. This option and the preempt-off timing option can be | 177 | enabled. This option and the preempt-off timing option can be |
| 178 | used together or separately.) | 178 | used together or separately.) |
| 179 | 179 | ||
| @@ -186,7 +186,7 @@ config PREEMPT_TRACER | |||
| 186 | select TRACER_MAX_TRACE | 186 | select TRACER_MAX_TRACE |
| 187 | select RING_BUFFER_ALLOW_SWAP | 187 | select RING_BUFFER_ALLOW_SWAP |
| 188 | help | 188 | help |
| 189 | This option measures the time spent in preemption off critical | 189 | This option measures the time spent in preemption-off critical |
| 190 | sections, with microsecond accuracy. | 190 | sections, with microsecond accuracy. |
| 191 | 191 | ||
| 192 | The default measurement method is a maximum search, which is | 192 | The default measurement method is a maximum search, which is |
| @@ -195,7 +195,7 @@ config PREEMPT_TRACER | |||
| 195 | 195 | ||
| 196 | echo 0 > /sys/kernel/debug/tracing/tracing_max_latency | 196 | echo 0 > /sys/kernel/debug/tracing/tracing_max_latency |
| 197 | 197 | ||
| 198 | (Note that kernel size and overhead increases with this option | 198 | (Note that kernel size and overhead increase with this option |
| 199 | enabled. This option and the irqs-off timing option can be | 199 | enabled. This option and the irqs-off timing option can be |
| 200 | used together or separately.) | 200 | used together or separately.) |
| 201 | 201 | ||
| @@ -222,7 +222,7 @@ config ENABLE_DEFAULT_TRACERS | |||
| 222 | depends on !GENERIC_TRACER | 222 | depends on !GENERIC_TRACER |
| 223 | select TRACING | 223 | select TRACING |
| 224 | help | 224 | help |
| 225 | This tracer hooks to various trace points in the kernel | 225 | This tracer hooks to various trace points in the kernel, |
| 226 | allowing the user to pick and choose which trace point they | 226 | allowing the user to pick and choose which trace point they |
| 227 | want to trace. It also includes the sched_switch tracer plugin. | 227 | want to trace. It also includes the sched_switch tracer plugin. |
| 228 | 228 | ||
| @@ -265,19 +265,19 @@ choice | |||
| 265 | The likely/unlikely profiler only looks at the conditions that | 265 | The likely/unlikely profiler only looks at the conditions that |
| 266 | are annotated with a likely or unlikely macro. | 266 | are annotated with a likely or unlikely macro. |
| 267 | 267 | ||
| 268 | The "all branch" profiler will profile every if statement in the | 268 | The "all branch" profiler will profile every if-statement in the |
| 269 | kernel. This profiler will also enable the likely/unlikely | 269 | kernel. This profiler will also enable the likely/unlikely |
| 270 | profiler as well. | 270 | profiler. |
| 271 | 271 | ||
| 272 | Either of the above profilers add a bit of overhead to the system. | 272 | Either of the above profilers adds a bit of overhead to the system. |
| 273 | If unsure choose "No branch profiling". | 273 | If unsure, choose "No branch profiling". |
| 274 | 274 | ||
| 275 | config BRANCH_PROFILE_NONE | 275 | config BRANCH_PROFILE_NONE |
| 276 | bool "No branch profiling" | 276 | bool "No branch profiling" |
| 277 | help | 277 | help |
| 278 | No branch profiling. Branch profiling adds a bit of overhead. | 278 | No branch profiling. Branch profiling adds a bit of overhead. |
| 279 | Only enable it if you want to analyse the branching behavior. | 279 | Only enable it if you want to analyse the branching behavior. |
| 280 | Otherwise keep it disabled. | 280 | Otherwise keep it disabled. |
| 281 | 281 | ||
| 282 | config PROFILE_ANNOTATED_BRANCHES | 282 | config PROFILE_ANNOTATED_BRANCHES |
| 283 | bool "Trace likely/unlikely profiler" | 283 | bool "Trace likely/unlikely profiler" |
| @@ -288,7 +288,7 @@ config PROFILE_ANNOTATED_BRANCHES | |||
| 288 | 288 | ||
| 289 | /sys/kernel/debug/tracing/profile_annotated_branch | 289 | /sys/kernel/debug/tracing/profile_annotated_branch |
| 290 | 290 | ||
| 291 | Note: this will add a significant overhead, only turn this | 291 | Note: this will add a significant overhead; only turn this |
| 292 | on if you need to profile the system's use of these macros. | 292 | on if you need to profile the system's use of these macros. |
| 293 | 293 | ||
| 294 | config PROFILE_ALL_BRANCHES | 294 | config PROFILE_ALL_BRANCHES |
| @@ -305,7 +305,7 @@ config PROFILE_ALL_BRANCHES | |||
| 305 | 305 | ||
| 306 | This configuration, when enabled, will impose a great overhead | 306 | This configuration, when enabled, will impose a great overhead |
| 307 | on the system. This should only be enabled when the system | 307 | on the system. This should only be enabled when the system |
| 308 | is to be analyzed | 308 | is to be analyzed in much detail. |
| 309 | endchoice | 309 | endchoice |
| 310 | 310 | ||
| 311 | config TRACING_BRANCHES | 311 | config TRACING_BRANCHES |
| @@ -335,7 +335,7 @@ config POWER_TRACER | |||
| 335 | depends on X86 | 335 | depends on X86 |
| 336 | select GENERIC_TRACER | 336 | select GENERIC_TRACER |
| 337 | help | 337 | help |
| 338 | This tracer helps developers to analyze and optimize the kernels | 338 | This tracer helps developers to analyze and optimize the kernel's |
| 339 | power management decisions, specifically the C-state and P-state | 339 | power management decisions, specifically the C-state and P-state |
| 340 | behavior. | 340 | behavior. |
| 341 | 341 | ||
| @@ -391,14 +391,14 @@ config HW_BRANCH_TRACER | |||
| 391 | select GENERIC_TRACER | 391 | select GENERIC_TRACER |
| 392 | help | 392 | help |
| 393 | This tracer records all branches on the system in a circular | 393 | This tracer records all branches on the system in a circular |
| 394 | buffer giving access to the last N branches for each cpu. | 394 | buffer, giving access to the last N branches for each cpu. |
| 395 | 395 | ||
| 396 | config KMEMTRACE | 396 | config KMEMTRACE |
| 397 | bool "Trace SLAB allocations" | 397 | bool "Trace SLAB allocations" |
| 398 | select GENERIC_TRACER | 398 | select GENERIC_TRACER |
| 399 | help | 399 | help |
| 400 | kmemtrace provides tracing for slab allocator functions, such as | 400 | kmemtrace provides tracing for slab allocator functions, such as |
| 401 | kmalloc, kfree, kmem_cache_alloc, kmem_cache_free etc.. Collected | 401 | kmalloc, kfree, kmem_cache_alloc, kmem_cache_free, etc. Collected |
| 402 | data is then fed to the userspace application in order to analyse | 402 | data is then fed to the userspace application in order to analyse |
| 403 | allocation hotspots, internal fragmentation and so on, making it | 403 | allocation hotspots, internal fragmentation and so on, making it |
| 404 | possible to see how well an allocator performs, as well as debug | 404 | possible to see how well an allocator performs, as well as debug |
| @@ -417,15 +417,15 @@ config WORKQUEUE_TRACER | |||
| 417 | bool "Trace workqueues" | 417 | bool "Trace workqueues" |
| 418 | select GENERIC_TRACER | 418 | select GENERIC_TRACER |
| 419 | help | 419 | help |
| 420 | The workqueue tracer provides some statistical informations | 420 | The workqueue tracer provides some statistical information |
| 421 | about each cpu workqueue thread such as the number of the | 421 | about each cpu workqueue thread such as the number of the |
| 422 | works inserted and executed since their creation. It can help | 422 | works inserted and executed since their creation. It can help |
| 423 | to evaluate the amount of work each of them have to perform. | 423 | to evaluate the amount of work each of them has to perform. |
| 424 | For example it can help a developer to decide whether he should | 424 | For example it can help a developer to decide whether he should |
| 425 | choose a per cpu workqueue instead of a singlethreaded one. | 425 | choose a per-cpu workqueue instead of a singlethreaded one. |
| 426 | 426 | ||
| 427 | config BLK_DEV_IO_TRACE | 427 | config BLK_DEV_IO_TRACE |
| 428 | bool "Support for tracing block io actions" | 428 | bool "Support for tracing block IO actions" |
| 429 | depends on SYSFS | 429 | depends on SYSFS |
| 430 | depends on BLOCK | 430 | depends on BLOCK |
| 431 | select RELAY | 431 | select RELAY |
| @@ -456,15 +456,15 @@ config KPROBE_EVENT | |||
| 456 | select TRACING | 456 | select TRACING |
| 457 | default y | 457 | default y |
| 458 | help | 458 | help |
| 459 | This allows the user to add tracing events (similar to tracepoints) on the fly | 459 | This allows the user to add tracing events (similar to tracepoints) |
| 460 | via the ftrace interface. See Documentation/trace/kprobetrace.txt | 460 | on the fly via the ftrace interface. See |
| 461 | for more details. | 461 | Documentation/trace/kprobetrace.txt for more details. |
| 462 | 462 | ||
| 463 | Those events can be inserted wherever kprobes can probe, and record | 463 | Those events can be inserted wherever kprobes can probe, and record |
| 464 | various register and memory values. | 464 | various register and memory values. |
| 465 | 465 | ||
| 466 | This option is also required by perf-probe subcommand of perf tools. If | 466 | This option is also required by perf-probe subcommand of perf tools. |
| 467 | you want to use perf tools, this option is strongly recommended. | 467 | If you want to use perf tools, this option is strongly recommended. |
| 468 | 468 | ||
| 469 | config DYNAMIC_FTRACE | 469 | config DYNAMIC_FTRACE |
| 470 | bool "enable/disable ftrace tracepoints dynamically" | 470 | bool "enable/disable ftrace tracepoints dynamically" |
| @@ -472,32 +472,32 @@ config DYNAMIC_FTRACE | |||
| 472 | depends on HAVE_DYNAMIC_FTRACE | 472 | depends on HAVE_DYNAMIC_FTRACE |
| 473 | default y | 473 | default y |
| 474 | help | 474 | help |
| 475 | This option will modify all the calls to ftrace dynamically | 475 | This option will modify all the calls to ftrace dynamically |
| 476 | (will patch them out of the binary image and replaces them | 476 | (will patch them out of the binary image and replace them |
| 477 | with a No-Op instruction) as they are called. A table is | 477 | with a No-Op instruction) as they are called. A table is |
| 478 | created to dynamically enable them again. | 478 | created to dynamically enable them again. |
| 479 | 479 | ||
| 480 | This way a CONFIG_FUNCTION_TRACER kernel is slightly larger, but otherwise | 480 | This way a CONFIG_FUNCTION_TRACER kernel is slightly larger, but |
| 481 | has native performance as long as no tracing is active. | 481 | otherwise has native performance as long as no tracing is active. |
| 482 | 482 | ||
| 483 | The changes to the code are done by a kernel thread that | 483 | The changes to the code are done by a kernel thread that |
| 484 | wakes up once a second and checks to see if any ftrace calls | 484 | wakes up once a second and checks to see if any ftrace calls |
| 485 | were made. If so, it runs stop_machine (stops all CPUS) | 485 | were made. If so, it runs stop_machine (stops all CPUS) |
| 486 | and modifies the code to jump over the call to ftrace. | 486 | and modifies the code to jump over the call to ftrace. |
| 487 | 487 | ||
| 488 | config FUNCTION_PROFILER | 488 | config FUNCTION_PROFILER |
| 489 | bool "Kernel function profiler" | 489 | bool "Kernel function profiler" |
| 490 | depends on FUNCTION_TRACER | 490 | depends on FUNCTION_TRACER |
| 491 | default n | 491 | default n |
| 492 | help | 492 | help |
| 493 | This option enables the kernel function profiler. A file is created | 493 | This option enables the kernel function profiler. A file is created |
| 494 | in debugfs called function_profile_enabled which defaults to zero. | 494 | in debugfs called function_profile_enabled which defaults to zero. |
| 495 | When a 1 is echoed into this file profiling begins, and when a | 495 | When a 1 is echoed into this file profiling begins, and when a |
| 496 | zero is entered, profiling stops. A file in the trace_stats | 496 | zero is entered, profiling stops. A "functions" file is created in |
| 497 | directory called functions, that show the list of functions that | 497 | the trace_stats directory; this file shows the list of functions that |
| 498 | have been hit and their counters. | 498 | have been hit and their counters. |
| 499 | 499 | ||
| 500 | If in doubt, say N | 500 | If in doubt, say N. |
| 501 | 501 | ||
| 502 | config FTRACE_MCOUNT_RECORD | 502 | config FTRACE_MCOUNT_RECORD |
| 503 | def_bool y | 503 | def_bool y |
| @@ -556,8 +556,8 @@ config RING_BUFFER_BENCHMARK | |||
| 556 | tristate "Ring buffer benchmark stress tester" | 556 | tristate "Ring buffer benchmark stress tester" |
| 557 | depends on RING_BUFFER | 557 | depends on RING_BUFFER |
| 558 | help | 558 | help |
| 559 | This option creates a test to stress the ring buffer and bench mark it. | 559 | This option creates a test to stress the ring buffer and benchmark it. |
| 560 | It creates its own ring buffer such that it will not interfer with | 560 | It creates its own ring buffer such that it will not interfere with |
| 561 | any other users of the ring buffer (such as ftrace). It then creates | 561 | any other users of the ring buffer (such as ftrace). It then creates |
| 562 | a producer and consumer that will run for 10 seconds and sleep for | 562 | a producer and consumer that will run for 10 seconds and sleep for |
| 563 | 10 seconds. Each interval it will print out the number of events | 563 | 10 seconds. Each interval it will print out the number of events |
| @@ -566,7 +566,7 @@ config RING_BUFFER_BENCHMARK | |||
| 566 | It does not disable interrupts or raise its priority, so it may be | 566 | It does not disable interrupts or raise its priority, so it may be |
| 567 | affected by processes that are running. | 567 | affected by processes that are running. |
| 568 | 568 | ||
| 569 | If unsure, say N | 569 | If unsure, say N. |
| 570 | 570 | ||
| 571 | endif # FTRACE | 571 | endif # FTRACE |
| 572 | 572 | ||
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index e51a1bcb7bed..7968762c8167 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c | |||
| @@ -1724,7 +1724,7 @@ ftrace_match_record(struct dyn_ftrace *rec, char *regex, int len, int type) | |||
| 1724 | return ftrace_match(str, regex, len, type); | 1724 | return ftrace_match(str, regex, len, type); |
| 1725 | } | 1725 | } |
| 1726 | 1726 | ||
| 1727 | static void ftrace_match_records(char *buff, int len, int enable) | 1727 | static int ftrace_match_records(char *buff, int len, int enable) |
| 1728 | { | 1728 | { |
| 1729 | unsigned int search_len; | 1729 | unsigned int search_len; |
| 1730 | struct ftrace_page *pg; | 1730 | struct ftrace_page *pg; |
| @@ -1733,6 +1733,7 @@ static void ftrace_match_records(char *buff, int len, int enable) | |||
| 1733 | char *search; | 1733 | char *search; |
| 1734 | int type; | 1734 | int type; |
| 1735 | int not; | 1735 | int not; |
| 1736 | int found = 0; | ||
| 1736 | 1737 | ||
| 1737 | flag = enable ? FTRACE_FL_FILTER : FTRACE_FL_NOTRACE; | 1738 | flag = enable ? FTRACE_FL_FILTER : FTRACE_FL_NOTRACE; |
| 1738 | type = filter_parse_regex(buff, len, &search, ¬); | 1739 | type = filter_parse_regex(buff, len, &search, ¬); |
| @@ -1750,6 +1751,7 @@ static void ftrace_match_records(char *buff, int len, int enable) | |||
| 1750 | rec->flags &= ~flag; | 1751 | rec->flags &= ~flag; |
| 1751 | else | 1752 | else |
| 1752 | rec->flags |= flag; | 1753 | rec->flags |= flag; |
| 1754 | found = 1; | ||
| 1753 | } | 1755 | } |
| 1754 | /* | 1756 | /* |
| 1755 | * Only enable filtering if we have a function that | 1757 | * Only enable filtering if we have a function that |
| @@ -1759,6 +1761,8 @@ static void ftrace_match_records(char *buff, int len, int enable) | |||
| 1759 | ftrace_filtered = 1; | 1761 | ftrace_filtered = 1; |
| 1760 | } while_for_each_ftrace_rec(); | 1762 | } while_for_each_ftrace_rec(); |
| 1761 | mutex_unlock(&ftrace_lock); | 1763 | mutex_unlock(&ftrace_lock); |
| 1764 | |||
| 1765 | return found; | ||
| 1762 | } | 1766 | } |
| 1763 | 1767 | ||
| 1764 | static int | 1768 | static int |
| @@ -1780,7 +1784,7 @@ ftrace_match_module_record(struct dyn_ftrace *rec, char *mod, | |||
| 1780 | return 1; | 1784 | return 1; |
| 1781 | } | 1785 | } |
| 1782 | 1786 | ||
| 1783 | static void ftrace_match_module_records(char *buff, char *mod, int enable) | 1787 | static int ftrace_match_module_records(char *buff, char *mod, int enable) |
| 1784 | { | 1788 | { |
| 1785 | unsigned search_len = 0; | 1789 | unsigned search_len = 0; |
| 1786 | struct ftrace_page *pg; | 1790 | struct ftrace_page *pg; |
| @@ -1789,6 +1793,7 @@ static void ftrace_match_module_records(char *buff, char *mod, int enable) | |||
| 1789 | char *search = buff; | 1793 | char *search = buff; |
| 1790 | unsigned long flag; | 1794 | unsigned long flag; |
| 1791 | int not = 0; | 1795 | int not = 0; |
| 1796 | int found = 0; | ||
| 1792 | 1797 | ||
| 1793 | flag = enable ? FTRACE_FL_FILTER : FTRACE_FL_NOTRACE; | 1798 | flag = enable ? FTRACE_FL_FILTER : FTRACE_FL_NOTRACE; |
| 1794 | 1799 | ||
| @@ -1819,12 +1824,15 @@ static void ftrace_match_module_records(char *buff, char *mod, int enable) | |||
| 1819 | rec->flags &= ~flag; | 1824 | rec->flags &= ~flag; |
| 1820 | else | 1825 | else |
| 1821 | rec->flags |= flag; | 1826 | rec->flags |= flag; |
| 1827 | found = 1; | ||
| 1822 | } | 1828 | } |
| 1823 | if (enable && (rec->flags & FTRACE_FL_FILTER)) | 1829 | if (enable && (rec->flags & FTRACE_FL_FILTER)) |
| 1824 | ftrace_filtered = 1; | 1830 | ftrace_filtered = 1; |
| 1825 | 1831 | ||
| 1826 | } while_for_each_ftrace_rec(); | 1832 | } while_for_each_ftrace_rec(); |
| 1827 | mutex_unlock(&ftrace_lock); | 1833 | mutex_unlock(&ftrace_lock); |
| 1834 | |||
| 1835 | return found; | ||
| 1828 | } | 1836 | } |
| 1829 | 1837 | ||
| 1830 | /* | 1838 | /* |
| @@ -1853,8 +1861,9 @@ ftrace_mod_callback(char *func, char *cmd, char *param, int enable) | |||
| 1853 | if (!strlen(mod)) | 1861 | if (!strlen(mod)) |
| 1854 | return -EINVAL; | 1862 | return -EINVAL; |
| 1855 | 1863 | ||
| 1856 | ftrace_match_module_records(func, mod, enable); | 1864 | if (ftrace_match_module_records(func, mod, enable)) |
| 1857 | return 0; | 1865 | return 0; |
| 1866 | return -EINVAL; | ||
| 1858 | } | 1867 | } |
| 1859 | 1868 | ||
| 1860 | static struct ftrace_func_command ftrace_mod_cmd = { | 1869 | static struct ftrace_func_command ftrace_mod_cmd = { |
| @@ -2151,8 +2160,9 @@ static int ftrace_process_regex(char *buff, int len, int enable) | |||
| 2151 | func = strsep(&next, ":"); | 2160 | func = strsep(&next, ":"); |
| 2152 | 2161 | ||
| 2153 | if (!next) { | 2162 | if (!next) { |
| 2154 | ftrace_match_records(func, len, enable); | 2163 | if (ftrace_match_records(func, len, enable)) |
| 2155 | return 0; | 2164 | return 0; |
| 2165 | return ret; | ||
| 2156 | } | 2166 | } |
| 2157 | 2167 | ||
| 2158 | /* command found */ | 2168 | /* command found */ |
| @@ -2198,10 +2208,9 @@ ftrace_regex_write(struct file *file, const char __user *ubuf, | |||
| 2198 | !trace_parser_cont(parser)) { | 2208 | !trace_parser_cont(parser)) { |
| 2199 | ret = ftrace_process_regex(parser->buffer, | 2209 | ret = ftrace_process_regex(parser->buffer, |
| 2200 | parser->idx, enable); | 2210 | parser->idx, enable); |
| 2211 | trace_parser_clear(parser); | ||
| 2201 | if (ret) | 2212 | if (ret) |
| 2202 | goto out_unlock; | 2213 | goto out_unlock; |
| 2203 | |||
| 2204 | trace_parser_clear(parser); | ||
| 2205 | } | 2214 | } |
| 2206 | 2215 | ||
| 2207 | ret = read; | 2216 | ret = read; |
| @@ -2543,10 +2552,9 @@ ftrace_set_func(unsigned long *array, int *idx, char *buffer) | |||
| 2543 | exists = true; | 2552 | exists = true; |
| 2544 | break; | 2553 | break; |
| 2545 | } | 2554 | } |
| 2546 | if (!exists) { | 2555 | if (!exists) |
| 2547 | array[(*idx)++] = rec->ip; | 2556 | array[(*idx)++] = rec->ip; |
| 2548 | found = 1; | 2557 | found = 1; |
| 2549 | } | ||
| 2550 | } | 2558 | } |
| 2551 | } while_for_each_ftrace_rec(); | 2559 | } while_for_each_ftrace_rec(); |
| 2552 | 2560 | ||
diff --git a/kernel/trace/power-traces.c b/kernel/trace/power-traces.c index e06c6e3d56a3..9f4f565b01e6 100644 --- a/kernel/trace/power-traces.c +++ b/kernel/trace/power-traces.c | |||
| @@ -14,7 +14,5 @@ | |||
| 14 | #define CREATE_TRACE_POINTS | 14 | #define CREATE_TRACE_POINTS |
| 15 | #include <trace/events/power.h> | 15 | #include <trace/events/power.h> |
| 16 | 16 | ||
| 17 | EXPORT_TRACEPOINT_SYMBOL_GPL(power_start); | ||
| 18 | EXPORT_TRACEPOINT_SYMBOL_GPL(power_end); | ||
| 19 | EXPORT_TRACEPOINT_SYMBOL_GPL(power_frequency); | 17 | EXPORT_TRACEPOINT_SYMBOL_GPL(power_frequency); |
| 20 | 18 | ||
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index a1ca4956ab5e..2326b04c95c4 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c | |||
| @@ -423,7 +423,7 @@ struct ring_buffer_per_cpu { | |||
| 423 | int cpu; | 423 | int cpu; |
| 424 | struct ring_buffer *buffer; | 424 | struct ring_buffer *buffer; |
| 425 | spinlock_t reader_lock; /* serialize readers */ | 425 | spinlock_t reader_lock; /* serialize readers */ |
| 426 | raw_spinlock_t lock; | 426 | arch_spinlock_t lock; |
| 427 | struct lock_class_key lock_key; | 427 | struct lock_class_key lock_key; |
| 428 | struct list_head *pages; | 428 | struct list_head *pages; |
| 429 | struct buffer_page *head_page; /* read from head */ | 429 | struct buffer_page *head_page; /* read from head */ |
| @@ -998,7 +998,7 @@ rb_allocate_cpu_buffer(struct ring_buffer *buffer, int cpu) | |||
| 998 | cpu_buffer->buffer = buffer; | 998 | cpu_buffer->buffer = buffer; |
| 999 | spin_lock_init(&cpu_buffer->reader_lock); | 999 | spin_lock_init(&cpu_buffer->reader_lock); |
| 1000 | lockdep_set_class(&cpu_buffer->reader_lock, buffer->reader_lock_key); | 1000 | lockdep_set_class(&cpu_buffer->reader_lock, buffer->reader_lock_key); |
| 1001 | cpu_buffer->lock = (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED; | 1001 | cpu_buffer->lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED; |
| 1002 | 1002 | ||
| 1003 | bpage = kzalloc_node(ALIGN(sizeof(*bpage), cache_line_size()), | 1003 | bpage = kzalloc_node(ALIGN(sizeof(*bpage), cache_line_size()), |
| 1004 | GFP_KERNEL, cpu_to_node(cpu)); | 1004 | GFP_KERNEL, cpu_to_node(cpu)); |
| @@ -1193,9 +1193,6 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned nr_pages) | |||
| 1193 | struct list_head *p; | 1193 | struct list_head *p; |
| 1194 | unsigned i; | 1194 | unsigned i; |
| 1195 | 1195 | ||
| 1196 | atomic_inc(&cpu_buffer->record_disabled); | ||
| 1197 | synchronize_sched(); | ||
| 1198 | |||
| 1199 | spin_lock_irq(&cpu_buffer->reader_lock); | 1196 | spin_lock_irq(&cpu_buffer->reader_lock); |
| 1200 | rb_head_page_deactivate(cpu_buffer); | 1197 | rb_head_page_deactivate(cpu_buffer); |
| 1201 | 1198 | ||
| @@ -1211,12 +1208,9 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned nr_pages) | |||
| 1211 | return; | 1208 | return; |
| 1212 | 1209 | ||
| 1213 | rb_reset_cpu(cpu_buffer); | 1210 | rb_reset_cpu(cpu_buffer); |
| 1214 | spin_unlock_irq(&cpu_buffer->reader_lock); | ||
| 1215 | |||
| 1216 | rb_check_pages(cpu_buffer); | 1211 | rb_check_pages(cpu_buffer); |
| 1217 | 1212 | ||
| 1218 | atomic_dec(&cpu_buffer->record_disabled); | 1213 | spin_unlock_irq(&cpu_buffer->reader_lock); |
| 1219 | |||
| 1220 | } | 1214 | } |
| 1221 | 1215 | ||
| 1222 | static void | 1216 | static void |
| @@ -1227,9 +1221,6 @@ rb_insert_pages(struct ring_buffer_per_cpu *cpu_buffer, | |||
| 1227 | struct list_head *p; | 1221 | struct list_head *p; |
| 1228 | unsigned i; | 1222 | unsigned i; |
| 1229 | 1223 | ||
| 1230 | atomic_inc(&cpu_buffer->record_disabled); | ||
| 1231 | synchronize_sched(); | ||
| 1232 | |||
| 1233 | spin_lock_irq(&cpu_buffer->reader_lock); | 1224 | spin_lock_irq(&cpu_buffer->reader_lock); |
| 1234 | rb_head_page_deactivate(cpu_buffer); | 1225 | rb_head_page_deactivate(cpu_buffer); |
| 1235 | 1226 | ||
| @@ -1242,11 +1233,9 @@ rb_insert_pages(struct ring_buffer_per_cpu *cpu_buffer, | |||
| 1242 | list_add_tail(&bpage->list, cpu_buffer->pages); | 1233 | list_add_tail(&bpage->list, cpu_buffer->pages); |
| 1243 | } | 1234 | } |
| 1244 | rb_reset_cpu(cpu_buffer); | 1235 | rb_reset_cpu(cpu_buffer); |
| 1245 | spin_unlock_irq(&cpu_buffer->reader_lock); | ||
| 1246 | |||
| 1247 | rb_check_pages(cpu_buffer); | 1236 | rb_check_pages(cpu_buffer); |
| 1248 | 1237 | ||
| 1249 | atomic_dec(&cpu_buffer->record_disabled); | 1238 | spin_unlock_irq(&cpu_buffer->reader_lock); |
| 1250 | } | 1239 | } |
| 1251 | 1240 | ||
| 1252 | /** | 1241 | /** |
| @@ -1254,11 +1243,6 @@ rb_insert_pages(struct ring_buffer_per_cpu *cpu_buffer, | |||
| 1254 | * @buffer: the buffer to resize. | 1243 | * @buffer: the buffer to resize. |
| 1255 | * @size: the new size. | 1244 | * @size: the new size. |
| 1256 | * | 1245 | * |
| 1257 | * The tracer is responsible for making sure that the buffer is | ||
| 1258 | * not being used while changing the size. | ||
| 1259 | * Note: We may be able to change the above requirement by using | ||
| 1260 | * RCU synchronizations. | ||
| 1261 | * | ||
| 1262 | * Minimum size is 2 * BUF_PAGE_SIZE. | 1246 | * Minimum size is 2 * BUF_PAGE_SIZE. |
| 1263 | * | 1247 | * |
| 1264 | * Returns -1 on failure. | 1248 | * Returns -1 on failure. |
| @@ -1290,6 +1274,11 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size) | |||
| 1290 | if (size == buffer_size) | 1274 | if (size == buffer_size) |
| 1291 | return size; | 1275 | return size; |
| 1292 | 1276 | ||
| 1277 | atomic_inc(&buffer->record_disabled); | ||
| 1278 | |||
| 1279 | /* Make sure all writers are done with this buffer. */ | ||
| 1280 | synchronize_sched(); | ||
| 1281 | |||
| 1293 | mutex_lock(&buffer->mutex); | 1282 | mutex_lock(&buffer->mutex); |
| 1294 | get_online_cpus(); | 1283 | get_online_cpus(); |
| 1295 | 1284 | ||
| @@ -1352,6 +1341,8 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size) | |||
| 1352 | put_online_cpus(); | 1341 | put_online_cpus(); |
| 1353 | mutex_unlock(&buffer->mutex); | 1342 | mutex_unlock(&buffer->mutex); |
| 1354 | 1343 | ||
| 1344 | atomic_dec(&buffer->record_disabled); | ||
| 1345 | |||
| 1355 | return size; | 1346 | return size; |
| 1356 | 1347 | ||
| 1357 | free_pages: | 1348 | free_pages: |
| @@ -1361,6 +1352,7 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size) | |||
| 1361 | } | 1352 | } |
| 1362 | put_online_cpus(); | 1353 | put_online_cpus(); |
| 1363 | mutex_unlock(&buffer->mutex); | 1354 | mutex_unlock(&buffer->mutex); |
| 1355 | atomic_dec(&buffer->record_disabled); | ||
| 1364 | return -ENOMEM; | 1356 | return -ENOMEM; |
| 1365 | 1357 | ||
| 1366 | /* | 1358 | /* |
| @@ -1370,6 +1362,7 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size) | |||
| 1370 | out_fail: | 1362 | out_fail: |
| 1371 | put_online_cpus(); | 1363 | put_online_cpus(); |
| 1372 | mutex_unlock(&buffer->mutex); | 1364 | mutex_unlock(&buffer->mutex); |
| 1365 | atomic_dec(&buffer->record_disabled); | ||
| 1373 | return -1; | 1366 | return -1; |
| 1374 | } | 1367 | } |
| 1375 | EXPORT_SYMBOL_GPL(ring_buffer_resize); | 1368 | EXPORT_SYMBOL_GPL(ring_buffer_resize); |
| @@ -2834,7 +2827,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer) | |||
| 2834 | int ret; | 2827 | int ret; |
| 2835 | 2828 | ||
| 2836 | local_irq_save(flags); | 2829 | local_irq_save(flags); |
| 2837 | __raw_spin_lock(&cpu_buffer->lock); | 2830 | arch_spin_lock(&cpu_buffer->lock); |
| 2838 | 2831 | ||
| 2839 | again: | 2832 | again: |
| 2840 | /* | 2833 | /* |
| @@ -2923,7 +2916,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer) | |||
| 2923 | goto again; | 2916 | goto again; |
| 2924 | 2917 | ||
| 2925 | out: | 2918 | out: |
| 2926 | __raw_spin_unlock(&cpu_buffer->lock); | 2919 | arch_spin_unlock(&cpu_buffer->lock); |
| 2927 | local_irq_restore(flags); | 2920 | local_irq_restore(flags); |
| 2928 | 2921 | ||
| 2929 | return reader; | 2922 | return reader; |
| @@ -3286,9 +3279,9 @@ ring_buffer_read_start(struct ring_buffer *buffer, int cpu) | |||
| 3286 | synchronize_sched(); | 3279 | synchronize_sched(); |
| 3287 | 3280 | ||
| 3288 | spin_lock_irqsave(&cpu_buffer->reader_lock, flags); | 3281 | spin_lock_irqsave(&cpu_buffer->reader_lock, flags); |
| 3289 | __raw_spin_lock(&cpu_buffer->lock); | 3282 | arch_spin_lock(&cpu_buffer->lock); |
| 3290 | rb_iter_reset(iter); | 3283 | rb_iter_reset(iter); |
| 3291 | __raw_spin_unlock(&cpu_buffer->lock); | 3284 | arch_spin_unlock(&cpu_buffer->lock); |
| 3292 | spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags); | 3285 | spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags); |
| 3293 | 3286 | ||
| 3294 | return iter; | 3287 | return iter; |
| @@ -3408,11 +3401,11 @@ void ring_buffer_reset_cpu(struct ring_buffer *buffer, int cpu) | |||
| 3408 | if (RB_WARN_ON(cpu_buffer, local_read(&cpu_buffer->committing))) | 3401 | if (RB_WARN_ON(cpu_buffer, local_read(&cpu_buffer->committing))) |
| 3409 | goto out; | 3402 | goto out; |
| 3410 | 3403 | ||
| 3411 | __raw_spin_lock(&cpu_buffer->lock); | 3404 | arch_spin_lock(&cpu_buffer->lock); |
| 3412 | 3405 | ||
| 3413 | rb_reset_cpu(cpu_buffer); | 3406 | rb_reset_cpu(cpu_buffer); |
| 3414 | 3407 | ||
| 3415 | __raw_spin_unlock(&cpu_buffer->lock); | 3408 | arch_spin_unlock(&cpu_buffer->lock); |
| 3416 | 3409 | ||
| 3417 | out: | 3410 | out: |
| 3418 | spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags); | 3411 | spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags); |
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 874f2893cff0..0df1b0f2cb9e 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | * Copyright (C) 2004 William Lee Irwin III | 12 | * Copyright (C) 2004 William Lee Irwin III |
| 13 | */ | 13 | */ |
| 14 | #include <linux/ring_buffer.h> | 14 | #include <linux/ring_buffer.h> |
| 15 | #include <linux/utsrelease.h> | 15 | #include <generated/utsrelease.h> |
| 16 | #include <linux/stacktrace.h> | 16 | #include <linux/stacktrace.h> |
| 17 | #include <linux/writeback.h> | 17 | #include <linux/writeback.h> |
| 18 | #include <linux/kallsyms.h> | 18 | #include <linux/kallsyms.h> |
| @@ -86,17 +86,17 @@ static int dummy_set_flag(u32 old_flags, u32 bit, int set) | |||
| 86 | */ | 86 | */ |
| 87 | static int tracing_disabled = 1; | 87 | static int tracing_disabled = 1; |
| 88 | 88 | ||
| 89 | DEFINE_PER_CPU(local_t, ftrace_cpu_disabled); | 89 | DEFINE_PER_CPU(int, ftrace_cpu_disabled); |
| 90 | 90 | ||
| 91 | static inline void ftrace_disable_cpu(void) | 91 | static inline void ftrace_disable_cpu(void) |
| 92 | { | 92 | { |
| 93 | preempt_disable(); | 93 | preempt_disable(); |
| 94 | local_inc(&__get_cpu_var(ftrace_cpu_disabled)); | 94 | __this_cpu_inc(per_cpu_var(ftrace_cpu_disabled)); |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | static inline void ftrace_enable_cpu(void) | 97 | static inline void ftrace_enable_cpu(void) |
| 98 | { | 98 | { |
| 99 | local_dec(&__get_cpu_var(ftrace_cpu_disabled)); | 99 | __this_cpu_dec(per_cpu_var(ftrace_cpu_disabled)); |
| 100 | preempt_enable(); | 100 | preempt_enable(); |
| 101 | } | 101 | } |
| 102 | 102 | ||
| @@ -203,7 +203,7 @@ cycle_t ftrace_now(int cpu) | |||
| 203 | */ | 203 | */ |
| 204 | static struct trace_array max_tr; | 204 | static struct trace_array max_tr; |
| 205 | 205 | ||
| 206 | static DEFINE_PER_CPU(struct trace_array_cpu, max_data); | 206 | static DEFINE_PER_CPU(struct trace_array_cpu, max_tr_data); |
| 207 | 207 | ||
| 208 | /* tracer_enabled is used to toggle activation of a tracer */ | 208 | /* tracer_enabled is used to toggle activation of a tracer */ |
| 209 | static int tracer_enabled = 1; | 209 | static int tracer_enabled = 1; |
| @@ -313,7 +313,6 @@ static const char *trace_options[] = { | |||
| 313 | "bin", | 313 | "bin", |
| 314 | "block", | 314 | "block", |
| 315 | "stacktrace", | 315 | "stacktrace", |
| 316 | "sched-tree", | ||
| 317 | "trace_printk", | 316 | "trace_printk", |
| 318 | "ftrace_preempt", | 317 | "ftrace_preempt", |
| 319 | "branch", | 318 | "branch", |
| @@ -493,15 +492,15 @@ static ssize_t trace_seq_to_buffer(struct trace_seq *s, void *buf, size_t cnt) | |||
| 493 | * protected by per_cpu spinlocks. But the action of the swap | 492 | * protected by per_cpu spinlocks. But the action of the swap |
| 494 | * needs its own lock. | 493 | * needs its own lock. |
| 495 | * | 494 | * |
| 496 | * This is defined as a raw_spinlock_t in order to help | 495 | * This is defined as a arch_spinlock_t in order to help |
| 497 | * with performance when lockdep debugging is enabled. | 496 | * with performance when lockdep debugging is enabled. |
| 498 | * | 497 | * |
| 499 | * It is also used in other places outside the update_max_tr | 498 | * It is also used in other places outside the update_max_tr |
| 500 | * so it needs to be defined outside of the | 499 | * so it needs to be defined outside of the |
| 501 | * CONFIG_TRACER_MAX_TRACE. | 500 | * CONFIG_TRACER_MAX_TRACE. |
| 502 | */ | 501 | */ |
| 503 | static raw_spinlock_t ftrace_max_lock = | 502 | static arch_spinlock_t ftrace_max_lock = |
| 504 | (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED; | 503 | (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED; |
| 505 | 504 | ||
| 506 | #ifdef CONFIG_TRACER_MAX_TRACE | 505 | #ifdef CONFIG_TRACER_MAX_TRACE |
| 507 | unsigned long __read_mostly tracing_max_latency; | 506 | unsigned long __read_mostly tracing_max_latency; |
| @@ -555,13 +554,13 @@ update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu) | |||
| 555 | return; | 554 | return; |
| 556 | 555 | ||
| 557 | WARN_ON_ONCE(!irqs_disabled()); | 556 | WARN_ON_ONCE(!irqs_disabled()); |
| 558 | __raw_spin_lock(&ftrace_max_lock); | 557 | arch_spin_lock(&ftrace_max_lock); |
| 559 | 558 | ||
| 560 | tr->buffer = max_tr.buffer; | 559 | tr->buffer = max_tr.buffer; |
| 561 | max_tr.buffer = buf; | 560 | max_tr.buffer = buf; |
| 562 | 561 | ||
| 563 | __update_max_tr(tr, tsk, cpu); | 562 | __update_max_tr(tr, tsk, cpu); |
| 564 | __raw_spin_unlock(&ftrace_max_lock); | 563 | arch_spin_unlock(&ftrace_max_lock); |
| 565 | } | 564 | } |
| 566 | 565 | ||
| 567 | /** | 566 | /** |
| @@ -581,7 +580,7 @@ update_max_tr_single(struct trace_array *tr, struct task_struct *tsk, int cpu) | |||
| 581 | return; | 580 | return; |
| 582 | 581 | ||
| 583 | WARN_ON_ONCE(!irqs_disabled()); | 582 | WARN_ON_ONCE(!irqs_disabled()); |
| 584 | __raw_spin_lock(&ftrace_max_lock); | 583 | arch_spin_lock(&ftrace_max_lock); |
| 585 | 584 | ||
| 586 | ftrace_disable_cpu(); | 585 | ftrace_disable_cpu(); |
| 587 | 586 | ||
| @@ -603,7 +602,7 @@ update_max_tr_single(struct trace_array *tr, struct task_struct *tsk, int cpu) | |||
| 603 | WARN_ON_ONCE(ret && ret != -EAGAIN && ret != -EBUSY); | 602 | WARN_ON_ONCE(ret && ret != -EAGAIN && ret != -EBUSY); |
| 604 | 603 | ||
| 605 | __update_max_tr(tr, tsk, cpu); | 604 | __update_max_tr(tr, tsk, cpu); |
| 606 | __raw_spin_unlock(&ftrace_max_lock); | 605 | arch_spin_unlock(&ftrace_max_lock); |
| 607 | } | 606 | } |
| 608 | #endif /* CONFIG_TRACER_MAX_TRACE */ | 607 | #endif /* CONFIG_TRACER_MAX_TRACE */ |
| 609 | 608 | ||
| @@ -802,7 +801,7 @@ static unsigned map_pid_to_cmdline[PID_MAX_DEFAULT+1]; | |||
| 802 | static unsigned map_cmdline_to_pid[SAVED_CMDLINES]; | 801 | static unsigned map_cmdline_to_pid[SAVED_CMDLINES]; |
| 803 | static char saved_cmdlines[SAVED_CMDLINES][TASK_COMM_LEN]; | 802 | static char saved_cmdlines[SAVED_CMDLINES][TASK_COMM_LEN]; |
| 804 | static int cmdline_idx; | 803 | static int cmdline_idx; |
| 805 | static raw_spinlock_t trace_cmdline_lock = __RAW_SPIN_LOCK_UNLOCKED; | 804 | static arch_spinlock_t trace_cmdline_lock = __ARCH_SPIN_LOCK_UNLOCKED; |
| 806 | 805 | ||
| 807 | /* temporary disable recording */ | 806 | /* temporary disable recording */ |
| 808 | static atomic_t trace_record_cmdline_disabled __read_mostly; | 807 | static atomic_t trace_record_cmdline_disabled __read_mostly; |
| @@ -915,7 +914,7 @@ static void trace_save_cmdline(struct task_struct *tsk) | |||
| 915 | * nor do we want to disable interrupts, | 914 | * nor do we want to disable interrupts, |
| 916 | * so if we miss here, then better luck next time. | 915 | * so if we miss here, then better luck next time. |
| 917 | */ | 916 | */ |
| 918 | if (!__raw_spin_trylock(&trace_cmdline_lock)) | 917 | if (!arch_spin_trylock(&trace_cmdline_lock)) |
| 919 | return; | 918 | return; |
| 920 | 919 | ||
| 921 | idx = map_pid_to_cmdline[tsk->pid]; | 920 | idx = map_pid_to_cmdline[tsk->pid]; |
| @@ -940,7 +939,7 @@ static void trace_save_cmdline(struct task_struct *tsk) | |||
| 940 | 939 | ||
| 941 | memcpy(&saved_cmdlines[idx], tsk->comm, TASK_COMM_LEN); | 940 | memcpy(&saved_cmdlines[idx], tsk->comm, TASK_COMM_LEN); |
| 942 | 941 | ||
| 943 | __raw_spin_unlock(&trace_cmdline_lock); | 942 | arch_spin_unlock(&trace_cmdline_lock); |
| 944 | } | 943 | } |
| 945 | 944 | ||
| 946 | void trace_find_cmdline(int pid, char comm[]) | 945 | void trace_find_cmdline(int pid, char comm[]) |
| @@ -958,14 +957,14 @@ void trace_find_cmdline(int pid, char comm[]) | |||
| 958 | } | 957 | } |
| 959 | 958 | ||
| 960 | preempt_disable(); | 959 | preempt_disable(); |
| 961 | __raw_spin_lock(&trace_cmdline_lock); | 960 | arch_spin_lock(&trace_cmdline_lock); |
| 962 | map = map_pid_to_cmdline[pid]; | 961 | map = map_pid_to_cmdline[pid]; |
| 963 | if (map != NO_CMDLINE_MAP) | 962 | if (map != NO_CMDLINE_MAP) |
| 964 | strcpy(comm, saved_cmdlines[map]); | 963 | strcpy(comm, saved_cmdlines[map]); |
| 965 | else | 964 | else |
| 966 | strcpy(comm, "<...>"); | 965 | strcpy(comm, "<...>"); |
| 967 | 966 | ||
| 968 | __raw_spin_unlock(&trace_cmdline_lock); | 967 | arch_spin_unlock(&trace_cmdline_lock); |
| 969 | preempt_enable(); | 968 | preempt_enable(); |
| 970 | } | 969 | } |
| 971 | 970 | ||
| @@ -1085,7 +1084,7 @@ trace_function(struct trace_array *tr, | |||
| 1085 | struct ftrace_entry *entry; | 1084 | struct ftrace_entry *entry; |
| 1086 | 1085 | ||
| 1087 | /* If we are reading the ring buffer, don't trace */ | 1086 | /* If we are reading the ring buffer, don't trace */ |
| 1088 | if (unlikely(local_read(&__get_cpu_var(ftrace_cpu_disabled)))) | 1087 | if (unlikely(__this_cpu_read(per_cpu_var(ftrace_cpu_disabled)))) |
| 1089 | return; | 1088 | return; |
| 1090 | 1089 | ||
| 1091 | event = trace_buffer_lock_reserve(buffer, TRACE_FN, sizeof(*entry), | 1090 | event = trace_buffer_lock_reserve(buffer, TRACE_FN, sizeof(*entry), |
| @@ -1151,6 +1150,22 @@ void __trace_stack(struct trace_array *tr, unsigned long flags, int skip, | |||
| 1151 | __ftrace_trace_stack(tr->buffer, flags, skip, pc); | 1150 | __ftrace_trace_stack(tr->buffer, flags, skip, pc); |
| 1152 | } | 1151 | } |
| 1153 | 1152 | ||
| 1153 | /** | ||
| 1154 | * trace_dump_stack - record a stack back trace in the trace buffer | ||
| 1155 | */ | ||
| 1156 | void trace_dump_stack(void) | ||
| 1157 | { | ||
| 1158 | unsigned long flags; | ||
| 1159 | |||
| 1160 | if (tracing_disabled || tracing_selftest_running) | ||
| 1161 | return; | ||
| 1162 | |||
| 1163 | local_save_flags(flags); | ||
| 1164 | |||
| 1165 | /* skipping 3 traces, seems to get us at the caller of this function */ | ||
| 1166 | __ftrace_trace_stack(global_trace.buffer, flags, 3, preempt_count()); | ||
| 1167 | } | ||
| 1168 | |||
| 1154 | void | 1169 | void |
| 1155 | ftrace_trace_userstack(struct ring_buffer *buffer, unsigned long flags, int pc) | 1170 | ftrace_trace_userstack(struct ring_buffer *buffer, unsigned long flags, int pc) |
| 1156 | { | 1171 | { |
| @@ -1251,8 +1266,8 @@ ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) | |||
| 1251 | */ | 1266 | */ |
| 1252 | int trace_vbprintk(unsigned long ip, const char *fmt, va_list args) | 1267 | int trace_vbprintk(unsigned long ip, const char *fmt, va_list args) |
| 1253 | { | 1268 | { |
| 1254 | static raw_spinlock_t trace_buf_lock = | 1269 | static arch_spinlock_t trace_buf_lock = |
| 1255 | (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED; | 1270 | (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED; |
| 1256 | static u32 trace_buf[TRACE_BUF_SIZE]; | 1271 | static u32 trace_buf[TRACE_BUF_SIZE]; |
| 1257 | 1272 | ||
| 1258 | struct ftrace_event_call *call = &event_bprint; | 1273 | struct ftrace_event_call *call = &event_bprint; |
| @@ -1283,7 +1298,7 @@ int trace_vbprintk(unsigned long ip, const char *fmt, va_list args) | |||
| 1283 | 1298 | ||
| 1284 | /* Lockdep uses trace_printk for lock tracing */ | 1299 | /* Lockdep uses trace_printk for lock tracing */ |
| 1285 | local_irq_save(flags); | 1300 | local_irq_save(flags); |
| 1286 | __raw_spin_lock(&trace_buf_lock); | 1301 | arch_spin_lock(&trace_buf_lock); |
| 1287 | len = vbin_printf(trace_buf, TRACE_BUF_SIZE, fmt, args); | 1302 | len = vbin_printf(trace_buf, TRACE_BUF_SIZE, fmt, args); |
| 1288 | 1303 | ||
| 1289 | if (len > TRACE_BUF_SIZE || len < 0) | 1304 | if (len > TRACE_BUF_SIZE || len < 0) |
| @@ -1304,7 +1319,7 @@ int trace_vbprintk(unsigned long ip, const char *fmt, va_list args) | |||
| 1304 | ring_buffer_unlock_commit(buffer, event); | 1319 | ring_buffer_unlock_commit(buffer, event); |
| 1305 | 1320 | ||
| 1306 | out_unlock: | 1321 | out_unlock: |
| 1307 | __raw_spin_unlock(&trace_buf_lock); | 1322 | arch_spin_unlock(&trace_buf_lock); |
| 1308 | local_irq_restore(flags); | 1323 | local_irq_restore(flags); |
| 1309 | 1324 | ||
| 1310 | out: | 1325 | out: |
| @@ -1334,7 +1349,7 @@ int trace_array_printk(struct trace_array *tr, | |||
| 1334 | int trace_array_vprintk(struct trace_array *tr, | 1349 | int trace_array_vprintk(struct trace_array *tr, |
| 1335 | unsigned long ip, const char *fmt, va_list args) | 1350 | unsigned long ip, const char *fmt, va_list args) |
| 1336 | { | 1351 | { |
| 1337 | static raw_spinlock_t trace_buf_lock = __RAW_SPIN_LOCK_UNLOCKED; | 1352 | static arch_spinlock_t trace_buf_lock = __ARCH_SPIN_LOCK_UNLOCKED; |
| 1338 | static char trace_buf[TRACE_BUF_SIZE]; | 1353 | static char trace_buf[TRACE_BUF_SIZE]; |
| 1339 | 1354 | ||
| 1340 | struct ftrace_event_call *call = &event_print; | 1355 | struct ftrace_event_call *call = &event_print; |
| @@ -1360,12 +1375,8 @@ int trace_array_vprintk(struct trace_array *tr, | |||
| 1360 | 1375 | ||
| 1361 | pause_graph_tracing(); | 1376 | pause_graph_tracing(); |
| 1362 | raw_local_irq_save(irq_flags); | 1377 | raw_local_irq_save(irq_flags); |
| 1363 | __raw_spin_lock(&trace_buf_lock); | 1378 | arch_spin_lock(&trace_buf_lock); |
| 1364 | if (args == NULL) { | 1379 | len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args); |
| 1365 | strncpy(trace_buf, fmt, TRACE_BUF_SIZE); | ||
| 1366 | len = strlen(trace_buf); | ||
| 1367 | } else | ||
| 1368 | len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args); | ||
| 1369 | 1380 | ||
| 1370 | size = sizeof(*entry) + len + 1; | 1381 | size = sizeof(*entry) + len + 1; |
| 1371 | buffer = tr->buffer; | 1382 | buffer = tr->buffer; |
| @@ -1382,7 +1393,7 @@ int trace_array_vprintk(struct trace_array *tr, | |||
| 1382 | ring_buffer_unlock_commit(buffer, event); | 1393 | ring_buffer_unlock_commit(buffer, event); |
| 1383 | 1394 | ||
| 1384 | out_unlock: | 1395 | out_unlock: |
| 1385 | __raw_spin_unlock(&trace_buf_lock); | 1396 | arch_spin_unlock(&trace_buf_lock); |
| 1386 | raw_local_irq_restore(irq_flags); | 1397 | raw_local_irq_restore(irq_flags); |
| 1387 | unpause_graph_tracing(); | 1398 | unpause_graph_tracing(); |
| 1388 | out: | 1399 | out: |
| @@ -1516,6 +1527,8 @@ static void *s_next(struct seq_file *m, void *v, loff_t *pos) | |||
| 1516 | int i = (int)*pos; | 1527 | int i = (int)*pos; |
| 1517 | void *ent; | 1528 | void *ent; |
| 1518 | 1529 | ||
| 1530 | WARN_ON_ONCE(iter->leftover); | ||
| 1531 | |||
| 1519 | (*pos)++; | 1532 | (*pos)++; |
| 1520 | 1533 | ||
| 1521 | /* can't go backwards */ | 1534 | /* can't go backwards */ |
| @@ -1614,8 +1627,16 @@ static void *s_start(struct seq_file *m, loff_t *pos) | |||
| 1614 | ; | 1627 | ; |
| 1615 | 1628 | ||
| 1616 | } else { | 1629 | } else { |
| 1617 | l = *pos - 1; | 1630 | /* |
| 1618 | p = s_next(m, p, &l); | 1631 | * If we overflowed the seq_file before, then we want |
| 1632 | * to just reuse the trace_seq buffer again. | ||
| 1633 | */ | ||
| 1634 | if (iter->leftover) | ||
| 1635 | p = iter; | ||
| 1636 | else { | ||
| 1637 | l = *pos - 1; | ||
| 1638 | p = s_next(m, p, &l); | ||
| 1639 | } | ||
| 1619 | } | 1640 | } |
| 1620 | 1641 | ||
| 1621 | trace_event_read_lock(); | 1642 | trace_event_read_lock(); |
| @@ -1923,6 +1944,7 @@ static enum print_line_t print_trace_line(struct trace_iterator *iter) | |||
| 1923 | static int s_show(struct seq_file *m, void *v) | 1944 | static int s_show(struct seq_file *m, void *v) |
| 1924 | { | 1945 | { |
| 1925 | struct trace_iterator *iter = v; | 1946 | struct trace_iterator *iter = v; |
| 1947 | int ret; | ||
| 1926 | 1948 | ||
| 1927 | if (iter->ent == NULL) { | 1949 | if (iter->ent == NULL) { |
| 1928 | if (iter->tr) { | 1950 | if (iter->tr) { |
| @@ -1942,9 +1964,27 @@ static int s_show(struct seq_file *m, void *v) | |||
| 1942 | if (!(trace_flags & TRACE_ITER_VERBOSE)) | 1964 | if (!(trace_flags & TRACE_ITER_VERBOSE)) |
| 1943 | print_func_help_header(m); | 1965 | print_func_help_header(m); |
| 1944 | } | 1966 | } |
| 1967 | } else if (iter->leftover) { | ||
| 1968 | /* | ||
| 1969 | * If we filled the seq_file buffer earlier, we | ||
| 1970 | * want to just show it now. | ||
| 1971 | */ | ||
| 1972 | ret = trace_print_seq(m, &iter->seq); | ||
| 1973 | |||
| 1974 | /* ret should this time be zero, but you never know */ | ||
| 1975 | iter->leftover = ret; | ||
| 1976 | |||
| 1945 | } else { | 1977 | } else { |
| 1946 | print_trace_line(iter); | 1978 | print_trace_line(iter); |
| 1947 | trace_print_seq(m, &iter->seq); | 1979 | ret = trace_print_seq(m, &iter->seq); |
| 1980 | /* | ||
| 1981 | * If we overflow the seq_file buffer, then it will | ||
| 1982 | * ask us for this data again at start up. | ||
| 1983 | * Use that instead. | ||
| 1984 | * ret is 0 if seq_file write succeeded. | ||
| 1985 | * -1 otherwise. | ||
| 1986 | */ | ||
| 1987 | iter->leftover = ret; | ||
| 1948 | } | 1988 | } |
| 1949 | 1989 | ||
| 1950 | return 0; | 1990 | return 0; |
| @@ -2254,7 +2294,7 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf, | |||
| 2254 | mutex_lock(&tracing_cpumask_update_lock); | 2294 | mutex_lock(&tracing_cpumask_update_lock); |
| 2255 | 2295 | ||
| 2256 | local_irq_disable(); | 2296 | local_irq_disable(); |
| 2257 | __raw_spin_lock(&ftrace_max_lock); | 2297 | arch_spin_lock(&ftrace_max_lock); |
| 2258 | for_each_tracing_cpu(cpu) { | 2298 | for_each_tracing_cpu(cpu) { |
| 2259 | /* | 2299 | /* |
| 2260 | * Increase/decrease the disabled counter if we are | 2300 | * Increase/decrease the disabled counter if we are |
| @@ -2269,7 +2309,7 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf, | |||
| 2269 | atomic_dec(&global_trace.data[cpu]->disabled); | 2309 | atomic_dec(&global_trace.data[cpu]->disabled); |
| 2270 | } | 2310 | } |
| 2271 | } | 2311 | } |
| 2272 | __raw_spin_unlock(&ftrace_max_lock); | 2312 | arch_spin_unlock(&ftrace_max_lock); |
| 2273 | local_irq_enable(); | 2313 | local_irq_enable(); |
| 2274 | 2314 | ||
| 2275 | cpumask_copy(tracing_cpumask, tracing_cpumask_new); | 2315 | cpumask_copy(tracing_cpumask, tracing_cpumask_new); |
| @@ -2291,67 +2331,49 @@ static const struct file_operations tracing_cpumask_fops = { | |||
| 2291 | .write = tracing_cpumask_write, | 2331 | .write = tracing_cpumask_write, |
| 2292 | }; | 2332 | }; |
| 2293 | 2333 | ||
| 2294 | static ssize_t | 2334 | static int tracing_trace_options_show(struct seq_file *m, void *v) |
| 2295 | tracing_trace_options_read(struct file *filp, char __user *ubuf, | ||
| 2296 | size_t cnt, loff_t *ppos) | ||
| 2297 | { | 2335 | { |
| 2298 | struct tracer_opt *trace_opts; | 2336 | struct tracer_opt *trace_opts; |
| 2299 | u32 tracer_flags; | 2337 | u32 tracer_flags; |
| 2300 | int len = 0; | ||
| 2301 | char *buf; | ||
| 2302 | int r = 0; | ||
| 2303 | int i; | 2338 | int i; |
| 2304 | 2339 | ||
| 2305 | |||
| 2306 | /* calculate max size */ | ||
| 2307 | for (i = 0; trace_options[i]; i++) { | ||
| 2308 | len += strlen(trace_options[i]); | ||
| 2309 | len += 3; /* "no" and newline */ | ||
| 2310 | } | ||
| 2311 | |||
| 2312 | mutex_lock(&trace_types_lock); | 2340 | mutex_lock(&trace_types_lock); |
| 2313 | tracer_flags = current_trace->flags->val; | 2341 | tracer_flags = current_trace->flags->val; |
| 2314 | trace_opts = current_trace->flags->opts; | 2342 | trace_opts = current_trace->flags->opts; |
| 2315 | 2343 | ||
| 2316 | /* | ||
| 2317 | * Increase the size with names of options specific | ||
| 2318 | * of the current tracer. | ||
| 2319 | */ | ||
| 2320 | for (i = 0; trace_opts[i].name; i++) { | ||
| 2321 | len += strlen(trace_opts[i].name); | ||
| 2322 | len += 3; /* "no" and newline */ | ||
| 2323 | } | ||
| 2324 | |||
| 2325 | /* +1 for \0 */ | ||
| 2326 | buf = kmalloc(len + 1, GFP_KERNEL); | ||
| 2327 | if (!buf) { | ||
| 2328 | mutex_unlock(&trace_types_lock); | ||
| 2329 | return -ENOMEM; | ||
| 2330 | } | ||
| 2331 | |||
| 2332 | for (i = 0; trace_options[i]; i++) { | 2344 | for (i = 0; trace_options[i]; i++) { |
| 2333 | if (trace_flags & (1 << i)) | 2345 | if (trace_flags & (1 << i)) |
| 2334 | r += sprintf(buf + r, "%s\n", trace_options[i]); | 2346 | seq_printf(m, "%s\n", trace_options[i]); |
| 2335 | else | 2347 | else |
| 2336 | r += sprintf(buf + r, "no%s\n", trace_options[i]); | 2348 | seq_printf(m, "no%s\n", trace_options[i]); |
| 2337 | } | 2349 | } |
| 2338 | 2350 | ||
| 2339 | for (i = 0; trace_opts[i].name; i++) { | 2351 | for (i = 0; trace_opts[i].name; i++) { |
| 2340 | if (tracer_flags & trace_opts[i].bit) | 2352 | if (tracer_flags & trace_opts[i].bit) |
| 2341 | r += sprintf(buf + r, "%s\n", | 2353 | seq_printf(m, "%s\n", trace_opts[i].name); |
| 2342 | trace_opts[i].name); | ||
| 2343 | else | 2354 | else |
| 2344 | r += sprintf(buf + r, "no%s\n", | 2355 | seq_printf(m, "no%s\n", trace_opts[i].name); |
| 2345 | trace_opts[i].name); | ||
| 2346 | } | 2356 | } |
| 2347 | mutex_unlock(&trace_types_lock); | 2357 | mutex_unlock(&trace_types_lock); |
| 2348 | 2358 | ||
| 2349 | WARN_ON(r >= len + 1); | 2359 | return 0; |
| 2360 | } | ||
| 2350 | 2361 | ||
| 2351 | r = simple_read_from_buffer(ubuf, cnt, ppos, buf, r); | 2362 | static int __set_tracer_option(struct tracer *trace, |
| 2363 | struct tracer_flags *tracer_flags, | ||
| 2364 | struct tracer_opt *opts, int neg) | ||
| 2365 | { | ||
| 2366 | int ret; | ||
| 2352 | 2367 | ||
| 2353 | kfree(buf); | 2368 | ret = trace->set_flag(tracer_flags->val, opts->bit, !neg); |
| 2354 | return r; | 2369 | if (ret) |
| 2370 | return ret; | ||
| 2371 | |||
| 2372 | if (neg) | ||
| 2373 | tracer_flags->val &= ~opts->bit; | ||
| 2374 | else | ||
| 2375 | tracer_flags->val |= opts->bit; | ||
| 2376 | return 0; | ||
| 2355 | } | 2377 | } |
| 2356 | 2378 | ||
| 2357 | /* Try to assign a tracer specific option */ | 2379 | /* Try to assign a tracer specific option */ |
| @@ -2359,33 +2381,17 @@ static int set_tracer_option(struct tracer *trace, char *cmp, int neg) | |||
| 2359 | { | 2381 | { |
| 2360 | struct tracer_flags *tracer_flags = trace->flags; | 2382 | struct tracer_flags *tracer_flags = trace->flags; |
| 2361 | struct tracer_opt *opts = NULL; | 2383 | struct tracer_opt *opts = NULL; |
| 2362 | int ret = 0, i = 0; | 2384 | int i; |
| 2363 | int len; | ||
| 2364 | 2385 | ||
| 2365 | for (i = 0; tracer_flags->opts[i].name; i++) { | 2386 | for (i = 0; tracer_flags->opts[i].name; i++) { |
| 2366 | opts = &tracer_flags->opts[i]; | 2387 | opts = &tracer_flags->opts[i]; |
| 2367 | len = strlen(opts->name); | ||
| 2368 | 2388 | ||
| 2369 | if (strncmp(cmp, opts->name, len) == 0) { | 2389 | if (strcmp(cmp, opts->name) == 0) |
| 2370 | ret = trace->set_flag(tracer_flags->val, | 2390 | return __set_tracer_option(trace, trace->flags, |
| 2371 | opts->bit, !neg); | 2391 | opts, neg); |
| 2372 | break; | ||
| 2373 | } | ||
| 2374 | } | 2392 | } |
| 2375 | /* Not found */ | ||
| 2376 | if (!tracer_flags->opts[i].name) | ||
| 2377 | return -EINVAL; | ||
| 2378 | |||
| 2379 | /* Refused to handle */ | ||
| 2380 | if (ret) | ||
| 2381 | return ret; | ||
| 2382 | |||
| 2383 | if (neg) | ||
| 2384 | tracer_flags->val &= ~opts->bit; | ||
| 2385 | else | ||
| 2386 | tracer_flags->val |= opts->bit; | ||
| 2387 | 2393 | ||
| 2388 | return 0; | 2394 | return -EINVAL; |
| 2389 | } | 2395 | } |
| 2390 | 2396 | ||
| 2391 | static void set_tracer_flags(unsigned int mask, int enabled) | 2397 | static void set_tracer_flags(unsigned int mask, int enabled) |
| @@ -2405,7 +2411,7 @@ tracing_trace_options_write(struct file *filp, const char __user *ubuf, | |||
| 2405 | size_t cnt, loff_t *ppos) | 2411 | size_t cnt, loff_t *ppos) |
| 2406 | { | 2412 | { |
| 2407 | char buf[64]; | 2413 | char buf[64]; |
| 2408 | char *cmp = buf; | 2414 | char *cmp; |
| 2409 | int neg = 0; | 2415 | int neg = 0; |
| 2410 | int ret; | 2416 | int ret; |
| 2411 | int i; | 2417 | int i; |
| @@ -2417,16 +2423,15 @@ tracing_trace_options_write(struct file *filp, const char __user *ubuf, | |||
| 2417 | return -EFAULT; | 2423 | return -EFAULT; |
| 2418 | 2424 | ||
| 2419 | buf[cnt] = 0; | 2425 | buf[cnt] = 0; |
| 2426 | cmp = strstrip(buf); | ||
| 2420 | 2427 | ||
| 2421 | if (strncmp(buf, "no", 2) == 0) { | 2428 | if (strncmp(cmp, "no", 2) == 0) { |
| 2422 | neg = 1; | 2429 | neg = 1; |
| 2423 | cmp += 2; | 2430 | cmp += 2; |
| 2424 | } | 2431 | } |
| 2425 | 2432 | ||
| 2426 | for (i = 0; trace_options[i]; i++) { | 2433 | for (i = 0; trace_options[i]; i++) { |
| 2427 | int len = strlen(trace_options[i]); | 2434 | if (strcmp(cmp, trace_options[i]) == 0) { |
| 2428 | |||
| 2429 | if (strncmp(cmp, trace_options[i], len) == 0) { | ||
| 2430 | set_tracer_flags(1 << i, !neg); | 2435 | set_tracer_flags(1 << i, !neg); |
| 2431 | break; | 2436 | break; |
| 2432 | } | 2437 | } |
| @@ -2446,9 +2451,18 @@ tracing_trace_options_write(struct file *filp, const char __user *ubuf, | |||
| 2446 | return cnt; | 2451 | return cnt; |
| 2447 | } | 2452 | } |
| 2448 | 2453 | ||
| 2454 | static int tracing_trace_options_open(struct inode *inode, struct file *file) | ||
| 2455 | { | ||
| 2456 | if (tracing_disabled) | ||
| 2457 | return -ENODEV; | ||
| 2458 | return single_open(file, tracing_trace_options_show, NULL); | ||
| 2459 | } | ||
| 2460 | |||
| 2449 | static const struct file_operations tracing_iter_fops = { | 2461 | static const struct file_operations tracing_iter_fops = { |
| 2450 | .open = tracing_open_generic, | 2462 | .open = tracing_trace_options_open, |
| 2451 | .read = tracing_trace_options_read, | 2463 | .read = seq_read, |
| 2464 | .llseek = seq_lseek, | ||
| 2465 | .release = single_release, | ||
| 2452 | .write = tracing_trace_options_write, | 2466 | .write = tracing_trace_options_write, |
| 2453 | }; | 2467 | }; |
| 2454 | 2468 | ||
| @@ -2898,6 +2912,10 @@ static int tracing_release_pipe(struct inode *inode, struct file *file) | |||
| 2898 | else | 2912 | else |
| 2899 | cpumask_clear_cpu(iter->cpu_file, tracing_reader_cpumask); | 2913 | cpumask_clear_cpu(iter->cpu_file, tracing_reader_cpumask); |
| 2900 | 2914 | ||
| 2915 | |||
| 2916 | if (iter->trace->pipe_close) | ||
| 2917 | iter->trace->pipe_close(iter); | ||
| 2918 | |||
| 2901 | mutex_unlock(&trace_types_lock); | 2919 | mutex_unlock(&trace_types_lock); |
| 2902 | 2920 | ||
| 2903 | free_cpumask_var(iter->started); | 2921 | free_cpumask_var(iter->started); |
| @@ -3104,7 +3122,7 @@ static void tracing_spd_release_pipe(struct splice_pipe_desc *spd, | |||
| 3104 | __free_page(spd->pages[idx]); | 3122 | __free_page(spd->pages[idx]); |
| 3105 | } | 3123 | } |
| 3106 | 3124 | ||
| 3107 | static struct pipe_buf_operations tracing_pipe_buf_ops = { | 3125 | static const struct pipe_buf_operations tracing_pipe_buf_ops = { |
| 3108 | .can_merge = 0, | 3126 | .can_merge = 0, |
| 3109 | .map = generic_pipe_buf_map, | 3127 | .map = generic_pipe_buf_map, |
| 3110 | .unmap = generic_pipe_buf_unmap, | 3128 | .unmap = generic_pipe_buf_unmap, |
| @@ -3320,6 +3338,16 @@ tracing_entries_write(struct file *filp, const char __user *ubuf, | |||
| 3320 | return cnt; | 3338 | return cnt; |
| 3321 | } | 3339 | } |
| 3322 | 3340 | ||
| 3341 | static int mark_printk(const char *fmt, ...) | ||
| 3342 | { | ||
| 3343 | int ret; | ||
| 3344 | va_list args; | ||
| 3345 | va_start(args, fmt); | ||
| 3346 | ret = trace_vprintk(0, fmt, args); | ||
| 3347 | va_end(args); | ||
| 3348 | return ret; | ||
| 3349 | } | ||
| 3350 | |||
| 3323 | static ssize_t | 3351 | static ssize_t |
| 3324 | tracing_mark_write(struct file *filp, const char __user *ubuf, | 3352 | tracing_mark_write(struct file *filp, const char __user *ubuf, |
| 3325 | size_t cnt, loff_t *fpos) | 3353 | size_t cnt, loff_t *fpos) |
| @@ -3346,28 +3374,25 @@ tracing_mark_write(struct file *filp, const char __user *ubuf, | |||
| 3346 | } else | 3374 | } else |
| 3347 | buf[cnt] = '\0'; | 3375 | buf[cnt] = '\0'; |
| 3348 | 3376 | ||
| 3349 | cnt = trace_vprintk(0, buf, NULL); | 3377 | cnt = mark_printk("%s", buf); |
| 3350 | kfree(buf); | 3378 | kfree(buf); |
| 3351 | *fpos += cnt; | 3379 | *fpos += cnt; |
| 3352 | 3380 | ||
| 3353 | return cnt; | 3381 | return cnt; |
| 3354 | } | 3382 | } |
| 3355 | 3383 | ||
| 3356 | static ssize_t tracing_clock_read(struct file *filp, char __user *ubuf, | 3384 | static int tracing_clock_show(struct seq_file *m, void *v) |
| 3357 | size_t cnt, loff_t *ppos) | ||
| 3358 | { | 3385 | { |
| 3359 | char buf[64]; | ||
| 3360 | int bufiter = 0; | ||
| 3361 | int i; | 3386 | int i; |
| 3362 | 3387 | ||
| 3363 | for (i = 0; i < ARRAY_SIZE(trace_clocks); i++) | 3388 | for (i = 0; i < ARRAY_SIZE(trace_clocks); i++) |
| 3364 | bufiter += snprintf(buf + bufiter, sizeof(buf) - bufiter, | 3389 | seq_printf(m, |
| 3365 | "%s%s%s%s", i ? " " : "", | 3390 | "%s%s%s%s", i ? " " : "", |
| 3366 | i == trace_clock_id ? "[" : "", trace_clocks[i].name, | 3391 | i == trace_clock_id ? "[" : "", trace_clocks[i].name, |
| 3367 | i == trace_clock_id ? "]" : ""); | 3392 | i == trace_clock_id ? "]" : ""); |
| 3368 | bufiter += snprintf(buf + bufiter, sizeof(buf) - bufiter, "\n"); | 3393 | seq_putc(m, '\n'); |
| 3369 | 3394 | ||
| 3370 | return simple_read_from_buffer(ubuf, cnt, ppos, buf, bufiter); | 3395 | return 0; |
| 3371 | } | 3396 | } |
| 3372 | 3397 | ||
| 3373 | static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf, | 3398 | static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf, |
| @@ -3409,6 +3434,13 @@ static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf, | |||
| 3409 | return cnt; | 3434 | return cnt; |
| 3410 | } | 3435 | } |
| 3411 | 3436 | ||
| 3437 | static int tracing_clock_open(struct inode *inode, struct file *file) | ||
| 3438 | { | ||
| 3439 | if (tracing_disabled) | ||
| 3440 | return -ENODEV; | ||
| 3441 | return single_open(file, tracing_clock_show, NULL); | ||
| 3442 | } | ||
| 3443 | |||
| 3412 | static const struct file_operations tracing_max_lat_fops = { | 3444 | static const struct file_operations tracing_max_lat_fops = { |
| 3413 | .open = tracing_open_generic, | 3445 | .open = tracing_open_generic, |
| 3414 | .read = tracing_max_lat_read, | 3446 | .read = tracing_max_lat_read, |
| @@ -3447,8 +3479,10 @@ static const struct file_operations tracing_mark_fops = { | |||
| 3447 | }; | 3479 | }; |
| 3448 | 3480 | ||
| 3449 | static const struct file_operations trace_clock_fops = { | 3481 | static const struct file_operations trace_clock_fops = { |
| 3450 | .open = tracing_open_generic, | 3482 | .open = tracing_clock_open, |
| 3451 | .read = tracing_clock_read, | 3483 | .read = seq_read, |
| 3484 | .llseek = seq_lseek, | ||
| 3485 | .release = single_release, | ||
| 3452 | .write = tracing_clock_write, | 3486 | .write = tracing_clock_write, |
| 3453 | }; | 3487 | }; |
| 3454 | 3488 | ||
| @@ -3578,7 +3612,7 @@ static void buffer_pipe_buf_get(struct pipe_inode_info *pipe, | |||
| 3578 | } | 3612 | } |
| 3579 | 3613 | ||
| 3580 | /* Pipe buffer operations for a buffer. */ | 3614 | /* Pipe buffer operations for a buffer. */ |
| 3581 | static struct pipe_buf_operations buffer_pipe_buf_ops = { | 3615 | static const struct pipe_buf_operations buffer_pipe_buf_ops = { |
| 3582 | .can_merge = 0, | 3616 | .can_merge = 0, |
| 3583 | .map = generic_pipe_buf_map, | 3617 | .map = generic_pipe_buf_map, |
| 3584 | .unmap = generic_pipe_buf_unmap, | 3618 | .unmap = generic_pipe_buf_unmap, |
| @@ -3909,39 +3943,16 @@ trace_options_write(struct file *filp, const char __user *ubuf, size_t cnt, | |||
| 3909 | if (ret < 0) | 3943 | if (ret < 0) |
| 3910 | return ret; | 3944 | return ret; |
| 3911 | 3945 | ||
| 3912 | ret = 0; | 3946 | if (val != 0 && val != 1) |
| 3913 | switch (val) { | 3947 | return -EINVAL; |
| 3914 | case 0: | ||
| 3915 | /* do nothing if already cleared */ | ||
| 3916 | if (!(topt->flags->val & topt->opt->bit)) | ||
| 3917 | break; | ||
| 3918 | |||
| 3919 | mutex_lock(&trace_types_lock); | ||
| 3920 | if (current_trace->set_flag) | ||
| 3921 | ret = current_trace->set_flag(topt->flags->val, | ||
| 3922 | topt->opt->bit, 0); | ||
| 3923 | mutex_unlock(&trace_types_lock); | ||
| 3924 | if (ret) | ||
| 3925 | return ret; | ||
| 3926 | topt->flags->val &= ~topt->opt->bit; | ||
| 3927 | break; | ||
| 3928 | case 1: | ||
| 3929 | /* do nothing if already set */ | ||
| 3930 | if (topt->flags->val & topt->opt->bit) | ||
| 3931 | break; | ||
| 3932 | 3948 | ||
| 3949 | if (!!(topt->flags->val & topt->opt->bit) != val) { | ||
| 3933 | mutex_lock(&trace_types_lock); | 3950 | mutex_lock(&trace_types_lock); |
| 3934 | if (current_trace->set_flag) | 3951 | ret = __set_tracer_option(current_trace, topt->flags, |
| 3935 | ret = current_trace->set_flag(topt->flags->val, | 3952 | topt->opt, !val); |
| 3936 | topt->opt->bit, 1); | ||
| 3937 | mutex_unlock(&trace_types_lock); | 3953 | mutex_unlock(&trace_types_lock); |
| 3938 | if (ret) | 3954 | if (ret) |
| 3939 | return ret; | 3955 | return ret; |
| 3940 | topt->flags->val |= topt->opt->bit; | ||
| 3941 | break; | ||
| 3942 | |||
| 3943 | default: | ||
| 3944 | return -EINVAL; | ||
| 3945 | } | 3956 | } |
| 3946 | 3957 | ||
| 3947 | *ppos += cnt; | 3958 | *ppos += cnt; |
| @@ -4268,8 +4279,8 @@ trace_printk_seq(struct trace_seq *s) | |||
| 4268 | 4279 | ||
| 4269 | static void __ftrace_dump(bool disable_tracing) | 4280 | static void __ftrace_dump(bool disable_tracing) |
| 4270 | { | 4281 | { |
| 4271 | static raw_spinlock_t ftrace_dump_lock = | 4282 | static arch_spinlock_t ftrace_dump_lock = |
| 4272 | (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED; | 4283 | (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED; |
| 4273 | /* use static because iter can be a bit big for the stack */ | 4284 | /* use static because iter can be a bit big for the stack */ |
| 4274 | static struct trace_iterator iter; | 4285 | static struct trace_iterator iter; |
| 4275 | unsigned int old_userobj; | 4286 | unsigned int old_userobj; |
| @@ -4279,7 +4290,7 @@ static void __ftrace_dump(bool disable_tracing) | |||
| 4279 | 4290 | ||
| 4280 | /* only one dump */ | 4291 | /* only one dump */ |
| 4281 | local_irq_save(flags); | 4292 | local_irq_save(flags); |
| 4282 | __raw_spin_lock(&ftrace_dump_lock); | 4293 | arch_spin_lock(&ftrace_dump_lock); |
| 4283 | if (dump_ran) | 4294 | if (dump_ran) |
| 4284 | goto out; | 4295 | goto out; |
| 4285 | 4296 | ||
| @@ -4354,7 +4365,7 @@ static void __ftrace_dump(bool disable_tracing) | |||
| 4354 | } | 4365 | } |
| 4355 | 4366 | ||
| 4356 | out: | 4367 | out: |
| 4357 | __raw_spin_unlock(&ftrace_dump_lock); | 4368 | arch_spin_unlock(&ftrace_dump_lock); |
| 4358 | local_irq_restore(flags); | 4369 | local_irq_restore(flags); |
| 4359 | } | 4370 | } |
| 4360 | 4371 | ||
| @@ -4415,7 +4426,7 @@ __init static int tracer_alloc_buffers(void) | |||
| 4415 | /* Allocate the first page for all buffers */ | 4426 | /* Allocate the first page for all buffers */ |
| 4416 | for_each_tracing_cpu(i) { | 4427 | for_each_tracing_cpu(i) { |
| 4417 | global_trace.data[i] = &per_cpu(global_trace_cpu, i); | 4428 | global_trace.data[i] = &per_cpu(global_trace_cpu, i); |
| 4418 | max_tr.data[i] = &per_cpu(max_data, i); | 4429 | max_tr.data[i] = &per_cpu(max_tr_data, i); |
| 4419 | } | 4430 | } |
| 4420 | 4431 | ||
| 4421 | trace_init_cmdlines(); | 4432 | trace_init_cmdlines(); |
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 1d7f4830a80d..4df6a77eb196 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
| @@ -272,6 +272,7 @@ struct tracer_flags { | |||
| 272 | * @pipe_open: called when the trace_pipe file is opened | 272 | * @pipe_open: called when the trace_pipe file is opened |
| 273 | * @wait_pipe: override how the user waits for traces on trace_pipe | 273 | * @wait_pipe: override how the user waits for traces on trace_pipe |
| 274 | * @close: called when the trace file is released | 274 | * @close: called when the trace file is released |
| 275 | * @pipe_close: called when the trace_pipe file is released | ||
| 275 | * @read: override the default read callback on trace_pipe | 276 | * @read: override the default read callback on trace_pipe |
| 276 | * @splice_read: override the default splice_read callback on trace_pipe | 277 | * @splice_read: override the default splice_read callback on trace_pipe |
| 277 | * @selftest: selftest to run on boot (see trace_selftest.c) | 278 | * @selftest: selftest to run on boot (see trace_selftest.c) |
| @@ -290,6 +291,7 @@ struct tracer { | |||
| 290 | void (*pipe_open)(struct trace_iterator *iter); | 291 | void (*pipe_open)(struct trace_iterator *iter); |
| 291 | void (*wait_pipe)(struct trace_iterator *iter); | 292 | void (*wait_pipe)(struct trace_iterator *iter); |
| 292 | void (*close)(struct trace_iterator *iter); | 293 | void (*close)(struct trace_iterator *iter); |
| 294 | void (*pipe_close)(struct trace_iterator *iter); | ||
| 293 | ssize_t (*read)(struct trace_iterator *iter, | 295 | ssize_t (*read)(struct trace_iterator *iter, |
| 294 | struct file *filp, char __user *ubuf, | 296 | struct file *filp, char __user *ubuf, |
| 295 | size_t cnt, loff_t *ppos); | 297 | size_t cnt, loff_t *ppos); |
| @@ -441,7 +443,7 @@ extern int DYN_FTRACE_TEST_NAME(void); | |||
| 441 | 443 | ||
| 442 | extern int ring_buffer_expanded; | 444 | extern int ring_buffer_expanded; |
| 443 | extern bool tracing_selftest_disabled; | 445 | extern bool tracing_selftest_disabled; |
| 444 | DECLARE_PER_CPU(local_t, ftrace_cpu_disabled); | 446 | DECLARE_PER_CPU(int, ftrace_cpu_disabled); |
| 445 | 447 | ||
| 446 | #ifdef CONFIG_FTRACE_STARTUP_TEST | 448 | #ifdef CONFIG_FTRACE_STARTUP_TEST |
| 447 | extern int trace_selftest_startup_function(struct tracer *trace, | 449 | extern int trace_selftest_startup_function(struct tracer *trace, |
| @@ -595,18 +597,17 @@ enum trace_iterator_flags { | |||
| 595 | TRACE_ITER_BIN = 0x40, | 597 | TRACE_ITER_BIN = 0x40, |
| 596 | TRACE_ITER_BLOCK = 0x80, | 598 | TRACE_ITER_BLOCK = 0x80, |
| 597 | TRACE_ITER_STACKTRACE = 0x100, | 599 | TRACE_ITER_STACKTRACE = 0x100, |
| 598 | TRACE_ITER_SCHED_TREE = 0x200, | 600 | TRACE_ITER_PRINTK = 0x200, |
| 599 | TRACE_ITER_PRINTK = 0x400, | 601 | TRACE_ITER_PREEMPTONLY = 0x400, |
| 600 | TRACE_ITER_PREEMPTONLY = 0x800, | 602 | TRACE_ITER_BRANCH = 0x800, |
| 601 | TRACE_ITER_BRANCH = 0x1000, | 603 | TRACE_ITER_ANNOTATE = 0x1000, |
| 602 | TRACE_ITER_ANNOTATE = 0x2000, | 604 | TRACE_ITER_USERSTACKTRACE = 0x2000, |
| 603 | TRACE_ITER_USERSTACKTRACE = 0x4000, | 605 | TRACE_ITER_SYM_USEROBJ = 0x4000, |
| 604 | TRACE_ITER_SYM_USEROBJ = 0x8000, | 606 | TRACE_ITER_PRINTK_MSGONLY = 0x8000, |
| 605 | TRACE_ITER_PRINTK_MSGONLY = 0x10000, | 607 | TRACE_ITER_CONTEXT_INFO = 0x10000, /* Print pid/cpu/time */ |
| 606 | TRACE_ITER_CONTEXT_INFO = 0x20000, /* Print pid/cpu/time */ | 608 | TRACE_ITER_LATENCY_FMT = 0x20000, |
| 607 | TRACE_ITER_LATENCY_FMT = 0x40000, | 609 | TRACE_ITER_SLEEP_TIME = 0x40000, |
| 608 | TRACE_ITER_SLEEP_TIME = 0x80000, | 610 | TRACE_ITER_GRAPH_TIME = 0x80000, |
| 609 | TRACE_ITER_GRAPH_TIME = 0x100000, | ||
| 610 | }; | 611 | }; |
| 611 | 612 | ||
| 612 | /* | 613 | /* |
diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c index 878c03f386ba..84a3a7ba072a 100644 --- a/kernel/trace/trace_clock.c +++ b/kernel/trace/trace_clock.c | |||
| @@ -71,10 +71,10 @@ u64 notrace trace_clock(void) | |||
| 71 | /* keep prev_time and lock in the same cacheline. */ | 71 | /* keep prev_time and lock in the same cacheline. */ |
| 72 | static struct { | 72 | static struct { |
| 73 | u64 prev_time; | 73 | u64 prev_time; |
| 74 | raw_spinlock_t lock; | 74 | arch_spinlock_t lock; |
| 75 | } trace_clock_struct ____cacheline_aligned_in_smp = | 75 | } trace_clock_struct ____cacheline_aligned_in_smp = |
| 76 | { | 76 | { |
| 77 | .lock = (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED, | 77 | .lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED, |
| 78 | }; | 78 | }; |
| 79 | 79 | ||
| 80 | u64 notrace trace_clock_global(void) | 80 | u64 notrace trace_clock_global(void) |
| @@ -94,7 +94,7 @@ u64 notrace trace_clock_global(void) | |||
| 94 | if (unlikely(in_nmi())) | 94 | if (unlikely(in_nmi())) |
| 95 | goto out; | 95 | goto out; |
| 96 | 96 | ||
| 97 | __raw_spin_lock(&trace_clock_struct.lock); | 97 | arch_spin_lock(&trace_clock_struct.lock); |
| 98 | 98 | ||
| 99 | /* | 99 | /* |
| 100 | * TODO: if this happens often then maybe we should reset | 100 | * TODO: if this happens often then maybe we should reset |
| @@ -106,7 +106,7 @@ u64 notrace trace_clock_global(void) | |||
| 106 | 106 | ||
| 107 | trace_clock_struct.prev_time = now; | 107 | trace_clock_struct.prev_time = now; |
| 108 | 108 | ||
| 109 | __raw_spin_unlock(&trace_clock_struct.lock); | 109 | arch_spin_unlock(&trace_clock_struct.lock); |
| 110 | 110 | ||
| 111 | out: | 111 | out: |
| 112 | raw_local_irq_restore(flags); | 112 | raw_local_irq_restore(flags); |
diff --git a/kernel/trace/trace_event_profile.c b/kernel/trace/trace_event_profile.c index d9c60f80aa0d..9e25573242cf 100644 --- a/kernel/trace/trace_event_profile.c +++ b/kernel/trace/trace_event_profile.c | |||
| @@ -25,7 +25,7 @@ static int ftrace_profile_enable_event(struct ftrace_event_call *event) | |||
| 25 | char *buf; | 25 | char *buf; |
| 26 | int ret = -ENOMEM; | 26 | int ret = -ENOMEM; |
| 27 | 27 | ||
| 28 | if (atomic_inc_return(&event->profile_count)) | 28 | if (event->profile_count++ > 0) |
| 29 | return 0; | 29 | return 0; |
| 30 | 30 | ||
| 31 | if (!total_profile_count) { | 31 | if (!total_profile_count) { |
| @@ -56,7 +56,7 @@ fail_buf_nmi: | |||
| 56 | perf_trace_buf = NULL; | 56 | perf_trace_buf = NULL; |
| 57 | } | 57 | } |
| 58 | fail_buf: | 58 | fail_buf: |
| 59 | atomic_dec(&event->profile_count); | 59 | event->profile_count--; |
| 60 | 60 | ||
| 61 | return ret; | 61 | return ret; |
| 62 | } | 62 | } |
| @@ -83,7 +83,7 @@ static void ftrace_profile_disable_event(struct ftrace_event_call *event) | |||
| 83 | { | 83 | { |
| 84 | char *buf, *nmi_buf; | 84 | char *buf, *nmi_buf; |
| 85 | 85 | ||
| 86 | if (!atomic_add_negative(-1, &event->profile_count)) | 86 | if (--event->profile_count > 0) |
| 87 | return; | 87 | return; |
| 88 | 88 | ||
| 89 | event->profile_disable(event); | 89 | event->profile_disable(event); |
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 1d18315dc836..189b09baf4fb 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c | |||
| @@ -78,7 +78,7 @@ EXPORT_SYMBOL_GPL(trace_define_field); | |||
| 78 | if (ret) \ | 78 | if (ret) \ |
| 79 | return ret; | 79 | return ret; |
| 80 | 80 | ||
| 81 | int trace_define_common_fields(struct ftrace_event_call *call) | 81 | static int trace_define_common_fields(struct ftrace_event_call *call) |
| 82 | { | 82 | { |
| 83 | int ret; | 83 | int ret; |
| 84 | struct trace_entry ent; | 84 | struct trace_entry ent; |
| @@ -91,7 +91,6 @@ int trace_define_common_fields(struct ftrace_event_call *call) | |||
| 91 | 91 | ||
| 92 | return ret; | 92 | return ret; |
| 93 | } | 93 | } |
| 94 | EXPORT_SYMBOL_GPL(trace_define_common_fields); | ||
| 95 | 94 | ||
| 96 | void trace_destroy_fields(struct ftrace_event_call *call) | 95 | void trace_destroy_fields(struct ftrace_event_call *call) |
| 97 | { | 96 | { |
| @@ -105,9 +104,25 @@ void trace_destroy_fields(struct ftrace_event_call *call) | |||
| 105 | } | 104 | } |
| 106 | } | 105 | } |
| 107 | 106 | ||
| 108 | static void ftrace_event_enable_disable(struct ftrace_event_call *call, | 107 | int trace_event_raw_init(struct ftrace_event_call *call) |
| 108 | { | ||
| 109 | int id; | ||
| 110 | |||
| 111 | id = register_ftrace_event(call->event); | ||
| 112 | if (!id) | ||
| 113 | return -ENODEV; | ||
| 114 | call->id = id; | ||
| 115 | INIT_LIST_HEAD(&call->fields); | ||
| 116 | |||
| 117 | return 0; | ||
| 118 | } | ||
| 119 | EXPORT_SYMBOL_GPL(trace_event_raw_init); | ||
| 120 | |||
| 121 | static int ftrace_event_enable_disable(struct ftrace_event_call *call, | ||
| 109 | int enable) | 122 | int enable) |
| 110 | { | 123 | { |
| 124 | int ret = 0; | ||
| 125 | |||
| 111 | switch (enable) { | 126 | switch (enable) { |
| 112 | case 0: | 127 | case 0: |
| 113 | if (call->enabled) { | 128 | if (call->enabled) { |
| @@ -118,12 +133,20 @@ static void ftrace_event_enable_disable(struct ftrace_event_call *call, | |||
| 118 | break; | 133 | break; |
| 119 | case 1: | 134 | case 1: |
| 120 | if (!call->enabled) { | 135 | if (!call->enabled) { |
| 121 | call->enabled = 1; | ||
| 122 | tracing_start_cmdline_record(); | 136 | tracing_start_cmdline_record(); |
| 123 | call->regfunc(call); | 137 | ret = call->regfunc(call); |
| 138 | if (ret) { | ||
| 139 | tracing_stop_cmdline_record(); | ||
| 140 | pr_info("event trace: Could not enable event " | ||
| 141 | "%s\n", call->name); | ||
| 142 | break; | ||
| 143 | } | ||
| 144 | call->enabled = 1; | ||
| 124 | } | 145 | } |
| 125 | break; | 146 | break; |
| 126 | } | 147 | } |
| 148 | |||
| 149 | return ret; | ||
| 127 | } | 150 | } |
| 128 | 151 | ||
| 129 | static void ftrace_clear_events(void) | 152 | static void ftrace_clear_events(void) |
| @@ -402,7 +425,7 @@ event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt, | |||
| 402 | case 0: | 425 | case 0: |
| 403 | case 1: | 426 | case 1: |
| 404 | mutex_lock(&event_mutex); | 427 | mutex_lock(&event_mutex); |
| 405 | ftrace_event_enable_disable(call, val); | 428 | ret = ftrace_event_enable_disable(call, val); |
| 406 | mutex_unlock(&event_mutex); | 429 | mutex_unlock(&event_mutex); |
| 407 | break; | 430 | break; |
| 408 | 431 | ||
| @@ -412,7 +435,7 @@ event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt, | |||
| 412 | 435 | ||
| 413 | *ppos += cnt; | 436 | *ppos += cnt; |
| 414 | 437 | ||
| 415 | return cnt; | 438 | return ret ? ret : cnt; |
| 416 | } | 439 | } |
| 417 | 440 | ||
| 418 | static ssize_t | 441 | static ssize_t |
| @@ -913,7 +936,9 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events, | |||
| 913 | id); | 936 | id); |
| 914 | 937 | ||
| 915 | if (call->define_fields) { | 938 | if (call->define_fields) { |
| 916 | ret = call->define_fields(call); | 939 | ret = trace_define_common_fields(call); |
| 940 | if (!ret) | ||
| 941 | ret = call->define_fields(call); | ||
| 917 | if (ret < 0) { | 942 | if (ret < 0) { |
| 918 | pr_warning("Could not initialize trace point" | 943 | pr_warning("Could not initialize trace point" |
| 919 | " events/%s\n", call->name); | 944 | " events/%s\n", call->name); |
diff --git a/kernel/trace/trace_export.c b/kernel/trace/trace_export.c index dff8c84ddf17..d4fa5dc1ee4e 100644 --- a/kernel/trace/trace_export.c +++ b/kernel/trace/trace_export.c | |||
| @@ -158,7 +158,8 @@ ftrace_format_##name(struct ftrace_event_call *unused, \ | |||
| 158 | BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \ | 158 | BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \ |
| 159 | ret = trace_define_field(event_call, #type "[" #len "]", #item, \ | 159 | ret = trace_define_field(event_call, #type "[" #len "]", #item, \ |
| 160 | offsetof(typeof(field), item), \ | 160 | offsetof(typeof(field), item), \ |
| 161 | sizeof(field.item), 0, FILTER_OTHER); \ | 161 | sizeof(field.item), \ |
| 162 | is_signed_type(type), FILTER_OTHER); \ | ||
| 162 | if (ret) \ | 163 | if (ret) \ |
| 163 | return ret; | 164 | return ret; |
| 164 | 165 | ||
| @@ -168,8 +169,8 @@ ftrace_format_##name(struct ftrace_event_call *unused, \ | |||
| 168 | ret = trace_define_field(event_call, #type "[" #len "]", #item, \ | 169 | ret = trace_define_field(event_call, #type "[" #len "]", #item, \ |
| 169 | offsetof(typeof(field), \ | 170 | offsetof(typeof(field), \ |
| 170 | container.item), \ | 171 | container.item), \ |
| 171 | sizeof(field.container.item), 0, \ | 172 | sizeof(field.container.item), \ |
| 172 | FILTER_OTHER); \ | 173 | is_signed_type(type), FILTER_OTHER); \ |
| 173 | if (ret) \ | 174 | if (ret) \ |
| 174 | return ret; | 175 | return ret; |
| 175 | 176 | ||
| @@ -184,10 +185,6 @@ ftrace_define_fields_##name(struct ftrace_event_call *event_call) \ | |||
| 184 | struct struct_name field; \ | 185 | struct struct_name field; \ |
| 185 | int ret; \ | 186 | int ret; \ |
| 186 | \ | 187 | \ |
| 187 | ret = trace_define_common_fields(event_call); \ | ||
| 188 | if (ret) \ | ||
| 189 | return ret; \ | ||
| 190 | \ | ||
| 191 | tstruct; \ | 188 | tstruct; \ |
| 192 | \ | 189 | \ |
| 193 | return ret; \ | 190 | return ret; \ |
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c index 45e6c01b2e4d..b1342c5d37cf 100644 --- a/kernel/trace/trace_functions_graph.c +++ b/kernel/trace/trace_functions_graph.c | |||
| @@ -14,9 +14,20 @@ | |||
| 14 | #include "trace.h" | 14 | #include "trace.h" |
| 15 | #include "trace_output.h" | 15 | #include "trace_output.h" |
| 16 | 16 | ||
| 17 | struct fgraph_data { | 17 | struct fgraph_cpu_data { |
| 18 | pid_t last_pid; | 18 | pid_t last_pid; |
| 19 | int depth; | 19 | int depth; |
| 20 | int ignore; | ||
| 21 | }; | ||
| 22 | |||
| 23 | struct fgraph_data { | ||
| 24 | struct fgraph_cpu_data *cpu_data; | ||
| 25 | |||
| 26 | /* Place to preserve last processed entry. */ | ||
| 27 | struct ftrace_graph_ent_entry ent; | ||
| 28 | struct ftrace_graph_ret_entry ret; | ||
| 29 | int failed; | ||
| 30 | int cpu; | ||
| 20 | }; | 31 | }; |
| 21 | 32 | ||
| 22 | #define TRACE_GRAPH_INDENT 2 | 33 | #define TRACE_GRAPH_INDENT 2 |
| @@ -176,7 +187,7 @@ static int __trace_graph_entry(struct trace_array *tr, | |||
| 176 | struct ring_buffer *buffer = tr->buffer; | 187 | struct ring_buffer *buffer = tr->buffer; |
| 177 | struct ftrace_graph_ent_entry *entry; | 188 | struct ftrace_graph_ent_entry *entry; |
| 178 | 189 | ||
| 179 | if (unlikely(local_read(&__get_cpu_var(ftrace_cpu_disabled)))) | 190 | if (unlikely(__this_cpu_read(per_cpu_var(ftrace_cpu_disabled)))) |
| 180 | return 0; | 191 | return 0; |
| 181 | 192 | ||
| 182 | event = trace_buffer_lock_reserve(buffer, TRACE_GRAPH_ENT, | 193 | event = trace_buffer_lock_reserve(buffer, TRACE_GRAPH_ENT, |
| @@ -240,7 +251,7 @@ static void __trace_graph_return(struct trace_array *tr, | |||
| 240 | struct ring_buffer *buffer = tr->buffer; | 251 | struct ring_buffer *buffer = tr->buffer; |
| 241 | struct ftrace_graph_ret_entry *entry; | 252 | struct ftrace_graph_ret_entry *entry; |
| 242 | 253 | ||
| 243 | if (unlikely(local_read(&__get_cpu_var(ftrace_cpu_disabled)))) | 254 | if (unlikely(__this_cpu_read(per_cpu_var(ftrace_cpu_disabled)))) |
| 244 | return; | 255 | return; |
| 245 | 256 | ||
| 246 | event = trace_buffer_lock_reserve(buffer, TRACE_GRAPH_RET, | 257 | event = trace_buffer_lock_reserve(buffer, TRACE_GRAPH_RET, |
| @@ -384,7 +395,7 @@ verif_pid(struct trace_seq *s, pid_t pid, int cpu, struct fgraph_data *data) | |||
| 384 | if (!data) | 395 | if (!data) |
| 385 | return TRACE_TYPE_HANDLED; | 396 | return TRACE_TYPE_HANDLED; |
| 386 | 397 | ||
| 387 | last_pid = &(per_cpu_ptr(data, cpu)->last_pid); | 398 | last_pid = &(per_cpu_ptr(data->cpu_data, cpu)->last_pid); |
| 388 | 399 | ||
| 389 | if (*last_pid == pid) | 400 | if (*last_pid == pid) |
| 390 | return TRACE_TYPE_HANDLED; | 401 | return TRACE_TYPE_HANDLED; |
| @@ -435,26 +446,49 @@ static struct ftrace_graph_ret_entry * | |||
| 435 | get_return_for_leaf(struct trace_iterator *iter, | 446 | get_return_for_leaf(struct trace_iterator *iter, |
| 436 | struct ftrace_graph_ent_entry *curr) | 447 | struct ftrace_graph_ent_entry *curr) |
| 437 | { | 448 | { |
| 438 | struct ring_buffer_iter *ring_iter; | 449 | struct fgraph_data *data = iter->private; |
| 450 | struct ring_buffer_iter *ring_iter = NULL; | ||
| 439 | struct ring_buffer_event *event; | 451 | struct ring_buffer_event *event; |
| 440 | struct ftrace_graph_ret_entry *next; | 452 | struct ftrace_graph_ret_entry *next; |
| 441 | 453 | ||
| 442 | ring_iter = iter->buffer_iter[iter->cpu]; | 454 | /* |
| 455 | * If the previous output failed to write to the seq buffer, | ||
| 456 | * then we just reuse the data from before. | ||
| 457 | */ | ||
| 458 | if (data && data->failed) { | ||
| 459 | curr = &data->ent; | ||
| 460 | next = &data->ret; | ||
| 461 | } else { | ||
| 443 | 462 | ||
| 444 | /* First peek to compare current entry and the next one */ | 463 | ring_iter = iter->buffer_iter[iter->cpu]; |
| 445 | if (ring_iter) | 464 | |
| 446 | event = ring_buffer_iter_peek(ring_iter, NULL); | 465 | /* First peek to compare current entry and the next one */ |
| 447 | else { | 466 | if (ring_iter) |
| 448 | /* We need to consume the current entry to see the next one */ | 467 | event = ring_buffer_iter_peek(ring_iter, NULL); |
| 449 | ring_buffer_consume(iter->tr->buffer, iter->cpu, NULL); | 468 | else { |
| 450 | event = ring_buffer_peek(iter->tr->buffer, iter->cpu, | 469 | /* |
| 451 | NULL); | 470 | * We need to consume the current entry to see |
| 452 | } | 471 | * the next one. |
| 472 | */ | ||
| 473 | ring_buffer_consume(iter->tr->buffer, iter->cpu, NULL); | ||
| 474 | event = ring_buffer_peek(iter->tr->buffer, iter->cpu, | ||
| 475 | NULL); | ||
| 476 | } | ||
| 453 | 477 | ||
| 454 | if (!event) | 478 | if (!event) |
| 455 | return NULL; | 479 | return NULL; |
| 480 | |||
| 481 | next = ring_buffer_event_data(event); | ||
| 456 | 482 | ||
| 457 | next = ring_buffer_event_data(event); | 483 | if (data) { |
| 484 | /* | ||
| 485 | * Save current and next entries for later reference | ||
| 486 | * if the output fails. | ||
| 487 | */ | ||
| 488 | data->ent = *curr; | ||
| 489 | data->ret = *next; | ||
| 490 | } | ||
| 491 | } | ||
| 458 | 492 | ||
| 459 | if (next->ent.type != TRACE_GRAPH_RET) | 493 | if (next->ent.type != TRACE_GRAPH_RET) |
| 460 | return NULL; | 494 | return NULL; |
| @@ -640,7 +674,7 @@ print_graph_entry_leaf(struct trace_iterator *iter, | |||
| 640 | 674 | ||
| 641 | if (data) { | 675 | if (data) { |
| 642 | int cpu = iter->cpu; | 676 | int cpu = iter->cpu; |
| 643 | int *depth = &(per_cpu_ptr(data, cpu)->depth); | 677 | int *depth = &(per_cpu_ptr(data->cpu_data, cpu)->depth); |
| 644 | 678 | ||
| 645 | /* | 679 | /* |
| 646 | * Comments display at + 1 to depth. Since | 680 | * Comments display at + 1 to depth. Since |
| @@ -688,7 +722,7 @@ print_graph_entry_nested(struct trace_iterator *iter, | |||
| 688 | 722 | ||
| 689 | if (data) { | 723 | if (data) { |
| 690 | int cpu = iter->cpu; | 724 | int cpu = iter->cpu; |
| 691 | int *depth = &(per_cpu_ptr(data, cpu)->depth); | 725 | int *depth = &(per_cpu_ptr(data->cpu_data, cpu)->depth); |
| 692 | 726 | ||
| 693 | *depth = call->depth; | 727 | *depth = call->depth; |
| 694 | } | 728 | } |
| @@ -782,19 +816,34 @@ static enum print_line_t | |||
| 782 | print_graph_entry(struct ftrace_graph_ent_entry *field, struct trace_seq *s, | 816 | print_graph_entry(struct ftrace_graph_ent_entry *field, struct trace_seq *s, |
| 783 | struct trace_iterator *iter) | 817 | struct trace_iterator *iter) |
| 784 | { | 818 | { |
| 785 | int cpu = iter->cpu; | 819 | struct fgraph_data *data = iter->private; |
| 786 | struct ftrace_graph_ent *call = &field->graph_ent; | 820 | struct ftrace_graph_ent *call = &field->graph_ent; |
| 787 | struct ftrace_graph_ret_entry *leaf_ret; | 821 | struct ftrace_graph_ret_entry *leaf_ret; |
| 822 | static enum print_line_t ret; | ||
| 823 | int cpu = iter->cpu; | ||
| 788 | 824 | ||
| 789 | if (print_graph_prologue(iter, s, TRACE_GRAPH_ENT, call->func)) | 825 | if (print_graph_prologue(iter, s, TRACE_GRAPH_ENT, call->func)) |
| 790 | return TRACE_TYPE_PARTIAL_LINE; | 826 | return TRACE_TYPE_PARTIAL_LINE; |
| 791 | 827 | ||
| 792 | leaf_ret = get_return_for_leaf(iter, field); | 828 | leaf_ret = get_return_for_leaf(iter, field); |
| 793 | if (leaf_ret) | 829 | if (leaf_ret) |
| 794 | return print_graph_entry_leaf(iter, field, leaf_ret, s); | 830 | ret = print_graph_entry_leaf(iter, field, leaf_ret, s); |
| 795 | else | 831 | else |
| 796 | return print_graph_entry_nested(iter, field, s, cpu); | 832 | ret = print_graph_entry_nested(iter, field, s, cpu); |
| 797 | 833 | ||
| 834 | if (data) { | ||
| 835 | /* | ||
| 836 | * If we failed to write our output, then we need to make | ||
| 837 | * note of it. Because we already consumed our entry. | ||
| 838 | */ | ||
| 839 | if (s->full) { | ||
| 840 | data->failed = 1; | ||
| 841 | data->cpu = cpu; | ||
| 842 | } else | ||
| 843 | data->failed = 0; | ||
| 844 | } | ||
| 845 | |||
| 846 | return ret; | ||
| 798 | } | 847 | } |
| 799 | 848 | ||
| 800 | static enum print_line_t | 849 | static enum print_line_t |
| @@ -810,7 +859,7 @@ print_graph_return(struct ftrace_graph_ret *trace, struct trace_seq *s, | |||
| 810 | 859 | ||
| 811 | if (data) { | 860 | if (data) { |
| 812 | int cpu = iter->cpu; | 861 | int cpu = iter->cpu; |
| 813 | int *depth = &(per_cpu_ptr(data, cpu)->depth); | 862 | int *depth = &(per_cpu_ptr(data->cpu_data, cpu)->depth); |
| 814 | 863 | ||
| 815 | /* | 864 | /* |
| 816 | * Comments display at + 1 to depth. This is the | 865 | * Comments display at + 1 to depth. This is the |
| @@ -873,7 +922,7 @@ print_graph_comment(struct trace_seq *s, struct trace_entry *ent, | |||
| 873 | int i; | 922 | int i; |
| 874 | 923 | ||
| 875 | if (data) | 924 | if (data) |
| 876 | depth = per_cpu_ptr(data, iter->cpu)->depth; | 925 | depth = per_cpu_ptr(data->cpu_data, iter->cpu)->depth; |
| 877 | 926 | ||
| 878 | if (print_graph_prologue(iter, s, 0, 0)) | 927 | if (print_graph_prologue(iter, s, 0, 0)) |
| 879 | return TRACE_TYPE_PARTIAL_LINE; | 928 | return TRACE_TYPE_PARTIAL_LINE; |
| @@ -941,8 +990,33 @@ print_graph_comment(struct trace_seq *s, struct trace_entry *ent, | |||
| 941 | enum print_line_t | 990 | enum print_line_t |
| 942 | print_graph_function(struct trace_iterator *iter) | 991 | print_graph_function(struct trace_iterator *iter) |
| 943 | { | 992 | { |
| 993 | struct ftrace_graph_ent_entry *field; | ||
| 994 | struct fgraph_data *data = iter->private; | ||
| 944 | struct trace_entry *entry = iter->ent; | 995 | struct trace_entry *entry = iter->ent; |
| 945 | struct trace_seq *s = &iter->seq; | 996 | struct trace_seq *s = &iter->seq; |
| 997 | int cpu = iter->cpu; | ||
| 998 | int ret; | ||
| 999 | |||
| 1000 | if (data && per_cpu_ptr(data->cpu_data, cpu)->ignore) { | ||
| 1001 | per_cpu_ptr(data->cpu_data, cpu)->ignore = 0; | ||
| 1002 | return TRACE_TYPE_HANDLED; | ||
| 1003 | } | ||
| 1004 | |||
| 1005 | /* | ||
| 1006 | * If the last output failed, there's a possibility we need | ||
| 1007 | * to print out the missing entry which would never go out. | ||
| 1008 | */ | ||
| 1009 | if (data && data->failed) { | ||
| 1010 | field = &data->ent; | ||
| 1011 | iter->cpu = data->cpu; | ||
| 1012 | ret = print_graph_entry(field, s, iter); | ||
| 1013 | if (ret == TRACE_TYPE_HANDLED && iter->cpu != cpu) { | ||
| 1014 | per_cpu_ptr(data->cpu_data, iter->cpu)->ignore = 1; | ||
| 1015 | ret = TRACE_TYPE_NO_CONSUME; | ||
| 1016 | } | ||
| 1017 | iter->cpu = cpu; | ||
| 1018 | return ret; | ||
| 1019 | } | ||
| 946 | 1020 | ||
| 947 | switch (entry->type) { | 1021 | switch (entry->type) { |
| 948 | case TRACE_GRAPH_ENT: { | 1022 | case TRACE_GRAPH_ENT: { |
| @@ -952,7 +1026,7 @@ print_graph_function(struct trace_iterator *iter) | |||
| 952 | * sizeof(struct ftrace_graph_ent_entry) is very small, | 1026 | * sizeof(struct ftrace_graph_ent_entry) is very small, |
| 953 | * it can be safely saved at the stack. | 1027 | * it can be safely saved at the stack. |
| 954 | */ | 1028 | */ |
| 955 | struct ftrace_graph_ent_entry *field, saved; | 1029 | struct ftrace_graph_ent_entry saved; |
| 956 | trace_assign_type(field, entry); | 1030 | trace_assign_type(field, entry); |
| 957 | saved = *field; | 1031 | saved = *field; |
| 958 | return print_graph_entry(&saved, s, iter); | 1032 | return print_graph_entry(&saved, s, iter); |
| @@ -1030,31 +1104,54 @@ static void print_graph_headers(struct seq_file *s) | |||
| 1030 | static void graph_trace_open(struct trace_iterator *iter) | 1104 | static void graph_trace_open(struct trace_iterator *iter) |
| 1031 | { | 1105 | { |
| 1032 | /* pid and depth on the last trace processed */ | 1106 | /* pid and depth on the last trace processed */ |
| 1033 | struct fgraph_data *data = alloc_percpu(struct fgraph_data); | 1107 | struct fgraph_data *data; |
| 1034 | int cpu; | 1108 | int cpu; |
| 1035 | 1109 | ||
| 1110 | iter->private = NULL; | ||
| 1111 | |||
| 1112 | data = kzalloc(sizeof(*data), GFP_KERNEL); | ||
| 1036 | if (!data) | 1113 | if (!data) |
| 1037 | pr_warning("function graph tracer: not enough memory\n"); | 1114 | goto out_err; |
| 1038 | else | 1115 | |
| 1039 | for_each_possible_cpu(cpu) { | 1116 | data->cpu_data = alloc_percpu(struct fgraph_cpu_data); |
| 1040 | pid_t *pid = &(per_cpu_ptr(data, cpu)->last_pid); | 1117 | if (!data->cpu_data) |
| 1041 | int *depth = &(per_cpu_ptr(data, cpu)->depth); | 1118 | goto out_err_free; |
| 1042 | *pid = -1; | 1119 | |
| 1043 | *depth = 0; | 1120 | for_each_possible_cpu(cpu) { |
| 1044 | } | 1121 | pid_t *pid = &(per_cpu_ptr(data->cpu_data, cpu)->last_pid); |
| 1122 | int *depth = &(per_cpu_ptr(data->cpu_data, cpu)->depth); | ||
| 1123 | int *ignore = &(per_cpu_ptr(data->cpu_data, cpu)->ignore); | ||
| 1124 | *pid = -1; | ||
| 1125 | *depth = 0; | ||
| 1126 | *ignore = 0; | ||
| 1127 | } | ||
| 1045 | 1128 | ||
| 1046 | iter->private = data; | 1129 | iter->private = data; |
| 1130 | |||
| 1131 | return; | ||
| 1132 | |||
| 1133 | out_err_free: | ||
| 1134 | kfree(data); | ||
| 1135 | out_err: | ||
| 1136 | pr_warning("function graph tracer: not enough memory\n"); | ||
| 1047 | } | 1137 | } |
| 1048 | 1138 | ||
| 1049 | static void graph_trace_close(struct trace_iterator *iter) | 1139 | static void graph_trace_close(struct trace_iterator *iter) |
| 1050 | { | 1140 | { |
| 1051 | free_percpu(iter->private); | 1141 | struct fgraph_data *data = iter->private; |
| 1142 | |||
| 1143 | if (data) { | ||
| 1144 | free_percpu(data->cpu_data); | ||
| 1145 | kfree(data); | ||
| 1146 | } | ||
| 1052 | } | 1147 | } |
| 1053 | 1148 | ||
| 1054 | static struct tracer graph_trace __read_mostly = { | 1149 | static struct tracer graph_trace __read_mostly = { |
| 1055 | .name = "function_graph", | 1150 | .name = "function_graph", |
| 1056 | .open = graph_trace_open, | 1151 | .open = graph_trace_open, |
| 1152 | .pipe_open = graph_trace_open, | ||
| 1057 | .close = graph_trace_close, | 1153 | .close = graph_trace_close, |
| 1154 | .pipe_close = graph_trace_close, | ||
| 1058 | .wait_pipe = poll_wait_pipe, | 1155 | .wait_pipe = poll_wait_pipe, |
| 1059 | .init = graph_trace_init, | 1156 | .init = graph_trace_init, |
| 1060 | .reset = graph_trace_reset, | 1157 | .reset = graph_trace_reset, |
diff --git a/kernel/trace/trace_hw_branches.c b/kernel/trace/trace_hw_branches.c index 69543a905cd5..7b97000745f5 100644 --- a/kernel/trace/trace_hw_branches.c +++ b/kernel/trace/trace_hw_branches.c | |||
| @@ -20,10 +20,10 @@ | |||
| 20 | 20 | ||
| 21 | #define BTS_BUFFER_SIZE (1 << 13) | 21 | #define BTS_BUFFER_SIZE (1 << 13) |
| 22 | 22 | ||
| 23 | static DEFINE_PER_CPU(struct bts_tracer *, tracer); | 23 | static DEFINE_PER_CPU(struct bts_tracer *, hwb_tracer); |
| 24 | static DEFINE_PER_CPU(unsigned char[BTS_BUFFER_SIZE], buffer); | 24 | static DEFINE_PER_CPU(unsigned char[BTS_BUFFER_SIZE], hwb_buffer); |
| 25 | 25 | ||
| 26 | #define this_tracer per_cpu(tracer, smp_processor_id()) | 26 | #define this_tracer per_cpu(hwb_tracer, smp_processor_id()) |
| 27 | 27 | ||
| 28 | static int trace_hw_branches_enabled __read_mostly; | 28 | static int trace_hw_branches_enabled __read_mostly; |
| 29 | static int trace_hw_branches_suspended __read_mostly; | 29 | static int trace_hw_branches_suspended __read_mostly; |
| @@ -32,12 +32,13 @@ static struct trace_array *hw_branch_trace __read_mostly; | |||
| 32 | 32 | ||
| 33 | static void bts_trace_init_cpu(int cpu) | 33 | static void bts_trace_init_cpu(int cpu) |
| 34 | { | 34 | { |
| 35 | per_cpu(tracer, cpu) = | 35 | per_cpu(hwb_tracer, cpu) = |
| 36 | ds_request_bts_cpu(cpu, per_cpu(buffer, cpu), BTS_BUFFER_SIZE, | 36 | ds_request_bts_cpu(cpu, per_cpu(hwb_buffer, cpu), |
| 37 | NULL, (size_t)-1, BTS_KERNEL); | 37 | BTS_BUFFER_SIZE, NULL, (size_t)-1, |
| 38 | BTS_KERNEL); | ||
| 38 | 39 | ||
| 39 | if (IS_ERR(per_cpu(tracer, cpu))) | 40 | if (IS_ERR(per_cpu(hwb_tracer, cpu))) |
| 40 | per_cpu(tracer, cpu) = NULL; | 41 | per_cpu(hwb_tracer, cpu) = NULL; |
| 41 | } | 42 | } |
| 42 | 43 | ||
| 43 | static int bts_trace_init(struct trace_array *tr) | 44 | static int bts_trace_init(struct trace_array *tr) |
| @@ -51,7 +52,7 @@ static int bts_trace_init(struct trace_array *tr) | |||
| 51 | for_each_online_cpu(cpu) { | 52 | for_each_online_cpu(cpu) { |
| 52 | bts_trace_init_cpu(cpu); | 53 | bts_trace_init_cpu(cpu); |
| 53 | 54 | ||
| 54 | if (likely(per_cpu(tracer, cpu))) | 55 | if (likely(per_cpu(hwb_tracer, cpu))) |
| 55 | trace_hw_branches_enabled = 1; | 56 | trace_hw_branches_enabled = 1; |
| 56 | } | 57 | } |
| 57 | trace_hw_branches_suspended = 0; | 58 | trace_hw_branches_suspended = 0; |
| @@ -67,9 +68,9 @@ static void bts_trace_reset(struct trace_array *tr) | |||
| 67 | 68 | ||
| 68 | get_online_cpus(); | 69 | get_online_cpus(); |
| 69 | for_each_online_cpu(cpu) { | 70 | for_each_online_cpu(cpu) { |
| 70 | if (likely(per_cpu(tracer, cpu))) { | 71 | if (likely(per_cpu(hwb_tracer, cpu))) { |
| 71 | ds_release_bts(per_cpu(tracer, cpu)); | 72 | ds_release_bts(per_cpu(hwb_tracer, cpu)); |
| 72 | per_cpu(tracer, cpu) = NULL; | 73 | per_cpu(hwb_tracer, cpu) = NULL; |
| 73 | } | 74 | } |
| 74 | } | 75 | } |
| 75 | trace_hw_branches_enabled = 0; | 76 | trace_hw_branches_enabled = 0; |
| @@ -83,8 +84,8 @@ static void bts_trace_start(struct trace_array *tr) | |||
| 83 | 84 | ||
| 84 | get_online_cpus(); | 85 | get_online_cpus(); |
| 85 | for_each_online_cpu(cpu) | 86 | for_each_online_cpu(cpu) |
| 86 | if (likely(per_cpu(tracer, cpu))) | 87 | if (likely(per_cpu(hwb_tracer, cpu))) |
| 87 | ds_resume_bts(per_cpu(tracer, cpu)); | 88 | ds_resume_bts(per_cpu(hwb_tracer, cpu)); |
| 88 | trace_hw_branches_suspended = 0; | 89 | trace_hw_branches_suspended = 0; |
| 89 | put_online_cpus(); | 90 | put_online_cpus(); |
| 90 | } | 91 | } |
| @@ -95,8 +96,8 @@ static void bts_trace_stop(struct trace_array *tr) | |||
| 95 | 96 | ||
| 96 | get_online_cpus(); | 97 | get_online_cpus(); |
| 97 | for_each_online_cpu(cpu) | 98 | for_each_online_cpu(cpu) |
| 98 | if (likely(per_cpu(tracer, cpu))) | 99 | if (likely(per_cpu(hwb_tracer, cpu))) |
| 99 | ds_suspend_bts(per_cpu(tracer, cpu)); | 100 | ds_suspend_bts(per_cpu(hwb_tracer, cpu)); |
| 100 | trace_hw_branches_suspended = 1; | 101 | trace_hw_branches_suspended = 1; |
| 101 | put_online_cpus(); | 102 | put_online_cpus(); |
| 102 | } | 103 | } |
| @@ -114,16 +115,16 @@ static int __cpuinit bts_hotcpu_handler(struct notifier_block *nfb, | |||
| 114 | bts_trace_init_cpu(cpu); | 115 | bts_trace_init_cpu(cpu); |
| 115 | 116 | ||
| 116 | if (trace_hw_branches_suspended && | 117 | if (trace_hw_branches_suspended && |
| 117 | likely(per_cpu(tracer, cpu))) | 118 | likely(per_cpu(hwb_tracer, cpu))) |
| 118 | ds_suspend_bts(per_cpu(tracer, cpu)); | 119 | ds_suspend_bts(per_cpu(hwb_tracer, cpu)); |
| 119 | } | 120 | } |
| 120 | break; | 121 | break; |
| 121 | 122 | ||
| 122 | case CPU_DOWN_PREPARE: | 123 | case CPU_DOWN_PREPARE: |
| 123 | /* The notification is sent with interrupts enabled. */ | 124 | /* The notification is sent with interrupts enabled. */ |
| 124 | if (likely(per_cpu(tracer, cpu))) { | 125 | if (likely(per_cpu(hwb_tracer, cpu))) { |
| 125 | ds_release_bts(per_cpu(tracer, cpu)); | 126 | ds_release_bts(per_cpu(hwb_tracer, cpu)); |
| 126 | per_cpu(tracer, cpu) = NULL; | 127 | per_cpu(hwb_tracer, cpu) = NULL; |
| 127 | } | 128 | } |
| 128 | } | 129 | } |
| 129 | 130 | ||
| @@ -258,8 +259,8 @@ static void trace_bts_prepare(struct trace_iterator *iter) | |||
| 258 | 259 | ||
| 259 | get_online_cpus(); | 260 | get_online_cpus(); |
| 260 | for_each_online_cpu(cpu) | 261 | for_each_online_cpu(cpu) |
| 261 | if (likely(per_cpu(tracer, cpu))) | 262 | if (likely(per_cpu(hwb_tracer, cpu))) |
| 262 | ds_suspend_bts(per_cpu(tracer, cpu)); | 263 | ds_suspend_bts(per_cpu(hwb_tracer, cpu)); |
| 263 | /* | 264 | /* |
| 264 | * We need to collect the trace on the respective cpu since ftrace | 265 | * We need to collect the trace on the respective cpu since ftrace |
| 265 | * implicitly adds the record for the current cpu. | 266 | * implicitly adds the record for the current cpu. |
| @@ -268,8 +269,8 @@ static void trace_bts_prepare(struct trace_iterator *iter) | |||
| 268 | on_each_cpu(trace_bts_cpu, iter->tr, 1); | 269 | on_each_cpu(trace_bts_cpu, iter->tr, 1); |
| 269 | 270 | ||
| 270 | for_each_online_cpu(cpu) | 271 | for_each_online_cpu(cpu) |
| 271 | if (likely(per_cpu(tracer, cpu))) | 272 | if (likely(per_cpu(hwb_tracer, cpu))) |
| 272 | ds_resume_bts(per_cpu(tracer, cpu)); | 273 | ds_resume_bts(per_cpu(hwb_tracer, cpu)); |
| 273 | put_online_cpus(); | 274 | put_online_cpus(); |
| 274 | } | 275 | } |
| 275 | 276 | ||
diff --git a/kernel/trace/trace_irqsoff.c b/kernel/trace/trace_irqsoff.c index 3aa7eaa2114c..2974bc7538c7 100644 --- a/kernel/trace/trace_irqsoff.c +++ b/kernel/trace/trace_irqsoff.c | |||
| @@ -151,6 +151,8 @@ check_critical_timing(struct trace_array *tr, | |||
| 151 | goto out_unlock; | 151 | goto out_unlock; |
| 152 | 152 | ||
| 153 | trace_function(tr, CALLER_ADDR0, parent_ip, flags, pc); | 153 | trace_function(tr, CALLER_ADDR0, parent_ip, flags, pc); |
| 154 | /* Skip 5 functions to get to the irq/preempt enable function */ | ||
| 155 | __trace_stack(tr, flags, 5, pc); | ||
| 154 | 156 | ||
| 155 | if (data->critical_sequence != max_sequence) | 157 | if (data->critical_sequence != max_sequence) |
| 156 | goto out_unlock; | 158 | goto out_unlock; |
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index aff5f80b59b8..6ea90c0e2c96 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c | |||
| @@ -282,6 +282,18 @@ static int kprobe_dispatcher(struct kprobe *kp, struct pt_regs *regs); | |||
| 282 | static int kretprobe_dispatcher(struct kretprobe_instance *ri, | 282 | static int kretprobe_dispatcher(struct kretprobe_instance *ri, |
| 283 | struct pt_regs *regs); | 283 | struct pt_regs *regs); |
| 284 | 284 | ||
| 285 | /* Check the name is good for event/group */ | ||
| 286 | static int check_event_name(const char *name) | ||
| 287 | { | ||
| 288 | if (!isalpha(*name) && *name != '_') | ||
| 289 | return 0; | ||
| 290 | while (*++name != '\0') { | ||
| 291 | if (!isalpha(*name) && !isdigit(*name) && *name != '_') | ||
| 292 | return 0; | ||
| 293 | } | ||
| 294 | return 1; | ||
| 295 | } | ||
| 296 | |||
| 285 | /* | 297 | /* |
| 286 | * Allocate new trace_probe and initialize it (including kprobes). | 298 | * Allocate new trace_probe and initialize it (including kprobes). |
| 287 | */ | 299 | */ |
| @@ -293,10 +305,11 @@ static struct trace_probe *alloc_trace_probe(const char *group, | |||
| 293 | int nargs, int is_return) | 305 | int nargs, int is_return) |
| 294 | { | 306 | { |
| 295 | struct trace_probe *tp; | 307 | struct trace_probe *tp; |
| 308 | int ret = -ENOMEM; | ||
| 296 | 309 | ||
| 297 | tp = kzalloc(SIZEOF_TRACE_PROBE(nargs), GFP_KERNEL); | 310 | tp = kzalloc(SIZEOF_TRACE_PROBE(nargs), GFP_KERNEL); |
| 298 | if (!tp) | 311 | if (!tp) |
| 299 | return ERR_PTR(-ENOMEM); | 312 | return ERR_PTR(ret); |
| 300 | 313 | ||
| 301 | if (symbol) { | 314 | if (symbol) { |
| 302 | tp->symbol = kstrdup(symbol, GFP_KERNEL); | 315 | tp->symbol = kstrdup(symbol, GFP_KERNEL); |
| @@ -312,14 +325,20 @@ static struct trace_probe *alloc_trace_probe(const char *group, | |||
| 312 | else | 325 | else |
| 313 | tp->rp.kp.pre_handler = kprobe_dispatcher; | 326 | tp->rp.kp.pre_handler = kprobe_dispatcher; |
| 314 | 327 | ||
| 315 | if (!event) | 328 | if (!event || !check_event_name(event)) { |
| 329 | ret = -EINVAL; | ||
| 316 | goto error; | 330 | goto error; |
| 331 | } | ||
| 332 | |||
| 317 | tp->call.name = kstrdup(event, GFP_KERNEL); | 333 | tp->call.name = kstrdup(event, GFP_KERNEL); |
| 318 | if (!tp->call.name) | 334 | if (!tp->call.name) |
| 319 | goto error; | 335 | goto error; |
| 320 | 336 | ||
| 321 | if (!group) | 337 | if (!group || !check_event_name(group)) { |
| 338 | ret = -EINVAL; | ||
| 322 | goto error; | 339 | goto error; |
| 340 | } | ||
| 341 | |||
| 323 | tp->call.system = kstrdup(group, GFP_KERNEL); | 342 | tp->call.system = kstrdup(group, GFP_KERNEL); |
| 324 | if (!tp->call.system) | 343 | if (!tp->call.system) |
| 325 | goto error; | 344 | goto error; |
| @@ -330,7 +349,7 @@ error: | |||
| 330 | kfree(tp->call.name); | 349 | kfree(tp->call.name); |
| 331 | kfree(tp->symbol); | 350 | kfree(tp->symbol); |
| 332 | kfree(tp); | 351 | kfree(tp); |
| 333 | return ERR_PTR(-ENOMEM); | 352 | return ERR_PTR(ret); |
| 334 | } | 353 | } |
| 335 | 354 | ||
| 336 | static void free_probe_arg(struct probe_arg *arg) | 355 | static void free_probe_arg(struct probe_arg *arg) |
| @@ -606,23 +625,22 @@ static int create_trace_probe(int argc, char **argv) | |||
| 606 | */ | 625 | */ |
| 607 | struct trace_probe *tp; | 626 | struct trace_probe *tp; |
| 608 | int i, ret = 0; | 627 | int i, ret = 0; |
| 609 | int is_return = 0; | 628 | int is_return = 0, is_delete = 0; |
| 610 | char *symbol = NULL, *event = NULL, *arg = NULL, *group = NULL; | 629 | char *symbol = NULL, *event = NULL, *arg = NULL, *group = NULL; |
| 611 | unsigned long offset = 0; | 630 | unsigned long offset = 0; |
| 612 | void *addr = NULL; | 631 | void *addr = NULL; |
| 613 | char buf[MAX_EVENT_NAME_LEN]; | 632 | char buf[MAX_EVENT_NAME_LEN]; |
| 614 | 633 | ||
| 615 | if (argc < 2) { | 634 | /* argc must be >= 1 */ |
| 616 | pr_info("Probe point is not specified.\n"); | ||
| 617 | return -EINVAL; | ||
| 618 | } | ||
| 619 | |||
| 620 | if (argv[0][0] == 'p') | 635 | if (argv[0][0] == 'p') |
| 621 | is_return = 0; | 636 | is_return = 0; |
| 622 | else if (argv[0][0] == 'r') | 637 | else if (argv[0][0] == 'r') |
| 623 | is_return = 1; | 638 | is_return = 1; |
| 639 | else if (argv[0][0] == '-') | ||
| 640 | is_delete = 1; | ||
| 624 | else { | 641 | else { |
| 625 | pr_info("Probe definition must be started with 'p' or 'r'.\n"); | 642 | pr_info("Probe definition must be started with 'p', 'r' or" |
| 643 | " '-'.\n"); | ||
| 626 | return -EINVAL; | 644 | return -EINVAL; |
| 627 | } | 645 | } |
| 628 | 646 | ||
| @@ -642,7 +660,29 @@ static int create_trace_probe(int argc, char **argv) | |||
| 642 | return -EINVAL; | 660 | return -EINVAL; |
| 643 | } | 661 | } |
| 644 | } | 662 | } |
| 663 | if (!group) | ||
| 664 | group = KPROBE_EVENT_SYSTEM; | ||
| 665 | |||
| 666 | if (is_delete) { | ||
| 667 | if (!event) { | ||
| 668 | pr_info("Delete command needs an event name.\n"); | ||
| 669 | return -EINVAL; | ||
| 670 | } | ||
| 671 | tp = find_probe_event(event, group); | ||
| 672 | if (!tp) { | ||
| 673 | pr_info("Event %s/%s doesn't exist.\n", group, event); | ||
| 674 | return -ENOENT; | ||
| 675 | } | ||
| 676 | /* delete an event */ | ||
| 677 | unregister_trace_probe(tp); | ||
| 678 | free_trace_probe(tp); | ||
| 679 | return 0; | ||
| 680 | } | ||
| 645 | 681 | ||
| 682 | if (argc < 2) { | ||
| 683 | pr_info("Probe point is not specified.\n"); | ||
| 684 | return -EINVAL; | ||
| 685 | } | ||
| 646 | if (isdigit(argv[1][0])) { | 686 | if (isdigit(argv[1][0])) { |
| 647 | if (is_return) { | 687 | if (is_return) { |
| 648 | pr_info("Return probe point must be a symbol.\n"); | 688 | pr_info("Return probe point must be a symbol.\n"); |
| @@ -671,15 +711,13 @@ static int create_trace_probe(int argc, char **argv) | |||
| 671 | argc -= 2; argv += 2; | 711 | argc -= 2; argv += 2; |
| 672 | 712 | ||
| 673 | /* setup a probe */ | 713 | /* setup a probe */ |
| 674 | if (!group) | ||
| 675 | group = KPROBE_EVENT_SYSTEM; | ||
| 676 | if (!event) { | 714 | if (!event) { |
| 677 | /* Make a new event name */ | 715 | /* Make a new event name */ |
| 678 | if (symbol) | 716 | if (symbol) |
| 679 | snprintf(buf, MAX_EVENT_NAME_LEN, "%c@%s%+ld", | 717 | snprintf(buf, MAX_EVENT_NAME_LEN, "%c_%s_%ld", |
| 680 | is_return ? 'r' : 'p', symbol, offset); | 718 | is_return ? 'r' : 'p', symbol, offset); |
| 681 | else | 719 | else |
| 682 | snprintf(buf, MAX_EVENT_NAME_LEN, "%c@0x%p", | 720 | snprintf(buf, MAX_EVENT_NAME_LEN, "%c_0x%p", |
| 683 | is_return ? 'r' : 'p', addr); | 721 | is_return ? 'r' : 'p', addr); |
| 684 | event = buf; | 722 | event = buf; |
| 685 | } | 723 | } |
| @@ -1113,10 +1151,6 @@ static int kprobe_event_define_fields(struct ftrace_event_call *event_call) | |||
| 1113 | struct kprobe_trace_entry field; | 1151 | struct kprobe_trace_entry field; |
| 1114 | struct trace_probe *tp = (struct trace_probe *)event_call->data; | 1152 | struct trace_probe *tp = (struct trace_probe *)event_call->data; |
| 1115 | 1153 | ||
| 1116 | ret = trace_define_common_fields(event_call); | ||
| 1117 | if (!ret) | ||
| 1118 | return ret; | ||
| 1119 | |||
| 1120 | DEFINE_FIELD(unsigned long, ip, FIELD_STRING_IP, 0); | 1154 | DEFINE_FIELD(unsigned long, ip, FIELD_STRING_IP, 0); |
| 1121 | DEFINE_FIELD(int, nargs, FIELD_STRING_NARGS, 1); | 1155 | DEFINE_FIELD(int, nargs, FIELD_STRING_NARGS, 1); |
| 1122 | /* Set argument names as fields */ | 1156 | /* Set argument names as fields */ |
| @@ -1131,10 +1165,6 @@ static int kretprobe_event_define_fields(struct ftrace_event_call *event_call) | |||
| 1131 | struct kretprobe_trace_entry field; | 1165 | struct kretprobe_trace_entry field; |
| 1132 | struct trace_probe *tp = (struct trace_probe *)event_call->data; | 1166 | struct trace_probe *tp = (struct trace_probe *)event_call->data; |
| 1133 | 1167 | ||
| 1134 | ret = trace_define_common_fields(event_call); | ||
| 1135 | if (!ret) | ||
| 1136 | return ret; | ||
| 1137 | |||
| 1138 | DEFINE_FIELD(unsigned long, func, FIELD_STRING_FUNC, 0); | 1168 | DEFINE_FIELD(unsigned long, func, FIELD_STRING_FUNC, 0); |
| 1139 | DEFINE_FIELD(unsigned long, ret_ip, FIELD_STRING_RETIP, 0); | 1169 | DEFINE_FIELD(unsigned long, ret_ip, FIELD_STRING_RETIP, 0); |
| 1140 | DEFINE_FIELD(int, nargs, FIELD_STRING_NARGS, 1); | 1170 | DEFINE_FIELD(int, nargs, FIELD_STRING_NARGS, 1); |
| @@ -1171,10 +1201,11 @@ static int __probe_event_show_format(struct trace_seq *s, | |||
| 1171 | #undef SHOW_FIELD | 1201 | #undef SHOW_FIELD |
| 1172 | #define SHOW_FIELD(type, item, name) \ | 1202 | #define SHOW_FIELD(type, item, name) \ |
| 1173 | do { \ | 1203 | do { \ |
| 1174 | ret = trace_seq_printf(s, "\tfield: " #type " %s;\t" \ | 1204 | ret = trace_seq_printf(s, "\tfield:" #type " %s;\t" \ |
| 1175 | "offset:%u;\tsize:%u;\n", name, \ | 1205 | "offset:%u;\tsize:%u;\tsigned:%d;\n", name,\ |
| 1176 | (unsigned int)offsetof(typeof(field), item),\ | 1206 | (unsigned int)offsetof(typeof(field), item),\ |
| 1177 | (unsigned int)sizeof(type)); \ | 1207 | (unsigned int)sizeof(type), \ |
| 1208 | is_signed_type(type)); \ | ||
| 1178 | if (!ret) \ | 1209 | if (!ret) \ |
| 1179 | return 0; \ | 1210 | return 0; \ |
| 1180 | } while (0) | 1211 | } while (0) |
| @@ -1434,7 +1465,6 @@ static int register_probe_event(struct trace_probe *tp) | |||
| 1434 | call->unregfunc = probe_event_disable; | 1465 | call->unregfunc = probe_event_disable; |
| 1435 | 1466 | ||
| 1436 | #ifdef CONFIG_EVENT_PROFILE | 1467 | #ifdef CONFIG_EVENT_PROFILE |
| 1437 | atomic_set(&call->profile_count, -1); | ||
| 1438 | call->profile_enable = probe_profile_enable; | 1468 | call->profile_enable = probe_profile_enable; |
| 1439 | call->profile_disable = probe_profile_disable; | 1469 | call->profile_disable = probe_profile_disable; |
| 1440 | #endif | 1470 | #endif |
diff --git a/kernel/trace/trace_ksym.c b/kernel/trace/trace_ksym.c index ddfa0fd43bc0..94103cdcf9d8 100644 --- a/kernel/trace/trace_ksym.c +++ b/kernel/trace/trace_ksym.c | |||
| @@ -26,12 +26,13 @@ | |||
| 26 | #include <linux/fs.h> | 26 | #include <linux/fs.h> |
| 27 | 27 | ||
| 28 | #include "trace_output.h" | 28 | #include "trace_output.h" |
| 29 | #include "trace_stat.h" | ||
| 30 | #include "trace.h" | 29 | #include "trace.h" |
| 31 | 30 | ||
| 32 | #include <linux/hw_breakpoint.h> | 31 | #include <linux/hw_breakpoint.h> |
| 33 | #include <asm/hw_breakpoint.h> | 32 | #include <asm/hw_breakpoint.h> |
| 34 | 33 | ||
| 34 | #include <asm/atomic.h> | ||
| 35 | |||
| 35 | /* | 36 | /* |
| 36 | * For now, let us restrict the no. of symbols traced simultaneously to number | 37 | * For now, let us restrict the no. of symbols traced simultaneously to number |
| 37 | * of available hardware breakpoint registers. | 38 | * of available hardware breakpoint registers. |
| @@ -44,7 +45,7 @@ struct trace_ksym { | |||
| 44 | struct perf_event **ksym_hbp; | 45 | struct perf_event **ksym_hbp; |
| 45 | struct perf_event_attr attr; | 46 | struct perf_event_attr attr; |
| 46 | #ifdef CONFIG_PROFILE_KSYM_TRACER | 47 | #ifdef CONFIG_PROFILE_KSYM_TRACER |
| 47 | unsigned long counter; | 48 | atomic64_t counter; |
| 48 | #endif | 49 | #endif |
| 49 | struct hlist_node ksym_hlist; | 50 | struct hlist_node ksym_hlist; |
| 50 | }; | 51 | }; |
| @@ -69,9 +70,8 @@ void ksym_collect_stats(unsigned long hbp_hit_addr) | |||
| 69 | 70 | ||
| 70 | rcu_read_lock(); | 71 | rcu_read_lock(); |
| 71 | hlist_for_each_entry_rcu(entry, node, &ksym_filter_head, ksym_hlist) { | 72 | hlist_for_each_entry_rcu(entry, node, &ksym_filter_head, ksym_hlist) { |
| 72 | if ((entry->attr.bp_addr == hbp_hit_addr) && | 73 | if (entry->attr.bp_addr == hbp_hit_addr) { |
| 73 | (entry->counter <= MAX_UL_INT)) { | 74 | atomic64_inc(&entry->counter); |
| 74 | entry->counter++; | ||
| 75 | break; | 75 | break; |
| 76 | } | 76 | } |
| 77 | } | 77 | } |
| @@ -79,11 +79,12 @@ void ksym_collect_stats(unsigned long hbp_hit_addr) | |||
| 79 | } | 79 | } |
| 80 | #endif /* CONFIG_PROFILE_KSYM_TRACER */ | 80 | #endif /* CONFIG_PROFILE_KSYM_TRACER */ |
| 81 | 81 | ||
| 82 | void ksym_hbp_handler(struct perf_event *hbp, void *data) | 82 | void ksym_hbp_handler(struct perf_event *hbp, int nmi, |
| 83 | struct perf_sample_data *data, | ||
| 84 | struct pt_regs *regs) | ||
| 83 | { | 85 | { |
| 84 | struct ring_buffer_event *event; | 86 | struct ring_buffer_event *event; |
| 85 | struct ksym_trace_entry *entry; | 87 | struct ksym_trace_entry *entry; |
| 86 | struct pt_regs *regs = data; | ||
| 87 | struct ring_buffer *buffer; | 88 | struct ring_buffer *buffer; |
| 88 | int pc; | 89 | int pc; |
| 89 | 90 | ||
| @@ -196,7 +197,6 @@ int process_new_ksym_entry(char *ksymname, int op, unsigned long addr) | |||
| 196 | entry->attr.bp_addr = addr; | 197 | entry->attr.bp_addr = addr; |
| 197 | entry->attr.bp_len = HW_BREAKPOINT_LEN_4; | 198 | entry->attr.bp_len = HW_BREAKPOINT_LEN_4; |
| 198 | 199 | ||
| 199 | ret = -EAGAIN; | ||
| 200 | entry->ksym_hbp = register_wide_hw_breakpoint(&entry->attr, | 200 | entry->ksym_hbp = register_wide_hw_breakpoint(&entry->attr, |
| 201 | ksym_hbp_handler); | 201 | ksym_hbp_handler); |
| 202 | 202 | ||
| @@ -235,7 +235,8 @@ static ssize_t ksym_trace_filter_read(struct file *filp, char __user *ubuf, | |||
| 235 | mutex_lock(&ksym_tracer_mutex); | 235 | mutex_lock(&ksym_tracer_mutex); |
| 236 | 236 | ||
| 237 | hlist_for_each_entry(entry, node, &ksym_filter_head, ksym_hlist) { | 237 | hlist_for_each_entry(entry, node, &ksym_filter_head, ksym_hlist) { |
| 238 | ret = trace_seq_printf(s, "%pS:", (void *)entry->attr.bp_addr); | 238 | ret = trace_seq_printf(s, "%pS:", |
| 239 | (void *)(unsigned long)entry->attr.bp_addr); | ||
| 239 | if (entry->attr.bp_type == HW_BREAKPOINT_R) | 240 | if (entry->attr.bp_type == HW_BREAKPOINT_R) |
| 240 | ret = trace_seq_puts(s, "r--\n"); | 241 | ret = trace_seq_puts(s, "r--\n"); |
| 241 | else if (entry->attr.bp_type == HW_BREAKPOINT_W) | 242 | else if (entry->attr.bp_type == HW_BREAKPOINT_W) |
| @@ -277,21 +278,20 @@ static ssize_t ksym_trace_filter_write(struct file *file, | |||
| 277 | { | 278 | { |
| 278 | struct trace_ksym *entry; | 279 | struct trace_ksym *entry; |
| 279 | struct hlist_node *node; | 280 | struct hlist_node *node; |
| 280 | char *input_string, *ksymname = NULL; | 281 | char *buf, *input_string, *ksymname = NULL; |
| 281 | unsigned long ksym_addr = 0; | 282 | unsigned long ksym_addr = 0; |
| 282 | int ret, op, changed = 0; | 283 | int ret, op, changed = 0; |
| 283 | 284 | ||
| 284 | input_string = kzalloc(count + 1, GFP_KERNEL); | 285 | buf = kzalloc(count + 1, GFP_KERNEL); |
| 285 | if (!input_string) | 286 | if (!buf) |
| 286 | return -ENOMEM; | 287 | return -ENOMEM; |
| 287 | 288 | ||
| 288 | if (copy_from_user(input_string, buffer, count)) { | 289 | ret = -EFAULT; |
| 289 | kfree(input_string); | 290 | if (copy_from_user(buf, buffer, count)) |
| 290 | return -EFAULT; | 291 | goto out; |
| 291 | } | ||
| 292 | input_string[count] = '\0'; | ||
| 293 | 292 | ||
| 294 | strstrip(input_string); | 293 | buf[count] = '\0'; |
| 294 | input_string = strstrip(buf); | ||
| 295 | 295 | ||
| 296 | /* | 296 | /* |
| 297 | * Clear all breakpoints if: | 297 | * Clear all breakpoints if: |
| @@ -302,15 +302,13 @@ static ssize_t ksym_trace_filter_write(struct file *file, | |||
| 302 | if (!input_string[0] || !strcmp(input_string, "0") || | 302 | if (!input_string[0] || !strcmp(input_string, "0") || |
| 303 | !strcmp(input_string, "*:---")) { | 303 | !strcmp(input_string, "*:---")) { |
| 304 | __ksym_trace_reset(); | 304 | __ksym_trace_reset(); |
| 305 | kfree(input_string); | 305 | ret = 0; |
| 306 | return count; | 306 | goto out; |
| 307 | } | 307 | } |
| 308 | 308 | ||
| 309 | ret = op = parse_ksym_trace_str(input_string, &ksymname, &ksym_addr); | 309 | ret = op = parse_ksym_trace_str(input_string, &ksymname, &ksym_addr); |
| 310 | if (ret < 0) { | 310 | if (ret < 0) |
| 311 | kfree(input_string); | 311 | goto out; |
| 312 | return ret; | ||
| 313 | } | ||
| 314 | 312 | ||
| 315 | mutex_lock(&ksym_tracer_mutex); | 313 | mutex_lock(&ksym_tracer_mutex); |
| 316 | 314 | ||
| @@ -321,7 +319,7 @@ static ssize_t ksym_trace_filter_write(struct file *file, | |||
| 321 | if (entry->attr.bp_type != op) | 319 | if (entry->attr.bp_type != op) |
| 322 | changed = 1; | 320 | changed = 1; |
| 323 | else | 321 | else |
| 324 | goto out; | 322 | goto out_unlock; |
| 325 | break; | 323 | break; |
| 326 | } | 324 | } |
| 327 | } | 325 | } |
| @@ -336,28 +334,24 @@ static ssize_t ksym_trace_filter_write(struct file *file, | |||
| 336 | if (IS_ERR(entry->ksym_hbp)) | 334 | if (IS_ERR(entry->ksym_hbp)) |
| 337 | ret = PTR_ERR(entry->ksym_hbp); | 335 | ret = PTR_ERR(entry->ksym_hbp); |
| 338 | else | 336 | else |
| 339 | goto out; | 337 | goto out_unlock; |
| 340 | } | 338 | } |
| 341 | /* Error or "symbol:---" case: drop it */ | 339 | /* Error or "symbol:---" case: drop it */ |
| 342 | ksym_filter_entry_count--; | 340 | ksym_filter_entry_count--; |
| 343 | hlist_del_rcu(&(entry->ksym_hlist)); | 341 | hlist_del_rcu(&(entry->ksym_hlist)); |
| 344 | synchronize_rcu(); | 342 | synchronize_rcu(); |
| 345 | kfree(entry); | 343 | kfree(entry); |
| 346 | goto out; | 344 | goto out_unlock; |
| 347 | } else { | 345 | } else { |
| 348 | /* Check for malformed request: (4) */ | 346 | /* Check for malformed request: (4) */ |
| 349 | if (op == 0) | 347 | if (op) |
| 350 | goto out; | 348 | ret = process_new_ksym_entry(ksymname, op, ksym_addr); |
| 351 | ret = process_new_ksym_entry(ksymname, op, ksym_addr); | ||
| 352 | } | 349 | } |
| 353 | out: | 350 | out_unlock: |
| 354 | mutex_unlock(&ksym_tracer_mutex); | 351 | mutex_unlock(&ksym_tracer_mutex); |
| 355 | 352 | out: | |
| 356 | kfree(input_string); | 353 | kfree(buf); |
| 357 | 354 | return !ret ? count : ret; | |
| 358 | if (!ret) | ||
| 359 | ret = count; | ||
| 360 | return ret; | ||
| 361 | } | 355 | } |
| 362 | 356 | ||
| 363 | static const struct file_operations ksym_tracing_fops = { | 357 | static const struct file_operations ksym_tracing_fops = { |
| @@ -449,102 +443,77 @@ struct tracer ksym_tracer __read_mostly = | |||
| 449 | .print_line = ksym_trace_output | 443 | .print_line = ksym_trace_output |
| 450 | }; | 444 | }; |
| 451 | 445 | ||
| 452 | __init static int init_ksym_trace(void) | ||
| 453 | { | ||
| 454 | struct dentry *d_tracer; | ||
| 455 | struct dentry *entry; | ||
| 456 | |||
| 457 | d_tracer = tracing_init_dentry(); | ||
| 458 | ksym_filter_entry_count = 0; | ||
| 459 | |||
| 460 | entry = debugfs_create_file("ksym_trace_filter", 0644, d_tracer, | ||
| 461 | NULL, &ksym_tracing_fops); | ||
| 462 | if (!entry) | ||
| 463 | pr_warning("Could not create debugfs " | ||
| 464 | "'ksym_trace_filter' file\n"); | ||
| 465 | |||
| 466 | return register_tracer(&ksym_tracer); | ||
| 467 | } | ||
| 468 | device_initcall(init_ksym_trace); | ||
| 469 | |||
| 470 | |||
| 471 | #ifdef CONFIG_PROFILE_KSYM_TRACER | 446 | #ifdef CONFIG_PROFILE_KSYM_TRACER |
| 472 | static int ksym_tracer_stat_headers(struct seq_file *m) | 447 | static int ksym_profile_show(struct seq_file *m, void *v) |
| 473 | { | 448 | { |
| 449 | struct hlist_node *node; | ||
| 450 | struct trace_ksym *entry; | ||
| 451 | int access_type = 0; | ||
| 452 | char fn_name[KSYM_NAME_LEN]; | ||
| 453 | |||
| 474 | seq_puts(m, " Access Type "); | 454 | seq_puts(m, " Access Type "); |
| 475 | seq_puts(m, " Symbol Counter\n"); | 455 | seq_puts(m, " Symbol Counter\n"); |
| 476 | seq_puts(m, " ----------- "); | 456 | seq_puts(m, " ----------- "); |
| 477 | seq_puts(m, " ------ -------\n"); | 457 | seq_puts(m, " ------ -------\n"); |
| 478 | return 0; | ||
| 479 | } | ||
| 480 | 458 | ||
| 481 | static int ksym_tracer_stat_show(struct seq_file *m, void *v) | 459 | rcu_read_lock(); |
| 482 | { | 460 | hlist_for_each_entry_rcu(entry, node, &ksym_filter_head, ksym_hlist) { |
| 483 | struct hlist_node *stat = v; | ||
| 484 | struct trace_ksym *entry; | ||
| 485 | int access_type = 0; | ||
| 486 | char fn_name[KSYM_NAME_LEN]; | ||
| 487 | 461 | ||
| 488 | entry = hlist_entry(stat, struct trace_ksym, ksym_hlist); | 462 | access_type = entry->attr.bp_type; |
| 489 | 463 | ||
| 490 | access_type = entry->attr.bp_type; | 464 | switch (access_type) { |
| 465 | case HW_BREAKPOINT_R: | ||
| 466 | seq_puts(m, " R "); | ||
| 467 | break; | ||
| 468 | case HW_BREAKPOINT_W: | ||
| 469 | seq_puts(m, " W "); | ||
| 470 | break; | ||
| 471 | case HW_BREAKPOINT_R | HW_BREAKPOINT_W: | ||
| 472 | seq_puts(m, " RW "); | ||
| 473 | break; | ||
| 474 | default: | ||
| 475 | seq_puts(m, " NA "); | ||
| 476 | } | ||
| 491 | 477 | ||
| 492 | switch (access_type) { | 478 | if (lookup_symbol_name(entry->attr.bp_addr, fn_name) >= 0) |
| 493 | case HW_BREAKPOINT_R: | 479 | seq_printf(m, " %-36s", fn_name); |
| 494 | seq_puts(m, " R "); | 480 | else |
| 495 | break; | 481 | seq_printf(m, " %-36s", "<NA>"); |
| 496 | case HW_BREAKPOINT_W: | 482 | seq_printf(m, " %15llu\n", |
| 497 | seq_puts(m, " W "); | 483 | (unsigned long long)atomic64_read(&entry->counter)); |
| 498 | break; | ||
| 499 | case HW_BREAKPOINT_R | HW_BREAKPOINT_W: | ||
| 500 | seq_puts(m, " RW "); | ||
| 501 | break; | ||
| 502 | default: | ||
| 503 | seq_puts(m, " NA "); | ||
| 504 | } | 484 | } |
| 505 | 485 | rcu_read_unlock(); | |
| 506 | if (lookup_symbol_name(entry->attr.bp_addr, fn_name) >= 0) | ||
| 507 | seq_printf(m, " %-36s", fn_name); | ||
| 508 | else | ||
| 509 | seq_printf(m, " %-36s", "<NA>"); | ||
| 510 | seq_printf(m, " %15lu\n", entry->counter); | ||
| 511 | 486 | ||
| 512 | return 0; | 487 | return 0; |
| 513 | } | 488 | } |
| 514 | 489 | ||
| 515 | static void *ksym_tracer_stat_start(struct tracer_stat *trace) | 490 | static int ksym_profile_open(struct inode *node, struct file *file) |
| 516 | { | 491 | { |
| 517 | return ksym_filter_head.first; | 492 | return single_open(file, ksym_profile_show, NULL); |
| 518 | } | 493 | } |
| 519 | 494 | ||
| 520 | static void * | 495 | static const struct file_operations ksym_profile_fops = { |
| 521 | ksym_tracer_stat_next(void *v, int idx) | 496 | .open = ksym_profile_open, |
| 522 | { | 497 | .read = seq_read, |
| 523 | struct hlist_node *stat = v; | 498 | .llseek = seq_lseek, |
| 524 | 499 | .release = single_release, | |
| 525 | return stat->next; | ||
| 526 | } | ||
| 527 | |||
| 528 | static struct tracer_stat ksym_tracer_stats = { | ||
| 529 | .name = "ksym_tracer", | ||
| 530 | .stat_start = ksym_tracer_stat_start, | ||
| 531 | .stat_next = ksym_tracer_stat_next, | ||
| 532 | .stat_headers = ksym_tracer_stat_headers, | ||
| 533 | .stat_show = ksym_tracer_stat_show | ||
| 534 | }; | 500 | }; |
| 501 | #endif /* CONFIG_PROFILE_KSYM_TRACER */ | ||
| 535 | 502 | ||
| 536 | __init static int ksym_tracer_stat_init(void) | 503 | __init static int init_ksym_trace(void) |
| 537 | { | 504 | { |
| 538 | int ret; | 505 | struct dentry *d_tracer; |
| 539 | 506 | ||
| 540 | ret = register_stat_tracer(&ksym_tracer_stats); | 507 | d_tracer = tracing_init_dentry(); |
| 541 | if (ret) { | ||
| 542 | printk(KERN_WARNING "Warning: could not register " | ||
| 543 | "ksym tracer stats\n"); | ||
| 544 | return 1; | ||
| 545 | } | ||
| 546 | 508 | ||
| 547 | return 0; | 509 | trace_create_file("ksym_trace_filter", 0644, d_tracer, |
| 510 | NULL, &ksym_tracing_fops); | ||
| 511 | |||
| 512 | #ifdef CONFIG_PROFILE_KSYM_TRACER | ||
| 513 | trace_create_file("ksym_profile", 0444, d_tracer, | ||
| 514 | NULL, &ksym_profile_fops); | ||
| 515 | #endif | ||
| 516 | |||
| 517 | return register_tracer(&ksym_tracer); | ||
| 548 | } | 518 | } |
| 549 | fs_initcall(ksym_tracer_stat_init); | 519 | device_initcall(init_ksym_trace); |
| 550 | #endif /* CONFIG_PROFILE_KSYM_TRACER */ | ||
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c index b6c12c6a1bcd..8e46b3323cdc 100644 --- a/kernel/trace/trace_output.c +++ b/kernel/trace/trace_output.c | |||
| @@ -23,13 +23,21 @@ static struct hlist_head event_hash[EVENT_HASHSIZE] __read_mostly; | |||
| 23 | 23 | ||
| 24 | static int next_event_type = __TRACE_LAST_TYPE + 1; | 24 | static int next_event_type = __TRACE_LAST_TYPE + 1; |
| 25 | 25 | ||
| 26 | void trace_print_seq(struct seq_file *m, struct trace_seq *s) | 26 | int trace_print_seq(struct seq_file *m, struct trace_seq *s) |
| 27 | { | 27 | { |
| 28 | int len = s->len >= PAGE_SIZE ? PAGE_SIZE - 1 : s->len; | 28 | int len = s->len >= PAGE_SIZE ? PAGE_SIZE - 1 : s->len; |
| 29 | int ret; | ||
| 30 | |||
| 31 | ret = seq_write(m, s->buffer, len); | ||
| 29 | 32 | ||
| 30 | seq_write(m, s->buffer, len); | 33 | /* |
| 34 | * Only reset this buffer if we successfully wrote to the | ||
| 35 | * seq_file buffer. | ||
| 36 | */ | ||
| 37 | if (!ret) | ||
| 38 | trace_seq_init(s); | ||
| 31 | 39 | ||
| 32 | trace_seq_init(s); | 40 | return ret; |
| 33 | } | 41 | } |
| 34 | 42 | ||
| 35 | enum print_line_t trace_print_bprintk_msg_only(struct trace_iterator *iter) | 43 | enum print_line_t trace_print_bprintk_msg_only(struct trace_iterator *iter) |
| @@ -85,7 +93,7 @@ trace_seq_printf(struct trace_seq *s, const char *fmt, ...) | |||
| 85 | va_list ap; | 93 | va_list ap; |
| 86 | int ret; | 94 | int ret; |
| 87 | 95 | ||
| 88 | if (!len) | 96 | if (s->full || !len) |
| 89 | return 0; | 97 | return 0; |
| 90 | 98 | ||
| 91 | va_start(ap, fmt); | 99 | va_start(ap, fmt); |
| @@ -93,8 +101,10 @@ trace_seq_printf(struct trace_seq *s, const char *fmt, ...) | |||
| 93 | va_end(ap); | 101 | va_end(ap); |
| 94 | 102 | ||
| 95 | /* If we can't write it all, don't bother writing anything */ | 103 | /* If we can't write it all, don't bother writing anything */ |
| 96 | if (ret >= len) | 104 | if (ret >= len) { |
| 105 | s->full = 1; | ||
| 97 | return 0; | 106 | return 0; |
| 107 | } | ||
| 98 | 108 | ||
| 99 | s->len += ret; | 109 | s->len += ret; |
| 100 | 110 | ||
| @@ -119,14 +129,16 @@ trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args) | |||
| 119 | int len = (PAGE_SIZE - 1) - s->len; | 129 | int len = (PAGE_SIZE - 1) - s->len; |
| 120 | int ret; | 130 | int ret; |
| 121 | 131 | ||
| 122 | if (!len) | 132 | if (s->full || !len) |
| 123 | return 0; | 133 | return 0; |
| 124 | 134 | ||
| 125 | ret = vsnprintf(s->buffer + s->len, len, fmt, args); | 135 | ret = vsnprintf(s->buffer + s->len, len, fmt, args); |
| 126 | 136 | ||
| 127 | /* If we can't write it all, don't bother writing anything */ | 137 | /* If we can't write it all, don't bother writing anything */ |
| 128 | if (ret >= len) | 138 | if (ret >= len) { |
| 139 | s->full = 1; | ||
| 129 | return 0; | 140 | return 0; |
| 141 | } | ||
| 130 | 142 | ||
| 131 | s->len += ret; | 143 | s->len += ret; |
| 132 | 144 | ||
| @@ -139,14 +151,16 @@ int trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary) | |||
| 139 | int len = (PAGE_SIZE - 1) - s->len; | 151 | int len = (PAGE_SIZE - 1) - s->len; |
| 140 | int ret; | 152 | int ret; |
| 141 | 153 | ||
| 142 | if (!len) | 154 | if (s->full || !len) |
| 143 | return 0; | 155 | return 0; |
| 144 | 156 | ||
| 145 | ret = bstr_printf(s->buffer + s->len, len, fmt, binary); | 157 | ret = bstr_printf(s->buffer + s->len, len, fmt, binary); |
| 146 | 158 | ||
| 147 | /* If we can't write it all, don't bother writing anything */ | 159 | /* If we can't write it all, don't bother writing anything */ |
| 148 | if (ret >= len) | 160 | if (ret >= len) { |
| 161 | s->full = 1; | ||
| 149 | return 0; | 162 | return 0; |
| 163 | } | ||
| 150 | 164 | ||
| 151 | s->len += ret; | 165 | s->len += ret; |
| 152 | 166 | ||
| @@ -167,8 +181,13 @@ int trace_seq_puts(struct trace_seq *s, const char *str) | |||
| 167 | { | 181 | { |
| 168 | int len = strlen(str); | 182 | int len = strlen(str); |
| 169 | 183 | ||
| 170 | if (len > ((PAGE_SIZE - 1) - s->len)) | 184 | if (s->full) |
| 185 | return 0; | ||
| 186 | |||
| 187 | if (len > ((PAGE_SIZE - 1) - s->len)) { | ||
| 188 | s->full = 1; | ||
| 171 | return 0; | 189 | return 0; |
| 190 | } | ||
| 172 | 191 | ||
| 173 | memcpy(s->buffer + s->len, str, len); | 192 | memcpy(s->buffer + s->len, str, len); |
| 174 | s->len += len; | 193 | s->len += len; |
| @@ -178,9 +197,14 @@ int trace_seq_puts(struct trace_seq *s, const char *str) | |||
| 178 | 197 | ||
| 179 | int trace_seq_putc(struct trace_seq *s, unsigned char c) | 198 | int trace_seq_putc(struct trace_seq *s, unsigned char c) |
| 180 | { | 199 | { |
| 181 | if (s->len >= (PAGE_SIZE - 1)) | 200 | if (s->full) |
| 182 | return 0; | 201 | return 0; |
| 183 | 202 | ||
| 203 | if (s->len >= (PAGE_SIZE - 1)) { | ||
| 204 | s->full = 1; | ||
| 205 | return 0; | ||
| 206 | } | ||
| 207 | |||
| 184 | s->buffer[s->len++] = c; | 208 | s->buffer[s->len++] = c; |
| 185 | 209 | ||
| 186 | return 1; | 210 | return 1; |
| @@ -188,9 +212,14 @@ int trace_seq_putc(struct trace_seq *s, unsigned char c) | |||
| 188 | 212 | ||
| 189 | int trace_seq_putmem(struct trace_seq *s, const void *mem, size_t len) | 213 | int trace_seq_putmem(struct trace_seq *s, const void *mem, size_t len) |
| 190 | { | 214 | { |
| 191 | if (len > ((PAGE_SIZE - 1) - s->len)) | 215 | if (s->full) |
| 192 | return 0; | 216 | return 0; |
| 193 | 217 | ||
| 218 | if (len > ((PAGE_SIZE - 1) - s->len)) { | ||
| 219 | s->full = 1; | ||
| 220 | return 0; | ||
| 221 | } | ||
| 222 | |||
| 194 | memcpy(s->buffer + s->len, mem, len); | 223 | memcpy(s->buffer + s->len, mem, len); |
| 195 | s->len += len; | 224 | s->len += len; |
| 196 | 225 | ||
| @@ -203,6 +232,9 @@ int trace_seq_putmem_hex(struct trace_seq *s, const void *mem, size_t len) | |||
| 203 | const unsigned char *data = mem; | 232 | const unsigned char *data = mem; |
| 204 | int i, j; | 233 | int i, j; |
| 205 | 234 | ||
| 235 | if (s->full) | ||
| 236 | return 0; | ||
| 237 | |||
| 206 | #ifdef __BIG_ENDIAN | 238 | #ifdef __BIG_ENDIAN |
| 207 | for (i = 0, j = 0; i < len; i++) { | 239 | for (i = 0, j = 0; i < len; i++) { |
| 208 | #else | 240 | #else |
| @@ -220,8 +252,13 @@ void *trace_seq_reserve(struct trace_seq *s, size_t len) | |||
| 220 | { | 252 | { |
| 221 | void *ret; | 253 | void *ret; |
| 222 | 254 | ||
| 223 | if (len > ((PAGE_SIZE - 1) - s->len)) | 255 | if (s->full) |
| 256 | return 0; | ||
| 257 | |||
| 258 | if (len > ((PAGE_SIZE - 1) - s->len)) { | ||
| 259 | s->full = 1; | ||
| 224 | return NULL; | 260 | return NULL; |
| 261 | } | ||
| 225 | 262 | ||
| 226 | ret = s->buffer + s->len; | 263 | ret = s->buffer + s->len; |
| 227 | s->len += len; | 264 | s->len += len; |
| @@ -233,8 +270,14 @@ int trace_seq_path(struct trace_seq *s, struct path *path) | |||
| 233 | { | 270 | { |
| 234 | unsigned char *p; | 271 | unsigned char *p; |
| 235 | 272 | ||
| 236 | if (s->len >= (PAGE_SIZE - 1)) | 273 | if (s->full) |
| 274 | return 0; | ||
| 275 | |||
| 276 | if (s->len >= (PAGE_SIZE - 1)) { | ||
| 277 | s->full = 1; | ||
| 237 | return 0; | 278 | return 0; |
| 279 | } | ||
| 280 | |||
| 238 | p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len); | 281 | p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len); |
| 239 | if (!IS_ERR(p)) { | 282 | if (!IS_ERR(p)) { |
| 240 | p = mangle_path(s->buffer + s->len, p, "\n"); | 283 | p = mangle_path(s->buffer + s->len, p, "\n"); |
| @@ -247,6 +290,7 @@ int trace_seq_path(struct trace_seq *s, struct path *path) | |||
| 247 | return 1; | 290 | return 1; |
| 248 | } | 291 | } |
| 249 | 292 | ||
| 293 | s->full = 1; | ||
| 250 | return 0; | 294 | return 0; |
| 251 | } | 295 | } |
| 252 | 296 | ||
| @@ -373,6 +417,9 @@ int seq_print_user_ip(struct trace_seq *s, struct mm_struct *mm, | |||
| 373 | unsigned long vmstart = 0; | 417 | unsigned long vmstart = 0; |
| 374 | int ret = 1; | 418 | int ret = 1; |
| 375 | 419 | ||
| 420 | if (s->full) | ||
| 421 | return 0; | ||
| 422 | |||
| 376 | if (mm) { | 423 | if (mm) { |
| 377 | const struct vm_area_struct *vma; | 424 | const struct vm_area_struct *vma; |
| 378 | 425 | ||
diff --git a/kernel/trace/trace_sched_wakeup.c b/kernel/trace/trace_sched_wakeup.c index 26185d727676..0271742abb8d 100644 --- a/kernel/trace/trace_sched_wakeup.c +++ b/kernel/trace/trace_sched_wakeup.c | |||
| @@ -28,8 +28,8 @@ static int wakeup_current_cpu; | |||
| 28 | static unsigned wakeup_prio = -1; | 28 | static unsigned wakeup_prio = -1; |
| 29 | static int wakeup_rt; | 29 | static int wakeup_rt; |
| 30 | 30 | ||
| 31 | static raw_spinlock_t wakeup_lock = | 31 | static arch_spinlock_t wakeup_lock = |
| 32 | (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED; | 32 | (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED; |
| 33 | 33 | ||
| 34 | static void __wakeup_reset(struct trace_array *tr); | 34 | static void __wakeup_reset(struct trace_array *tr); |
| 35 | 35 | ||
| @@ -143,7 +143,7 @@ probe_wakeup_sched_switch(struct rq *rq, struct task_struct *prev, | |||
| 143 | goto out; | 143 | goto out; |
| 144 | 144 | ||
| 145 | local_irq_save(flags); | 145 | local_irq_save(flags); |
| 146 | __raw_spin_lock(&wakeup_lock); | 146 | arch_spin_lock(&wakeup_lock); |
| 147 | 147 | ||
| 148 | /* We could race with grabbing wakeup_lock */ | 148 | /* We could race with grabbing wakeup_lock */ |
| 149 | if (unlikely(!tracer_enabled || next != wakeup_task)) | 149 | if (unlikely(!tracer_enabled || next != wakeup_task)) |
| @@ -169,7 +169,7 @@ probe_wakeup_sched_switch(struct rq *rq, struct task_struct *prev, | |||
| 169 | 169 | ||
| 170 | out_unlock: | 170 | out_unlock: |
| 171 | __wakeup_reset(wakeup_trace); | 171 | __wakeup_reset(wakeup_trace); |
| 172 | __raw_spin_unlock(&wakeup_lock); | 172 | arch_spin_unlock(&wakeup_lock); |
| 173 | local_irq_restore(flags); | 173 | local_irq_restore(flags); |
| 174 | out: | 174 | out: |
| 175 | atomic_dec(&wakeup_trace->data[cpu]->disabled); | 175 | atomic_dec(&wakeup_trace->data[cpu]->disabled); |
| @@ -193,9 +193,9 @@ static void wakeup_reset(struct trace_array *tr) | |||
| 193 | tracing_reset_online_cpus(tr); | 193 | tracing_reset_online_cpus(tr); |
| 194 | 194 | ||
| 195 | local_irq_save(flags); | 195 | local_irq_save(flags); |
| 196 | __raw_spin_lock(&wakeup_lock); | 196 | arch_spin_lock(&wakeup_lock); |
| 197 | __wakeup_reset(tr); | 197 | __wakeup_reset(tr); |
| 198 | __raw_spin_unlock(&wakeup_lock); | 198 | arch_spin_unlock(&wakeup_lock); |
| 199 | local_irq_restore(flags); | 199 | local_irq_restore(flags); |
| 200 | } | 200 | } |
| 201 | 201 | ||
| @@ -225,7 +225,7 @@ probe_wakeup(struct rq *rq, struct task_struct *p, int success) | |||
| 225 | goto out; | 225 | goto out; |
| 226 | 226 | ||
| 227 | /* interrupts should be off from try_to_wake_up */ | 227 | /* interrupts should be off from try_to_wake_up */ |
| 228 | __raw_spin_lock(&wakeup_lock); | 228 | arch_spin_lock(&wakeup_lock); |
| 229 | 229 | ||
| 230 | /* check for races. */ | 230 | /* check for races. */ |
| 231 | if (!tracer_enabled || p->prio >= wakeup_prio) | 231 | if (!tracer_enabled || p->prio >= wakeup_prio) |
| @@ -255,7 +255,7 @@ probe_wakeup(struct rq *rq, struct task_struct *p, int success) | |||
| 255 | trace_function(wakeup_trace, CALLER_ADDR1, CALLER_ADDR2, flags, pc); | 255 | trace_function(wakeup_trace, CALLER_ADDR1, CALLER_ADDR2, flags, pc); |
| 256 | 256 | ||
| 257 | out_locked: | 257 | out_locked: |
| 258 | __raw_spin_unlock(&wakeup_lock); | 258 | arch_spin_unlock(&wakeup_lock); |
| 259 | out: | 259 | out: |
| 260 | atomic_dec(&wakeup_trace->data[cpu]->disabled); | 260 | atomic_dec(&wakeup_trace->data[cpu]->disabled); |
| 261 | } | 261 | } |
diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c index dc98309e839a..280fea470d67 100644 --- a/kernel/trace/trace_selftest.c +++ b/kernel/trace/trace_selftest.c | |||
| @@ -67,7 +67,7 @@ static int trace_test_buffer(struct trace_array *tr, unsigned long *count) | |||
| 67 | 67 | ||
| 68 | /* Don't allow flipping of max traces now */ | 68 | /* Don't allow flipping of max traces now */ |
| 69 | local_irq_save(flags); | 69 | local_irq_save(flags); |
| 70 | __raw_spin_lock(&ftrace_max_lock); | 70 | arch_spin_lock(&ftrace_max_lock); |
| 71 | 71 | ||
| 72 | cnt = ring_buffer_entries(tr->buffer); | 72 | cnt = ring_buffer_entries(tr->buffer); |
| 73 | 73 | ||
| @@ -85,7 +85,7 @@ static int trace_test_buffer(struct trace_array *tr, unsigned long *count) | |||
| 85 | break; | 85 | break; |
| 86 | } | 86 | } |
| 87 | tracing_on(); | 87 | tracing_on(); |
| 88 | __raw_spin_unlock(&ftrace_max_lock); | 88 | arch_spin_unlock(&ftrace_max_lock); |
| 89 | local_irq_restore(flags); | 89 | local_irq_restore(flags); |
| 90 | 90 | ||
| 91 | if (count) | 91 | if (count) |
diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c index 8504ac71e4e8..678a5120ee30 100644 --- a/kernel/trace/trace_stack.c +++ b/kernel/trace/trace_stack.c | |||
| @@ -27,8 +27,8 @@ static struct stack_trace max_stack_trace = { | |||
| 27 | }; | 27 | }; |
| 28 | 28 | ||
| 29 | static unsigned long max_stack_size; | 29 | static unsigned long max_stack_size; |
| 30 | static raw_spinlock_t max_stack_lock = | 30 | static arch_spinlock_t max_stack_lock = |
| 31 | (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED; | 31 | (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED; |
| 32 | 32 | ||
| 33 | static int stack_trace_disabled __read_mostly; | 33 | static int stack_trace_disabled __read_mostly; |
| 34 | static DEFINE_PER_CPU(int, trace_active); | 34 | static DEFINE_PER_CPU(int, trace_active); |
| @@ -54,7 +54,7 @@ static inline void check_stack(void) | |||
| 54 | return; | 54 | return; |
| 55 | 55 | ||
| 56 | local_irq_save(flags); | 56 | local_irq_save(flags); |
| 57 | __raw_spin_lock(&max_stack_lock); | 57 | arch_spin_lock(&max_stack_lock); |
| 58 | 58 | ||
| 59 | /* a race could have already updated it */ | 59 | /* a race could have already updated it */ |
| 60 | if (this_size <= max_stack_size) | 60 | if (this_size <= max_stack_size) |
| @@ -103,7 +103,7 @@ static inline void check_stack(void) | |||
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | out: | 105 | out: |
| 106 | __raw_spin_unlock(&max_stack_lock); | 106 | arch_spin_unlock(&max_stack_lock); |
| 107 | local_irq_restore(flags); | 107 | local_irq_restore(flags); |
| 108 | } | 108 | } |
| 109 | 109 | ||
| @@ -171,9 +171,9 @@ stack_max_size_write(struct file *filp, const char __user *ubuf, | |||
| 171 | return ret; | 171 | return ret; |
| 172 | 172 | ||
| 173 | local_irq_save(flags); | 173 | local_irq_save(flags); |
| 174 | __raw_spin_lock(&max_stack_lock); | 174 | arch_spin_lock(&max_stack_lock); |
| 175 | *ptr = val; | 175 | *ptr = val; |
| 176 | __raw_spin_unlock(&max_stack_lock); | 176 | arch_spin_unlock(&max_stack_lock); |
| 177 | local_irq_restore(flags); | 177 | local_irq_restore(flags); |
| 178 | 178 | ||
| 179 | return count; | 179 | return count; |
| @@ -207,7 +207,7 @@ t_next(struct seq_file *m, void *v, loff_t *pos) | |||
| 207 | static void *t_start(struct seq_file *m, loff_t *pos) | 207 | static void *t_start(struct seq_file *m, loff_t *pos) |
| 208 | { | 208 | { |
| 209 | local_irq_disable(); | 209 | local_irq_disable(); |
| 210 | __raw_spin_lock(&max_stack_lock); | 210 | arch_spin_lock(&max_stack_lock); |
| 211 | 211 | ||
| 212 | if (*pos == 0) | 212 | if (*pos == 0) |
| 213 | return SEQ_START_TOKEN; | 213 | return SEQ_START_TOKEN; |
| @@ -217,7 +217,7 @@ static void *t_start(struct seq_file *m, loff_t *pos) | |||
| 217 | 217 | ||
| 218 | static void t_stop(struct seq_file *m, void *p) | 218 | static void t_stop(struct seq_file *m, void *p) |
| 219 | { | 219 | { |
| 220 | __raw_spin_unlock(&max_stack_lock); | 220 | arch_spin_unlock(&max_stack_lock); |
| 221 | local_irq_enable(); | 221 | local_irq_enable(); |
| 222 | } | 222 | } |
| 223 | 223 | ||
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c index 57501d90096a..75289f372dd2 100644 --- a/kernel/trace/trace_syscalls.c +++ b/kernel/trace/trace_syscalls.c | |||
| @@ -217,10 +217,6 @@ int syscall_enter_define_fields(struct ftrace_event_call *call) | |||
| 217 | int i; | 217 | int i; |
| 218 | int offset = offsetof(typeof(trace), args); | 218 | int offset = offsetof(typeof(trace), args); |
| 219 | 219 | ||
| 220 | ret = trace_define_common_fields(call); | ||
| 221 | if (ret) | ||
| 222 | return ret; | ||
| 223 | |||
| 224 | ret = trace_define_field(call, SYSCALL_FIELD(int, nr), FILTER_OTHER); | 220 | ret = trace_define_field(call, SYSCALL_FIELD(int, nr), FILTER_OTHER); |
| 225 | if (ret) | 221 | if (ret) |
| 226 | return ret; | 222 | return ret; |
| @@ -241,10 +237,6 @@ int syscall_exit_define_fields(struct ftrace_event_call *call) | |||
| 241 | struct syscall_trace_exit trace; | 237 | struct syscall_trace_exit trace; |
| 242 | int ret; | 238 | int ret; |
| 243 | 239 | ||
| 244 | ret = trace_define_common_fields(call); | ||
| 245 | if (ret) | ||
| 246 | return ret; | ||
| 247 | |||
| 248 | ret = trace_define_field(call, SYSCALL_FIELD(int, nr), FILTER_OTHER); | 240 | ret = trace_define_field(call, SYSCALL_FIELD(int, nr), FILTER_OTHER); |
| 249 | if (ret) | 241 | if (ret) |
| 250 | return ret; | 242 | return ret; |
| @@ -333,10 +325,7 @@ int reg_event_syscall_enter(struct ftrace_event_call *call) | |||
| 333 | mutex_lock(&syscall_trace_lock); | 325 | mutex_lock(&syscall_trace_lock); |
| 334 | if (!sys_refcount_enter) | 326 | if (!sys_refcount_enter) |
| 335 | ret = register_trace_sys_enter(ftrace_syscall_enter); | 327 | ret = register_trace_sys_enter(ftrace_syscall_enter); |
| 336 | if (ret) { | 328 | if (!ret) { |
| 337 | pr_info("event trace: Could not activate" | ||
| 338 | "syscall entry trace point"); | ||
| 339 | } else { | ||
| 340 | set_bit(num, enabled_enter_syscalls); | 329 | set_bit(num, enabled_enter_syscalls); |
| 341 | sys_refcount_enter++; | 330 | sys_refcount_enter++; |
| 342 | } | 331 | } |
| @@ -370,10 +359,7 @@ int reg_event_syscall_exit(struct ftrace_event_call *call) | |||
| 370 | mutex_lock(&syscall_trace_lock); | 359 | mutex_lock(&syscall_trace_lock); |
| 371 | if (!sys_refcount_exit) | 360 | if (!sys_refcount_exit) |
| 372 | ret = register_trace_sys_exit(ftrace_syscall_exit); | 361 | ret = register_trace_sys_exit(ftrace_syscall_exit); |
| 373 | if (ret) { | 362 | if (!ret) { |
| 374 | pr_info("event trace: Could not activate" | ||
| 375 | "syscall exit trace point"); | ||
| 376 | } else { | ||
| 377 | set_bit(num, enabled_exit_syscalls); | 363 | set_bit(num, enabled_exit_syscalls); |
| 378 | sys_refcount_exit++; | 364 | sys_refcount_exit++; |
| 379 | } | 365 | } |
diff --git a/kernel/trace/trace_sysprof.c b/kernel/trace/trace_sysprof.c index f6693969287d..a7974a552ca9 100644 --- a/kernel/trace/trace_sysprof.c +++ b/kernel/trace/trace_sysprof.c | |||
| @@ -93,6 +93,7 @@ static const struct stacktrace_ops backtrace_ops = { | |||
| 93 | .warning_symbol = backtrace_warning_symbol, | 93 | .warning_symbol = backtrace_warning_symbol, |
| 94 | .stack = backtrace_stack, | 94 | .stack = backtrace_stack, |
| 95 | .address = backtrace_address, | 95 | .address = backtrace_address, |
| 96 | .walk_stack = print_context_stack, | ||
| 96 | }; | 97 | }; |
| 97 | 98 | ||
| 98 | static int | 99 | static int |
