From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>,
Peter Zijlstra <peterz@infradead.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Lai Jiangshan <laijs@cn.fujitsu.com>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
Steven Rostedt <srostedt@redhat.com>
Subject: [PATCH 16/16] ring-buffer: document reader page design
Date: Thu, 12 Mar 2009 22:37:20 -0400 [thread overview]
Message-ID: <20090313023828.288926973@goodmis.org> (raw)
In-Reply-To: 20090313023704.971438367@goodmis.org
[-- Attachment #1: 0016-ring-buffer-document-reader-page-design.patch --]
[-- Type: text/plain, Size: 3235 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
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>
---
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 2c36be9..58128ad 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -22,6 +22,74 @@
#include "trace.h"
/*
+ * The ring buffer is made up of a list of pages. A separate list of pages is
+ * allocated for each CPU. A writer may only write to a buffer that is
+ * associated with the CPU it is currently executing on. A reader may read
+ * from any per cpu buffer.
+ *
+ * The reader is special. For each per cpu buffer, the reader has its own
+ * reader page. When a reader has read the entire reader page, this reader
+ * page is swapped with another page in the ring buffer.
+ *
+ * Now, as long as the writer is off the reader page, the reader can do what
+ * ever it wants with that page. The writer will never write to that page
+ * again (as long as it is out of the ring buffer).
+ *
+ * Here's some silly ASCII art.
+ *
+ * +------+
+ * |reader| RING BUFFER
+ * |page |
+ * +------+ +---+ +---+ +---+
+ * | |-->| |-->| |
+ * +---+ +---+ +---+
+ * ^ |
+ * | |
+ * +---------------+
+ *
+ *
+ * +------+
+ * |reader| RING BUFFER
+ * |page |------------------v
+ * +------+ +---+ +---+ +---+
+ * | |-->| |-->| |
+ * +---+ +---+ +---+
+ * ^ |
+ * | |
+ * +---------------+
+ *
+ *
+ * +------+
+ * |reader| RING BUFFER
+ * |page |------------------v
+ * +------+ +---+ +---+ +---+
+ * ^ | |-->| |-->| |
+ * | +---+ +---+ +---+
+ * | |
+ * | |
+ * +------------------------------+
+ *
+ *
+ * +------+
+ * |buffer| RING BUFFER
+ * |page |------------------v
+ * +------+ +---+ +---+ +---+
+ * ^ | | | |-->| |
+ * | New +---+ +---+ +---+
+ * | Reader------^ |
+ * | page |
+ * +------------------------------+
+ *
+ *
+ * After we make this swap, the reader can hand this page off to the splice
+ * code and be done with it. It can even allocate a new page if it needs to
+ * and swap that into the ring buffer.
+ *
+ * We will be using cmpxchg soon to make all this lockless.
+ *
+ */
+
+/*
* A fast way to enable or disable all ring buffers is to
* call tracing_on or tracing_off. Turning off the ring buffers
* prevents all ring buffers from being recorded to.
--
1.6.1.3
--
next prev parent reply other threads:[~2009-03-13 2:44 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-13 2:37 [PATCH 00/16] [GIT PULL] updates for tip/tracing/ftrace Steven Rostedt
2009-03-13 2:37 ` [PATCH 01/16] tracing: fix comments about trace buffer resizing Steven Rostedt
2009-03-13 2:37 ` [PATCH 02/16] tracing: protect ring_buffer_expanded with trace_types_lock Steven Rostedt
2009-03-13 2:37 ` [PATCH 03/16] ring-buffer: use CONFIG_HOTPLUG_CPU not CONFIG_HOTPLUG Steven Rostedt
2009-03-13 2:37 ` [PATCH 04/16] ring-buffer: remove unneeded get_online_cpus Steven Rostedt
2009-03-13 2:37 ` [PATCH 05/16] tracing: show that buffer size is not expanded Steven Rostedt
2009-03-13 3:05 ` KOSAKI Motohiro
2009-03-13 3:20 ` Steven Rostedt
2009-03-13 3:28 ` KOSAKI Motohiro
2009-03-13 2:37 ` [PATCH 06/16] tracing/core: bring back raw trace_printk for dynamic formats strings Steven Rostedt
2009-03-13 2:37 ` [PATCH 07/16] tracing: make bprint event use the proper event id Steven Rostedt
2009-03-13 2:37 ` [PATCH 08/16] tracing: have event_trace_printk use static tracer Steven Rostedt
2009-03-13 2:49 ` Andrew Morton
2009-03-13 3:08 ` Steven Rostedt
2009-03-13 3:09 ` KOSAKI Motohiro
2009-03-13 3:17 ` Steven Rostedt
2009-03-13 3:28 ` KOSAKI Motohiro
2009-03-13 3:34 ` Steven Rostedt
2009-03-13 5:36 ` [tip:tracing/ftrace] tracing: add comment for use of double __builtin_consant_p Steven Rostedt
2009-03-13 2:37 ` [PATCH 09/16] tracing: export trace formats to user space Steven Rostedt
2009-03-13 15:03 ` Frederic Weisbecker
2009-03-13 2:37 ` [PATCH 10/16] tracing: fix stack tracer header Steven Rostedt
2009-03-13 2:37 ` [PATCH 11/16] tracing: explain why stack tracer is empty Steven Rostedt
2009-03-13 2:37 ` [PATCH 12/16] tracing: tracepoints for softirq entry/exit - add softirq-to-name array Steven Rostedt
2009-03-13 4:12 ` Andrew Morton
2009-03-13 4:22 ` Steven Rostedt
2009-03-13 2:37 ` [PATCH 13/16] tracing: tracepoints for softirq entry/exit - tracepoints Steven Rostedt
2009-03-13 2:37 ` [PATCH 14/16] tracing: Dont use tracing_record_cmdline() in workqueue tracer fix Steven Rostedt
2009-03-13 2:37 ` [PATCH 15/16] tracing: show event name in trace for TRACE_EVENT created events Steven Rostedt
2009-03-13 2:37 ` Steven Rostedt [this message]
2009-03-13 3:35 ` [PATCH 00/16] [GIT PULL] updates for tip/tracing/ftrace Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090313023828.288926973@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=srostedt@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox