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>,
Li Zefan <lizf@cn.fujitsu.com>, Christoph Hellwig <hch@lst.de>
Subject: [PATCH 4/7] ring-buffer: change test to be more latency friendly
Date: Wed, 06 May 2009 23:13:39 -0400 [thread overview]
Message-ID: <20090507031434.214633851@goodmis.org> (raw)
In-Reply-To: 20090507031335.815354104@goodmis.org
[-- Attachment #1: 0004-ring-buffer-change-test-to-be-more-latency-friendly.patch --]
[-- Type: text/plain, Size: 2522 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
The ring buffer benchmark/test runs a producer for 10 seconds.
This is done with preemption and interrupts enabled. But if the kernel
is not compiled with CONFIG_PREEMPT, it basically stops everything
but interrupts for 10 seconds.
Although this is just a test and is not for production, this attribute
can be quite annoying. It can also spawn badness elsewhere.
This patch solves the issues by calling "cond_resched" when the system
is not compiled with CONFIG_PREEMPT. It also keeps track of the time
spent to call cond_resched such that it does not go against the
time calculations. That is, if the task schedules away, the time scheduled
out is removed from the test data. Note, this only works for non PREEMPT
because we do not know when the task is scheduled out if we have PREEMPT
enabled.
[ Impact: prevent test from stopping the world for 10 seconds ]
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/ring_buffer_benchmark.c | 31 +++++++++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/kernel/trace/ring_buffer_benchmark.c b/kernel/trace/ring_buffer_benchmark.c
index dcd75e9..a26fc67 100644
--- a/kernel/trace/ring_buffer_benchmark.c
+++ b/kernel/trace/ring_buffer_benchmark.c
@@ -185,6 +185,35 @@ static void ring_buffer_consumer(void)
complete(&read_done);
}
+/*
+ * If we are a non preempt kernel, the 10 second run will
+ * stop everything while it runs. Instead, we will call cond_resched
+ * and also add any time that was lost by a rescedule.
+ */
+#ifdef CONFIG_PREEMPT
+static void sched_if_needed(struct timeval *start_tv, struct timeval *end_tv)
+{
+}
+#else
+static void sched_if_needed(struct timeval *start_tv, struct timeval *end_tv)
+{
+ struct timeval tv;
+
+ cond_resched();
+ do_gettimeofday(&tv);
+ if (tv.tv_usec < end_tv->tv_usec) {
+ tv.tv_usec += 1000000;
+ tv.tv_sec--;
+ }
+ start_tv->tv_sec += tv.tv_sec - end_tv->tv_sec;
+ start_tv->tv_usec += tv.tv_usec - end_tv->tv_usec;
+ if (start_tv->tv_usec > 1000000) {
+ start_tv->tv_usec -= 1000000;
+ start_tv->tv_sec++;
+ }
+}
+#endif
+
static void ring_buffer_producer(void)
{
struct timeval start_tv;
@@ -221,6 +250,8 @@ static void ring_buffer_producer(void)
if (consumer && !(++cnt % wakeup_interval))
wake_up_process(consumer);
+ sched_if_needed(&start_tv, &end_tv);
+
} while (end_tv.tv_sec < (start_tv.tv_sec + RUN_TIME) && !kill_test);
pr_info("End ring buffer hammer\n");
--
1.6.2.4
--
next prev parent reply other threads:[~2009-05-07 3:15 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-07 3:13 [PATCH 0/7] [GIT PULL] tracing/ring-buffer: more updates for tip Steven Rostedt
2009-05-07 3:13 ` [PATCH 1/7] ring-buffer: remove unneeded conditional in rb_reserve_next Steven Rostedt
2009-05-07 8:23 ` Ingo Molnar
2009-05-07 3:13 ` [PATCH 2/7] ring-buffer: check for failed allocation in ring buffer benchmark Steven Rostedt
2009-05-07 3:13 ` [PATCH 3/7] ring-buffer: make moving the tail page a separate function Steven Rostedt
2009-05-07 8:27 ` Ingo Molnar
2009-05-07 13:26 ` Steven Rostedt
2009-05-07 13:56 ` Ingo Molnar
2009-05-07 3:13 ` Steven Rostedt [this message]
2009-05-07 8:31 ` [PATCH 4/7] ring-buffer: change test to be more latency friendly Ingo Molnar
2009-05-07 8:34 ` Ingo Molnar
2009-05-07 13:51 ` Steven Rostedt
2009-05-07 3:13 ` [PATCH 5/7] tracing: update sample with TRACE_INCLUDE_FILE Steven Rostedt
2009-05-07 3:13 ` [PATCH 6/7] tracing: reset ring buffer when removing modules with events Steven Rostedt
2009-05-07 3:51 ` Li Zefan
2009-05-07 16:24 ` Frederic Weisbecker
2009-05-07 3:13 ` [PATCH 7/7] tracing: add hierarchical enabling of events Steven Rostedt
2009-05-07 3:51 ` Li Zefan
2009-05-07 13:21 ` Steven Rostedt
2009-05-08 1:11 ` Li Zefan
2009-05-08 1:23 ` Steven Rostedt
2009-05-08 1:24 ` Steven Rostedt
2009-05-07 16:28 ` Frederic Weisbecker
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=20090507031434.214633851@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=lizf@cn.fujitsu.com \
--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