summaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_benchmark.c
diff options
context:
space:
mode:
authorThorsten Blum <thorsten.blum@toblux.com>2024-02-25 17:45:08 +0100
committerSteven Rostedt (Google) <rostedt@goodmis.org>2024-03-18 15:33:06 +0100
commitd6cb38e10810743addf8cac0b277861d614de1e9 (patch)
tree95bff947f6c4e89a22e9b9beb9b774eb0ae4aa06 /kernel/trace/trace_benchmark.c
parenttracing: Support to dump instance traces by ftrace_dump_on_oops (diff)
downloadlinux-d6cb38e10810743addf8cac0b277861d614de1e9.tar.xz
linux-d6cb38e10810743addf8cac0b277861d614de1e9.zip
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>
Diffstat (limited to '')
-rw-r--r--kernel/trace/trace_benchmark.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/kernel/trace/trace_benchmark.c b/kernel/trace/trace_benchmark.c
index 54d5fa35c90a..811b08439406 100644
--- a/kernel/trace/trace_benchmark.c
+++ b/kernel/trace/trace_benchmark.c
@@ -92,7 +92,6 @@ static void trace_do_benchmark(void)
bm_total += delta;
bm_totalsq += delta * delta;
-
if (bm_cnt > 1) {
/*
* Apply Welford's method to calculate standard deviation:
@@ -105,7 +104,7 @@ static void trace_do_benchmark(void)
stddev = 0;
delta = bm_total;
- do_div(delta, bm_cnt);
+ delta = div64_u64(delta, bm_cnt);
avg = delta;
if (stddev > 0) {
@@ -127,7 +126,7 @@ static void trace_do_benchmark(void)
seed = stddev;
if (!last_seed)
break;
- do_div(seed, last_seed);
+ seed = div64_u64(seed, last_seed);
seed += last_seed;
do_div(seed, 2);
} while (i++ < 10 && last_seed != seed);