Skip to content

Commit 347bd7f

Browse files
tobluxrostedt
authored andcommitted
tracing: Improve benchmark test performance by using do_div()
Partially revert commit d6cb38e ("tracing: Use div64_u64() instead of do_div()") and use do_div() again to utilize its faster 64-by-32 division compared to the 64-by-64 division done by div64_u64(). Explicitly cast the divisor bm_cnt to u32 to prevent a Coccinelle warning reported by do_div.cocci. The warning was removed with commit d6cb38e ("tracing: Use div64_u64() instead of do_div()"). Using the faster 64-by-32 division and casting bm_cnt to u32 is safe because we return early from trace_do_benchmark() if bm_cnt > UINT_MAX. This approach is already used twice in trace_do_benchmark() when calculating the standard deviation: do_div(stddev, (u32)bm_cnt); do_div(stddev, (u32)bm_cnt - 1); Link: https://lore.kernel.org/linux-trace-kernel/20240329160229.4874-2-thorsten.blum@toblux.com Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 33f1371 commit 347bd7f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/trace/trace_benchmark.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ static void trace_do_benchmark(void)
104104
stddev = 0;
105105

106106
delta = bm_total;
107-
delta = div64_u64(delta, bm_cnt);
107+
do_div(delta, (u32)bm_cnt);
108108
avg = delta;
109109

110110
if (stddev > 0) {

0 commit comments

Comments
 (0)