Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4579331pxv; Tue, 29 Jun 2021 10:13:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaoODbMqFTQJSNbIaoYmJr+6XAtggGbyHNGN6HIoAH/OcUn8hJLVASiLx60HN1dd6sz3nc X-Received: by 2002:a05:6402:2047:: with SMTP id bc7mr42021721edb.247.1624986814553; Tue, 29 Jun 2021 10:13:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624986814; cv=none; d=google.com; s=arc-20160816; b=DEWh6larnFIb7npzss4t0TafNNPFLjfIXKMWgADKwJf+5B0aRj5ax9pof5qDAMGUei RqQThMtx/ityrA/BfZ9eirDXQZaAnug169txeaHse2zUyv+DV4iXmzjHN19bZAe1Z4Pp UVcBez4OJpZ6YA93V80RPoPh6oFzv2XWPhwZbdserQJLe6UyJUI0EDxpdCQ423sL/4mp 9AZ+VcJdeuHRGhdNo8ATfW4hprb4kjl6d4afUB3nCxjO5f1RTaEdmLqyq6TITkakOrEi vbjnls9u1bVHsr6wTL+uDG2tMD4D3IXWzTbrPnPV/+hMeRRufL+ANDlXschuZec1z9lk 7eeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Yh2F59AqAF8H041ekeZo+V4beqXtOxS1tFuRsx8xUgg=; b=GBiLuTFRuk+vLTn8k0N2goWn0UhiWG059y7+DX98hycssjpykDhNVb62jpNGCdZDFX V6yhyJaN1qzHAy3c07jExw7tVtvPf2iaKF6Gm40tC9Uk9duX3oOu1PuzgA9U1E2NfBjD 7yAB9593IF6IB3bY05inF3IOPOH0CFLP0dbSm9jiIDBiRNWLhlzilBHy4kn47H6uhnuN RI3UbDfXE1upWO/wYscIwpTkbqoLinV4l7nRcO0HDWHIxQMO2zP6/FgPSRz2XzOtbdat YRn5KIR6MEE+BJkulGxVLtl9xZ98FJCZmEpJ1eVrp+xR6MQYmd19cNbpGm41YAcA66zB c+oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GMH9TuQz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 3si17911428ejl.361.2021.06.29.10.13.11; Tue, 29 Jun 2021 10:13:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GMH9TuQz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233134AbhF2RNK (ORCPT + 99 others); Tue, 29 Jun 2021 13:13:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58748 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233118AbhF2RNH (ORCPT ); Tue, 29 Jun 2021 13:13:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624986639; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Yh2F59AqAF8H041ekeZo+V4beqXtOxS1tFuRsx8xUgg=; b=GMH9TuQz0Jn7hdyy/8joKhVUHc1Kdch2UYNOa429QCF16mjVnQF0+57q3EAo9cFLX/5tGM wZTCNr51uai7Lgbce4jUigy3ZEF1FrsbYkmCjXOJfEwsqbWNNmAvA+pcNkrKjGbdHAiWB0 aqsM7swp8Lroz4p6BzpddblgRMQbT8U= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-467-h8Im1EvbNau3ldosL29Mdw-1; Tue, 29 Jun 2021 13:10:37 -0400 X-MC-Unique: h8Im1EvbNau3ldosL29Mdw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 36C17101F000; Tue, 29 Jun 2021 17:10:36 +0000 (UTC) Received: from x1.bristot.me.homenet.telecomitalia.it (ovpn-116-83.rdu2.redhat.com [10.10.116.83]) by smtp.corp.redhat.com (Postfix) with ESMTP id D0C5E17C58; Tue, 29 Jun 2021 17:10:30 +0000 (UTC) From: Daniel Bristot de Oliveira To: Steven Rostedt Cc: Daniel Bristot de Oliveira , Ingo Molnar , Dan Carpenter , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] trace/osnoise: Make 'noise' variable s64 in run_osnoise() Date: Tue, 29 Jun 2021 19:10:26 +0200 Message-Id: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Cc: Steven Rostedt Cc: Ingo Molnar Cc: Daniel Bristot de Oliveira Cc: Dan Carpenter Cc: linux-kernel@vger.kernel.org Fixes: bce29ac9ce0b ("trace: Add osnoise tracer") Reported-by: Dan Carpenter Signed-off-by: Daniel Bristot de Oliveira --- 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.31.1