diff options
author | Steven Rostedt (Red Hat) <rostedt@goodmis.org> | 2015-05-29 10:32:28 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2015-05-29 10:39:08 -0400 |
commit | a497adb45b8691f7e477e711a1a4bd54748d64fe (patch) | |
tree | 084b06ef058590c42e830a68faa0fa687d9fc079 | |
parent | 3c6296f716ebef704b76070d90567ab4faa8462c (diff) |
ring-buffer: Add enum names for the context levels
Instead of having hard coded numbers for the context levels, use
enums to describe them more.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | kernel/trace/ring_buffer.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index 0fc5add6423b..6260717c18e3 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c | |||
@@ -400,6 +400,23 @@ struct rb_irq_work { | |||
400 | }; | 400 | }; |
401 | 401 | ||
402 | /* | 402 | /* |
403 | * Used for which event context the event is in. | ||
404 | * NMI = 0 | ||
405 | * IRQ = 1 | ||
406 | * SOFTIRQ = 2 | ||
407 | * NORMAL = 3 | ||
408 | * | ||
409 | * See trace_recursive_lock() comment below for more details. | ||
410 | */ | ||
411 | enum { | ||
412 | RB_CTX_NMI, | ||
413 | RB_CTX_IRQ, | ||
414 | RB_CTX_SOFTIRQ, | ||
415 | RB_CTX_NORMAL, | ||
416 | RB_CTX_MAX | ||
417 | }; | ||
418 | |||
419 | /* | ||
403 | * head_page == tail_page && head == tail then buffer is empty. | 420 | * head_page == tail_page && head == tail then buffer is empty. |
404 | */ | 421 | */ |
405 | struct ring_buffer_per_cpu { | 422 | struct ring_buffer_per_cpu { |
@@ -2173,7 +2190,7 @@ static unsigned rb_calculate_event_length(unsigned length) | |||
2173 | 2190 | ||
2174 | /* zero length can cause confusions */ | 2191 | /* zero length can cause confusions */ |
2175 | if (!length) | 2192 | if (!length) |
2176 | length = 1; | 2193 | length++; |
2177 | 2194 | ||
2178 | if (length > RB_MAX_SMALL_DATA || RB_FORCE_8BYTE_ALIGNMENT) | 2195 | if (length > RB_MAX_SMALL_DATA || RB_FORCE_8BYTE_ALIGNMENT) |
2179 | length += sizeof(event.array[0]); | 2196 | length += sizeof(event.array[0]); |
@@ -2631,13 +2648,13 @@ trace_recursive_lock(struct ring_buffer_per_cpu *cpu_buffer) | |||
2631 | 2648 | ||
2632 | if (in_interrupt()) { | 2649 | if (in_interrupt()) { |
2633 | if (in_nmi()) | 2650 | if (in_nmi()) |
2634 | bit = 0; | 2651 | bit = RB_CTX_NMI; |
2635 | else if (in_irq()) | 2652 | else if (in_irq()) |
2636 | bit = 1; | 2653 | bit = RB_CTX_IRQ; |
2637 | else | 2654 | else |
2638 | bit = 2; | 2655 | bit = RB_CTX_SOFTIRQ; |
2639 | } else | 2656 | } else |
2640 | bit = 3; | 2657 | bit = RB_CTX_NORMAL; |
2641 | 2658 | ||
2642 | if (unlikely(val & (1 << bit))) | 2659 | if (unlikely(val & (1 << bit))) |
2643 | return 1; | 2660 | return 1; |