[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210630231822.219090027@goodmis.org>
Date: Wed, 30 Jun 2021 19:18:00 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: linux-kernel@...r.kernel.org
Cc: Ingo Molnar <mingo@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Ingo Molnar <mingo@...hat.com>,
Daniel Bristot de Oliveira <bristot@...hat.com>,
Dan Carpenter <dan.carpenter@...cle.com>
Subject: [for-next][PATCH 2/5] trace/osnoise: Make noise variable s64 in run_osnoise()
From: Daniel Bristot de Oliveira <bristot@...hat.com>
Dab Carpenter reported that:
The patch bce29ac9ce0b: "trace: Add osnoise tracer" from Jun 22,
2021, leads to the following static checker warning:
kernel/trace/trace_osnoise.c:1103 run_osnoise()
warn: unsigned 'noise' is never less than zero.
In this part of the code:
1100 /*
1101 * This shouldn't happen.
1102 */
1103 if (noise < 0) {
^^^^^^^^^
1104 osnoise_taint("negative noise!");
1105 goto out;
1106 }
1107
And the static checker is right because 'noise' is u64.
Make noise s64 and keep the check. It is important to check if
the time read is behaving correctly - so we can trust the results.
I also re-arranged some variable declarations.
Link: https://lkml.kernel.org/r/acd7cd6e7d56b798a298c3bc8139a390b3c4ab52.1624986368.git.bristot@redhat.com
Cc: Ingo Molnar <mingo@...hat.com>
Cc: Daniel Bristot de Oliveira <bristot@...hat.com>
Cc: Dan Carpenter <dan.carpenter@...cle.com>
Cc: linux-kernel@...r.kernel.org
Fixes: bce29ac9ce0b ("trace: Add osnoise tracer")
Reported-by: Dan Carpenter <dan.carpenter@...cle.com>
Signed-off-by: Daniel Bristot de Oliveira <bristot@...hat.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@...dmis.org>
---
kernel/trace/trace_osnoise.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
index 085a83de98ad..cc1faca1a620 100644
--- a/kernel/trace/trace_osnoise.c
+++ b/kernel/trace/trace_osnoise.c
@@ -1042,15 +1042,16 @@ static void osnoise_stop_tracing(void)
static int run_osnoise(void)
{
struct osnoise_variables *osn_var = this_cpu_osn_var();
- u64 noise = 0, sum_noise = 0, max_noise = 0;
struct trace_array *tr = osnoise_trace;
u64 start, sample, last_sample;
u64 last_int_count, int_count;
+ s64 noise = 0, max_noise = 0;
s64 total, last_total = 0;
struct osnoise_sample s;
unsigned int threshold;
- int hw_count = 0;
u64 runtime, stop_in;
+ u64 sum_noise = 0;
+ int hw_count = 0;
int ret = -1;
/*
--
2.30.2
Powered by blists - more mailing lists