diff options
author | Steven Rostedt <srostedt@redhat.com> | 2009-03-12 22:24:17 -0400 |
---|---|---|
committer | Steven Rostedt <srostedt@redhat.com> | 2009-03-12 22:24:17 -0400 |
commit | 5cc985488845ec7227a2c5cfd2fd62cf57fb411a (patch) | |
tree | 818517eb07b585e981ce81c200294a8ec7a8e992 /kernel/trace/ring_buffer.c | |
parent | f28e55765e40450c127e44d00ae65d0cd1a4efec (diff) |
ring-buffer: document reader page design
In a private email conversation I explained how the ring buffer
page worked by using silly ASCII art. Ingo suggested that I add
that to the comments of the code.
Here it is.
Requested-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Diffstat (limited to 'kernel/trace/ring_buffer.c')
-rw-r--r-- | kernel/trace/ring_buffer.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index 2c36be9fac2e..58128ad2fde0 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c | |||
@@ -22,6 +22,74 @@ | |||
22 | #include "trace.h" | 22 | #include "trace.h" |
23 | 23 | ||
24 | /* | 24 | /* |
25 | * The ring buffer is made up of a list of pages. A separate list of pages is | ||
26 | * allocated for each CPU. A writer may only write to a buffer that is | ||
27 | * associated with the CPU it is currently executing on. A reader may read | ||
28 | * from any per cpu buffer. | ||
29 | * | ||
30 | * The reader is special. For each per cpu buffer, the reader has its own | ||
31 | * reader page. When a reader has read the entire reader page, this reader | ||
32 | * page is swapped with another page in the ring buffer. | ||
33 | * | ||
34 | * Now, as long as the writer is off the reader page, the reader can do what | ||
35 | * ever it wants with that page. The writer will never write to that page | ||
36 | * again (as long as it is out of the ring buffer). | ||
37 | * | ||
38 | * Here's some silly ASCII art. | ||
39 | * | ||
40 | * +------+ | ||
41 | * |reader| RING BUFFER | ||
42 | * |page | | ||
43 | * +------+ +---+ +---+ +---+ | ||
44 | * | |-->| |-->| | | ||
45 | * +---+ +---+ +---+ | ||
46 | * ^ | | ||
47 | * | | | ||
48 | * +---------------+ | ||
49 | * | ||
50 | * | ||
51 | * +------+ | ||
52 | * |reader| RING BUFFER | ||
53 | * |page |------------------v | ||
54 | * +------+ +---+ +---+ +---+ | ||
55 | * | |-->| |-->| | | ||
56 | * +---+ +---+ +---+ | ||
57 | * ^ | | ||
58 | * | | | ||
59 | * +---------------+ | ||
60 | * | ||
61 | * | ||
62 | * +------+ | ||
63 | * |reader| RING BUFFER | ||
64 | * |page |------------------v | ||
65 | * +------+ +---+ +---+ +---+ | ||
66 | * ^ | |-->| |-->| | | ||
67 | * | +---+ +---+ +---+ | ||
68 | * | | | ||
69 | * | | | ||
70 | * +------------------------------+ | ||
71 | * | ||
72 | * | ||
73 | * +------+ | ||
74 | * |buffer| RING BUFFER | ||
75 | * |page |------------------v | ||
76 | * +------+ +---+ +---+ +---+ | ||
77 | * ^ | | | |-->| | | ||
78 | * | New +---+ +---+ +---+ | ||
79 | * | Reader------^ | | ||
80 | * | page | | ||
81 | * +------------------------------+ | ||
82 | * | ||
83 | * | ||
84 | * After we make this swap, the reader can hand this page off to the splice | ||
85 | * code and be done with it. It can even allocate a new page if it needs to | ||
86 | * and swap that into the ring buffer. | ||
87 | * | ||
88 | * We will be using cmpxchg soon to make all this lockless. | ||
89 | * | ||
90 | */ | ||
91 | |||
92 | /* | ||
25 | * A fast way to enable or disable all ring buffers is to | 93 | * A fast way to enable or disable all ring buffers is to |
26 | * call tracing_on or tracing_off. Turning off the ring buffers | 94 | * call tracing_on or tracing_off. Turning off the ring buffers |
27 | * prevents all ring buffers from being recorded to. | 95 | * prevents all ring buffers from being recorded to. |