aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/ring_buffer_benchmark.c
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2009-05-06 18:36:59 -0400
committerSteven Rostedt <rostedt@goodmis.org>2009-05-06 18:36:59 -0400
commit3e07a4f680adc66dfa175aa5021aedf340251b12 (patch)
treec245b416cf3d88e4c2f1d0ff43d0021e59b20b47 /kernel/trace/ring_buffer_benchmark.c
parent6634ff26cce2da04e5c2a5481bcb8888e7d01786 (diff)
ring-buffer: change test to be more latency friendly
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>
Diffstat (limited to 'kernel/trace/ring_buffer_benchmark.c')
-rw-r--r--kernel/trace/ring_buffer_benchmark.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/kernel/trace/ring_buffer_benchmark.c b/kernel/trace/ring_buffer_benchmark.c
index dcd75e9e49f4..a26fc67b63bb 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)
185 complete(&read_done); 185 complete(&read_done);
186} 186}
187 187
188/*
189 * If we are a non preempt kernel, the 10 second run will
190 * stop everything while it runs. Instead, we will call cond_resched
191 * and also add any time that was lost by a rescedule.
192 */
193#ifdef CONFIG_PREEMPT
194static void sched_if_needed(struct timeval *start_tv, struct timeval *end_tv)
195{
196}
197#else
198static void sched_if_needed(struct timeval *start_tv, struct timeval *end_tv)
199{
200 struct timeval tv;
201
202 cond_resched();
203 do_gettimeofday(&tv);
204 if (tv.tv_usec < end_tv->tv_usec) {
205 tv.tv_usec += 1000000;
206 tv.tv_sec--;
207 }
208 start_tv->tv_sec += tv.tv_sec - end_tv->tv_sec;
209 start_tv->tv_usec += tv.tv_usec - end_tv->tv_usec;
210 if (start_tv->tv_usec > 1000000) {
211 start_tv->tv_usec -= 1000000;
212 start_tv->tv_sec++;
213 }
214}
215#endif
216
188static void ring_buffer_producer(void) 217static void ring_buffer_producer(void)
189{ 218{
190 struct timeval start_tv; 219 struct timeval start_tv;
@@ -221,6 +250,8 @@ static void ring_buffer_producer(void)
221 if (consumer && !(++cnt % wakeup_interval)) 250 if (consumer && !(++cnt % wakeup_interval))
222 wake_up_process(consumer); 251 wake_up_process(consumer);
223 252
253 sched_if_needed(&start_tv, &end_tv);
254
224 } while (end_tv.tv_sec < (start_tv.tv_sec + RUN_TIME) && !kill_test); 255 } while (end_tv.tv_sec < (start_tv.tv_sec + RUN_TIME) && !kill_test);
225 pr_info("End ring buffer hammer\n"); 256 pr_info("End ring buffer hammer\n");
226 257