Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 146103
b: refs/heads/master
c: 3e07a4f
h: refs/heads/master
i:
  146101: 392cbef
  146099: 44e7519
  146095: 02f2088
v: v3
  • Loading branch information
Steven Rostedt authored and Steven Rostedt committed May 6, 2009
1 parent 7600c7f commit b28e5c7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6634ff26cce2da04e5c2a5481bcb8888e7d01786
refs/heads/master: 3e07a4f680adc66dfa175aa5021aedf340251b12
31 changes: 31 additions & 0 deletions trunk/kernel/trace/ring_buffer_benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");

Expand Down

0 comments on commit b28e5c7

Please sign in to comment.