Skip to content

Commit

Permalink
ring-buffer: only periodically call cond_resched to ring-buffer-bench…
Browse files Browse the repository at this point in the history
…mark

Calling cond_resched at every iteration of the loop adds a bit of
overhead to the benchmark.

This patch does two things.

1) only calls cond-resched when CONFIG_PREEMPT is not enabled
2) only calls cond-resched after so many traces has been performed.

[ Impact: less overhead to the ring-buffer-benchmark ]

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
  • Loading branch information
Steven Rostedt authored and Steven Rostedt committed May 7, 2009
1 parent 65b7724 commit 0574ea4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions kernel/trace/ring_buffer_benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,23 @@ static void ring_buffer_producer(void)
}
do_gettimeofday(&end_tv);

if (consumer && !(++cnt % wakeup_interval))
cnt++;
if (consumer && !(cnt % wakeup_interval))
wake_up_process(consumer);

#ifndef CONFIG_PREEMPT
/*
* 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.
*
* Do a cond resched at the same frequency we would wake up
* the reader.
*/
cond_resched();
if (cnt % wakeup_interval)
cond_resched();
#endif

} while (end_tv.tv_sec < (start_tv.tv_sec + RUN_TIME) && !kill_test);
pr_info("End ring buffer hammer\n");
Expand Down

0 comments on commit 0574ea4

Please sign in to comment.