Skip to content

Commit d6cb38e

Browse files
tobluxrostedt
authored andcommitted
tracing: Use div64_u64() instead of do_div()
Fixes Coccinelle/coccicheck warnings reported by do_div.cocci. Compared to do_div(), div64_u64() does not implicitly cast the divisor and does not unnecessarily calculate the remainder. Link: https://lore.kernel.org/linux-trace-kernel/[email protected] Cc: Mathieu Desnoyers <[email protected]> Signed-off-by: Thorsten Blum <[email protected]> Acked-by: Masami Hiramatsu (Google) <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 19f0423 commit d6cb38e

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

kernel/trace/trace_benchmark.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ static void trace_do_benchmark(void)
9292
bm_total += delta;
9393
bm_totalsq += delta * delta;
9494

95-
9695
if (bm_cnt > 1) {
9796
/*
9897
* Apply Welford's method to calculate standard deviation:
@@ -105,7 +104,7 @@ static void trace_do_benchmark(void)
105104
stddev = 0;
106105

107106
delta = bm_total;
108-
do_div(delta, bm_cnt);
107+
delta = div64_u64(delta, bm_cnt);
109108
avg = delta;
110109

111110
if (stddev > 0) {
@@ -127,7 +126,7 @@ static void trace_do_benchmark(void)
127126
seed = stddev;
128127
if (!last_seed)
129128
break;
130-
do_div(seed, last_seed);
129+
seed = div64_u64(seed, last_seed);
131130
seed += last_seed;
132131
do_div(seed, 2);
133132
} while (i++ < 10 && last_seed != seed);

0 commit comments

Comments
 (0)