diff options
-rw-r--r-- | kernel/trace/ring_buffer_benchmark.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/kernel/trace/ring_buffer_benchmark.c b/kernel/trace/ring_buffer_benchmark.c index a21aa7b3d05e..7d3aef93c49f 100644 --- a/kernel/trace/ring_buffer_benchmark.c +++ b/kernel/trace/ring_buffer_benchmark.c | |||
@@ -253,7 +253,7 @@ static void ring_buffer_producer(void) | |||
253 | } | 253 | } |
254 | 254 | ||
255 | time = end_tv.tv_sec - start_tv.tv_sec; | 255 | time = end_tv.tv_sec - start_tv.tv_sec; |
256 | time *= 1000000; | 256 | time *= USEC_PER_SEC; |
257 | time += (long long)((long)end_tv.tv_usec - (long)start_tv.tv_usec); | 257 | time += (long long)((long)end_tv.tv_usec - (long)start_tv.tv_usec); |
258 | 258 | ||
259 | entries = ring_buffer_entries(buffer); | 259 | entries = ring_buffer_entries(buffer); |
@@ -273,7 +273,8 @@ static void ring_buffer_producer(void) | |||
273 | pr_info("Missed: %ld\n", missed); | 273 | pr_info("Missed: %ld\n", missed); |
274 | pr_info("Hit: %ld\n", hit); | 274 | pr_info("Hit: %ld\n", hit); |
275 | 275 | ||
276 | do_div(time, 1000); | 276 | /* Convert time from usecs to millisecs */ |
277 | do_div(time, USEC_PER_MSEC); | ||
277 | if (time) | 278 | if (time) |
278 | hit /= (long)time; | 279 | hit /= (long)time; |
279 | else | 280 | else |
@@ -282,18 +283,19 @@ static void ring_buffer_producer(void) | |||
282 | pr_info("Entries per millisec: %ld\n", hit); | 283 | pr_info("Entries per millisec: %ld\n", hit); |
283 | 284 | ||
284 | if (hit) { | 285 | if (hit) { |
285 | avg = 1000000 / hit; | 286 | /* Calculate the average time in nanosecs */ |
287 | avg = NSEC_PER_MSEC / hit; | ||
286 | pr_info("%ld ns per entry\n", avg); | 288 | pr_info("%ld ns per entry\n", avg); |
287 | } | 289 | } |
288 | 290 | ||
289 | |||
290 | if (missed) { | 291 | if (missed) { |
291 | if (time) | 292 | if (time) |
292 | missed /= (long)time; | 293 | missed /= (long)time; |
293 | 294 | ||
294 | pr_info("Total iterations per millisec: %ld\n", hit + missed); | 295 | pr_info("Total iterations per millisec: %ld\n", hit + missed); |
295 | 296 | ||
296 | avg = 1000000 / (hit + missed); | 297 | /* Caculate the average time in nanosecs */ |
298 | avg = NSEC_PER_MSEC / (hit + missed); | ||
297 | pr_info("%ld ns per entry\n", avg); | 299 | pr_info("%ld ns per entry\n", avg); |
298 | } | 300 | } |
299 | } | 301 | } |