Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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/20240225164507.232942-2-thorsten.blum@toblux.com

Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

authored by

Thorsten Blum and committed by
Steven Rostedt (Google)
d6cb38e1 19f0423f

+2 -3
+2 -3
kernel/trace/trace_benchmark.c
··· 92 92 bm_total += delta; 93 93 bm_totalsq += delta * delta; 94 94 95 - 96 95 if (bm_cnt > 1) { 97 96 /* 98 97 * Apply Welford's method to calculate standard deviation: ··· 104 105 stddev = 0; 105 106 106 107 delta = bm_total; 107 - do_div(delta, bm_cnt); 108 + delta = div64_u64(delta, bm_cnt); 108 109 avg = delta; 109 110 110 111 if (stddev > 0) { ··· 126 127 seed = stddev; 127 128 if (!last_seed) 128 129 break; 129 - do_div(seed, last_seed); 130 + seed = div64_u64(seed, last_seed); 130 131 seed += last_seed; 131 132 do_div(seed, 2); 132 133 } while (i++ < 10 && last_seed != seed);