diff options
| -rw-r--r-- | Documentation/tracers/mmiotrace.txt | 6 | ||||
| -rw-r--r-- | arch/x86/Kconfig.debug | 24 | ||||
| -rw-r--r-- | kernel/trace/Kconfig | 23 | ||||
| -rw-r--r-- | kernel/trace/trace_mmiotrace.c | 14 |
4 files changed, 37 insertions, 30 deletions
diff --git a/Documentation/tracers/mmiotrace.txt b/Documentation/tracers/mmiotrace.txt index cde23b4a12a1..5731c67abc55 100644 --- a/Documentation/tracers/mmiotrace.txt +++ b/Documentation/tracers/mmiotrace.txt | |||
| @@ -78,12 +78,10 @@ to view your kernel log and look for "mmiotrace has lost events" warning. If | |||
| 78 | events were lost, the trace is incomplete. You should enlarge the buffers and | 78 | events were lost, the trace is incomplete. You should enlarge the buffers and |
| 79 | try again. Buffers are enlarged by first seeing how large the current buffers | 79 | try again. Buffers are enlarged by first seeing how large the current buffers |
| 80 | are: | 80 | are: |
| 81 | $ cat /debug/tracing/trace_entries | 81 | $ cat /debug/tracing/buffer_size_kb |
| 82 | gives you a number. Approximately double this number and write it back, for | 82 | gives you a number. Approximately double this number and write it back, for |
| 83 | instance: | 83 | instance: |
| 84 | $ echo 0 > /debug/tracing/tracing_enabled | 84 | $ echo 128000 > /debug/tracing/buffer_size_kb |
| 85 | $ echo 128000 > /debug/tracing/trace_entries | ||
| 86 | $ echo 1 > /debug/tracing/tracing_enabled | ||
| 87 | Then start again from the top. | 85 | Then start again from the top. |
| 88 | 86 | ||
| 89 | If you are doing a trace for a driver project, e.g. Nouveau, you should also | 87 | If you are doing a trace for a driver project, e.g. Nouveau, you should also |
diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug index 10d6cc3fd052..e1983fa025d2 100644 --- a/arch/x86/Kconfig.debug +++ b/arch/x86/Kconfig.debug | |||
| @@ -174,28 +174,8 @@ config IOMMU_LEAK | |||
| 174 | Add a simple leak tracer to the IOMMU code. This is useful when you | 174 | Add a simple leak tracer to the IOMMU code. This is useful when you |
| 175 | are debugging a buggy device driver that leaks IOMMU mappings. | 175 | are debugging a buggy device driver that leaks IOMMU mappings. |
| 176 | 176 | ||
| 177 | config MMIOTRACE | 177 | config HAVE_MMIOTRACE_SUPPORT |
| 178 | bool "Memory mapped IO tracing" | 178 | def_bool y |
| 179 | depends on DEBUG_KERNEL && PCI | ||
| 180 | select TRACING | ||
| 181 | help | ||
| 182 | Mmiotrace traces Memory Mapped I/O access and is meant for | ||
| 183 | debugging and reverse engineering. It is called from the ioremap | ||
| 184 | implementation and works via page faults. Tracing is disabled by | ||
| 185 | default and can be enabled at run-time. | ||
| 186 | |||
| 187 | See Documentation/tracers/mmiotrace.txt. | ||
| 188 | If you are not helping to develop drivers, say N. | ||
| 189 | |||
| 190 | config MMIOTRACE_TEST | ||
| 191 | tristate "Test module for mmiotrace" | ||
| 192 | depends on MMIOTRACE && m | ||
| 193 | help | ||
| 194 | This is a dumb module for testing mmiotrace. It is very dangerous | ||
| 195 | as it will write garbage to IO memory starting at a given address. | ||
| 196 | However, it should be safe to use on e.g. unused portion of VRAM. | ||
| 197 | |||
| 198 | Say N, unless you absolutely know what you are doing. | ||
| 199 | 179 | ||
| 200 | # | 180 | # |
| 201 | # IO delay types: | 181 | # IO delay types: |
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig index e2a4ff6fc3a6..58a93fbd68aa 100644 --- a/kernel/trace/Kconfig +++ b/kernel/trace/Kconfig | |||
| @@ -302,4 +302,27 @@ config FTRACE_STARTUP_TEST | |||
| 302 | functioning properly. It will do tests on all the configured | 302 | functioning properly. It will do tests on all the configured |
| 303 | tracers of ftrace. | 303 | tracers of ftrace. |
| 304 | 304 | ||
| 305 | config MMIOTRACE | ||
| 306 | bool "Memory mapped IO tracing" | ||
| 307 | depends on HAVE_MMIOTRACE_SUPPORT && DEBUG_KERNEL && PCI | ||
| 308 | select TRACING | ||
| 309 | help | ||
| 310 | Mmiotrace traces Memory Mapped I/O access and is meant for | ||
| 311 | debugging and reverse engineering. It is called from the ioremap | ||
| 312 | implementation and works via page faults. Tracing is disabled by | ||
| 313 | default and can be enabled at run-time. | ||
| 314 | |||
| 315 | See Documentation/tracers/mmiotrace.txt. | ||
| 316 | If you are not helping to develop drivers, say N. | ||
| 317 | |||
| 318 | config MMIOTRACE_TEST | ||
| 319 | tristate "Test module for mmiotrace" | ||
| 320 | depends on MMIOTRACE && m | ||
| 321 | help | ||
| 322 | This is a dumb module for testing mmiotrace. It is very dangerous | ||
| 323 | as it will write garbage to IO memory starting at a given address. | ||
| 324 | However, it should be safe to use on e.g. unused portion of VRAM. | ||
| 325 | |||
| 326 | Say N, unless you absolutely know what you are doing. | ||
| 327 | |||
| 305 | endmenu | 328 | endmenu |
diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c index fffcb069f1dc..80e503ef6136 100644 --- a/kernel/trace/trace_mmiotrace.c +++ b/kernel/trace/trace_mmiotrace.c | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
| 10 | #include <linux/mmiotrace.h> | 10 | #include <linux/mmiotrace.h> |
| 11 | #include <linux/pci.h> | 11 | #include <linux/pci.h> |
| 12 | #include <asm/atomic.h> | ||
| 12 | 13 | ||
| 13 | #include "trace.h" | 14 | #include "trace.h" |
| 14 | 15 | ||
| @@ -19,6 +20,7 @@ struct header_iter { | |||
| 19 | static struct trace_array *mmio_trace_array; | 20 | static struct trace_array *mmio_trace_array; |
| 20 | static bool overrun_detected; | 21 | static bool overrun_detected; |
| 21 | static unsigned long prev_overruns; | 22 | static unsigned long prev_overruns; |
| 23 | static atomic_t dropped_count; | ||
| 22 | 24 | ||
| 23 | static void mmio_reset_data(struct trace_array *tr) | 25 | static void mmio_reset_data(struct trace_array *tr) |
| 24 | { | 26 | { |
| @@ -121,11 +123,11 @@ static void mmio_close(struct trace_iterator *iter) | |||
| 121 | 123 | ||
| 122 | static unsigned long count_overruns(struct trace_iterator *iter) | 124 | static unsigned long count_overruns(struct trace_iterator *iter) |
| 123 | { | 125 | { |
| 124 | unsigned long cnt = 0; | 126 | unsigned long cnt = atomic_xchg(&dropped_count, 0); |
| 125 | unsigned long over = ring_buffer_overruns(iter->tr->buffer); | 127 | unsigned long over = ring_buffer_overruns(iter->tr->buffer); |
| 126 | 128 | ||
| 127 | if (over > prev_overruns) | 129 | if (over > prev_overruns) |
| 128 | cnt = over - prev_overruns; | 130 | cnt += over - prev_overruns; |
| 129 | prev_overruns = over; | 131 | prev_overruns = over; |
| 130 | return cnt; | 132 | return cnt; |
| 131 | } | 133 | } |
| @@ -310,8 +312,10 @@ static void __trace_mmiotrace_rw(struct trace_array *tr, | |||
| 310 | 312 | ||
| 311 | event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry), | 313 | event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry), |
| 312 | &irq_flags); | 314 | &irq_flags); |
| 313 | if (!event) | 315 | if (!event) { |
| 316 | atomic_inc(&dropped_count); | ||
| 314 | return; | 317 | return; |
| 318 | } | ||
| 315 | entry = ring_buffer_event_data(event); | 319 | entry = ring_buffer_event_data(event); |
| 316 | tracing_generic_entry_update(&entry->ent, 0, preempt_count()); | 320 | tracing_generic_entry_update(&entry->ent, 0, preempt_count()); |
| 317 | entry->ent.type = TRACE_MMIO_RW; | 321 | entry->ent.type = TRACE_MMIO_RW; |
| @@ -338,8 +342,10 @@ static void __trace_mmiotrace_map(struct trace_array *tr, | |||
| 338 | 342 | ||
| 339 | event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry), | 343 | event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry), |
| 340 | &irq_flags); | 344 | &irq_flags); |
| 341 | if (!event) | 345 | if (!event) { |
| 346 | atomic_inc(&dropped_count); | ||
| 342 | return; | 347 | return; |
| 348 | } | ||
| 343 | entry = ring_buffer_event_data(event); | 349 | entry = ring_buffer_event_data(event); |
| 344 | tracing_generic_entry_update(&entry->ent, 0, preempt_count()); | 350 | tracing_generic_entry_update(&entry->ent, 0, preempt_count()); |
| 345 | entry->ent.type = TRACE_MMIO_MAP; | 351 | entry->ent.type = TRACE_MMIO_MAP; |
