From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>
Subject: [PATCH 3/5] ring-buffer: Remove condition to add timestamp in fast path
Date: Tue, 19 Oct 2010 13:54:35 -0400 [thread overview]
Message-ID: <20101019194204.098928016@goodmis.org> (raw)
In-Reply-To: 20101019175432.854431527@goodmis.org
[-- Attachment #1: 0003-ring-buffer-Remove-condition-to-add-timestamp-in-fas.patch --]
[-- Type: text/plain, Size: 2446 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
There's a condition to check if we should add a time extend or
not in the fast path. But this condition is racey (in the sense
that we can add a unnecessary time extend, but nothing that
can break anything). We later check if the time or event time
delta should be zero or have real data in it (not racey), making
this first check redundant.
This check may help save space once in a while, but really is
not worth the hassle to try to save some space that happens at
most 134 ms at a time.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/ring_buffer.c | 28 ++++++----------------------
1 files changed, 6 insertions(+), 22 deletions(-)
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 4fc1577..9f55330 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -2126,6 +2126,7 @@ rb_reserve_next_event(struct ring_buffer *buffer,
u64 ts, delta;
int nr_loops = 0;
int add_timestamp;
+ u64 diff;
rb_start_commit(cpu_buffer);
@@ -2162,29 +2163,13 @@ rb_reserve_next_event(struct ring_buffer *buffer,
goto out_fail;
ts = rb_time_stamp(cpu_buffer->buffer);
+ diff = ts - cpu_buffer->write_stamp;
- /*
- * Only the first commit can update the timestamp.
- * Yes there is a race here. If an interrupt comes in
- * just after the conditional and it traces too, then it
- * will also check the deltas. More than one timestamp may
- * also be made. But only the entry that did the actual
- * commit will be something other than zero.
- */
- if (likely(cpu_buffer->tail_page == cpu_buffer->commit_page &&
- rb_page_write(cpu_buffer->tail_page) ==
- rb_commit_index(cpu_buffer))) {
- u64 diff;
-
- diff = ts - cpu_buffer->write_stamp;
-
- /* make sure this diff is calculated here */
- barrier();
-
- /* Did the write stamp get updated already? */
- if (unlikely(ts < cpu_buffer->write_stamp))
- goto get_event;
+ /* make sure this diff is calculated here */
+ barrier();
+ /* Did the write stamp get updated already? */
+ if (likely(ts >= cpu_buffer->write_stamp)) {
delta = diff;
if (unlikely(test_time_stamp(delta))) {
WARN_ONCE(delta > (1ULL << 59),
@@ -2196,7 +2181,6 @@ rb_reserve_next_event(struct ring_buffer *buffer,
}
}
- get_event:
event = __rb_reserve_next(cpu_buffer, length, ts,
delta, add_timestamp);
if (unlikely(PTR_ERR(event) == -EAGAIN))
--
1.7.1
next prev parent reply other threads:[~2010-10-19 19:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-19 17:54 [PATCH 0/5] [GIT PULL] ring-buffer: Various optimizations Steven Rostedt
2010-10-19 17:54 ` [PATCH 1/5] ring-buffer: Make write slow path out of line Steven Rostedt
2010-10-19 17:54 ` [PATCH 2/5] ring-buffer: Bind time extend and data events together Steven Rostedt
2010-10-19 20:46 ` Thomas Gleixner
2010-10-20 13:06 ` Steven Rostedt
2010-10-19 17:54 ` Steven Rostedt [this message]
2010-10-19 17:54 ` [PATCH 4/5] ring-buffer: Micro-optimize with some strategic inlining Steven Rostedt
2010-10-19 17:54 ` [PATCH 5/5] ring-buffer: Remove unused macro RB_TIMESTAMPS_PER_PAGE Steven Rostedt
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=20101019194204.098928016@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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