From: Colin Ian King <colin.king@canonical.com>
To: Daniel Bristot de Oliveira <bristot@redhat.com>,
Steven Rostedt <rostedt@goodmis.org>
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
Dan Carpenter <dan.carpenter@oracle.com>,
Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH][next] trace: osnoise: Fix u64 less than zero comparison
Date: Tue, 29 Jun 2021 18:21:32 +0100 [thread overview]
Message-ID: <e36f61af-4fbe-42cf-f26d-229f940e8fc9@canonical.com> (raw)
In-Reply-To: <c74e711e-71c9-df9c-8406-b9e92ef12da0@redhat.com>
On 29/06/2021 18:19, Daniel Bristot de Oliveira wrote:
> On 6/29/21 6:52 PM, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> The less than zero comparison of the u64 variable 'noise' is always
>> false because the variable is unsigned. Since the time_sub macro
>> can potentially return an -ve vale, make the variable a s64 to
>> fix the issue.
>
> Ops! concurrent bug fixing.
Well, shows static analysis is doing it's thing and I'm not being
vigilant enough by spotting that Dan found it earlier :-)
>
> Dan Carpenter reported the same bug (and another problem), and I was working in
> the patches... I saw yours after sending his ones:
>
> https://lore.kernel.org/lkml/acd7cd6e7d56b798a298c3bc8139a390b3c4ab52.1624986368.git.bristot@redhat.com/
>
> The patches do the same fix, but there it also:
>
> - Made also max_noise s64 (it is snapshot of noise).
> - Arranged the declarations in the inverted christmas tree.
>
>> Addresses-Coverity: ("Unsigned compared against 0")
>> Fixes: bce29ac9ce0b ("trace: Add osnoise tracer")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>
> Steven, can we merge the flags?
>
> -- Daniel
>
>> ---
>> kernel/trace/trace_osnoise.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
>> index 38aa5e208ffd..02c984560ceb 100644
>> --- a/kernel/trace/trace_osnoise.c
>> +++ b/kernel/trace/trace_osnoise.c
>> @@ -1040,11 +1040,11 @@ 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;
>> + u64 sum_noise = 0, max_noise = 0;
>> struct trace_array *tr = osnoise_trace;
>> u64 start, sample, last_sample;
>> u64 last_int_count, int_count;
>> - s64 total, last_total = 0;
>> + s64 noise = 0, total, last_total = 0;
>> struct osnoise_sample s;
>> unsigned int threshold;
>> int hw_count = 0;
>>
>
next prev parent reply other threads:[~2021-06-29 17:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-29 16:52 [PATCH][next] trace: osnoise: Fix u64 less than zero comparison Colin King
2021-06-29 17:19 ` Daniel Bristot de Oliveira
2021-06-29 17:21 ` Colin Ian King [this message]
2021-06-29 18:55 ` Dan Carpenter
2021-06-30 13:05 ` Steven Rostedt
2021-06-30 13:32 ` Daniel Bristot de Oliveira
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e36f61af-4fbe-42cf-f26d-229f940e8fc9@canonical.com \
--to=colin.king@canonical.com \
--cc=bristot@redhat.com \
--cc=dan.carpenter@oracle.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).