diff options
author | Steven Rostedt <srostedt@redhat.com> | 2009-05-07 11:13:42 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2009-05-07 11:16:18 -0400 |
commit | 29c8000ee7da3a6756d26143991e573eaaf2a9f6 (patch) | |
tree | 4c57a374639127ebccd6f4fca0feb02cde21e702 /kernel | |
parent | 0ad5d703c6c0fcd385d956555460df95dff7eb7e (diff) |
ring-buffer: remove complex calculations in ring-buffer-test
Ingo Molnar thought that the code to calculate the time in cond_resched
is a bit too ugly and is not needed. This patch removes it and replaces
it with a simple call to cond_resched. I kept the comment that explains
the reason for the cond_resched.
[ Impact: remove ugly code ]
Reported-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/ring_buffer_benchmark.c | 37 |
1 files changed, 7 insertions, 30 deletions
diff --git a/kernel/trace/ring_buffer_benchmark.c b/kernel/trace/ring_buffer_benchmark.c index a26fc67b63bb..f4ceb453c7dd 100644 --- a/kernel/trace/ring_buffer_benchmark.c +++ b/kernel/trace/ring_buffer_benchmark.c | |||
@@ -185,35 +185,6 @@ 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 | ||
194 | static void sched_if_needed(struct timeval *start_tv, struct timeval *end_tv) | ||
195 | { | ||
196 | } | ||
197 | #else | ||
198 | static 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 | |||
217 | static void ring_buffer_producer(void) | 188 | static void ring_buffer_producer(void) |
218 | { | 189 | { |
219 | struct timeval start_tv; | 190 | struct timeval start_tv; |
@@ -250,7 +221,13 @@ static void ring_buffer_producer(void) | |||
250 | if (consumer && !(++cnt % wakeup_interval)) | 221 | if (consumer && !(++cnt % wakeup_interval)) |
251 | wake_up_process(consumer); | 222 | wake_up_process(consumer); |
252 | 223 | ||
253 | sched_if_needed(&start_tv, &end_tv); | 224 | /* |
225 | * If we are a non preempt kernel, the 10 second run will | ||
226 | * stop everything while it runs. Instead, we will call | ||
227 | * cond_resched and also add any time that was lost by a | ||
228 | * rescedule. | ||
229 | */ | ||
230 | cond_resched(); | ||
254 | 231 | ||
255 | } while (end_tv.tv_sec < (start_tv.tv_sec + RUN_TIME) && !kill_test); | 232 | } while (end_tv.tv_sec < (start_tv.tv_sec + RUN_TIME) && !kill_test); |
256 | pr_info("End ring buffer hammer\n"); | 233 | pr_info("End ring buffer hammer\n"); |