From patchwork Fri Dec 11 15:07:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 11968505 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3354CC4361B for ; Fri, 11 Dec 2020 15:56:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 43EFC23B31 for ; Fri, 11 Dec 2020 15:56:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392465AbgLKPLb (ORCPT ); Fri, 11 Dec 2020 10:11:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437669AbgLKPJ4 (ORCPT ); Fri, 11 Dec 2020 10:09:56 -0500 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD5CAC0611E4 for ; Fri, 11 Dec 2020 07:08:36 -0800 (PST) Received: by mail-wr1-x443.google.com with SMTP id c5so5737905wrp.6 for ; Fri, 11 Dec 2020 07:08:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dZ0Md1ZVuFNbmAKxQLmv9j8FqeYHXxFKPJzenH94qMY=; b=FuPFAQ+aXcp03Bh9P8W9oT/jQNpB0+wsqcKrl5T82q907OLyllDuzWc4dJ7eilwgdu ZIbTZV225wGwfroXnVNjiJl/JGuIRMbDGySsvkYxyVzXqwwAMn+wkfPUVV5mQKGISouY oVg42w26QwXGrvV1apXp73fVJTNpKSIoPPAa4oIpsDesC9y4vxcw/c3PhUZus6IhmxtT 0GBWX1c3pTMK8OW/acRwwTneMM9wJYpYWutCfWP2i/VgiaDp2366MLqGRRD4s3QcLj1k I2N6p1VgA1Mh6H/DCTssbdWu04v9nZErreQheh0VcdbFkYKNro2Rl2M5fCJIWjqXjj9L JoQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dZ0Md1ZVuFNbmAKxQLmv9j8FqeYHXxFKPJzenH94qMY=; b=meD2SdrDPQMtNfiWC6x76Cvqyvnk59gwFuO51d4ZmKiKUj/rpZDstzzmuDHnEHQfIc hyU/eQ25oopLsVRhRj5xsZoO/41jepFHNmAe7lxHauMAngTkZhzxITYq1WK4JHkZJyxv DcUuhzaiWxYxjsbrVj46KlTs/dOiAIA2fLzavyBTM5oF9Xe4qmfkRuSL+G8KJWmqYqz/ /qrw4R2ZTIYG1h8fLsZ8KLcakyAB8Fv1+JLwbEk/b/vJ9v1hwOoxH+ATg6g86LvBs7zw o2HM/sbt7Gs101BEI4kjSKcSIyUtcMzjwyq3Uyz+bBCjnzpKv+1S5BhrcIN2NAQeYjgx UfdQ== X-Gm-Message-State: AOAM531gfMDB2B7aLsx7qnmM3luWMULnh1tk4AXYQPBPoB8a5YNHaDaL DMHEfZAiGRXFIwVzp0a0Ee7We7nTSm8= X-Google-Smtp-Source: ABdhPJyRCR9hDfoFmR3LMEDyDAnrKDNhcgZ8Y/BxvrsowTmQsxYg/wiaSIEMqk3kVLv/TzPuHZzxUg== X-Received: by 2002:adf:ee4d:: with SMTP id w13mr1802936wro.216.1607699315643; Fri, 11 Dec 2020 07:08:35 -0800 (PST) Received: from localhost.localdomain ([95.87.199.104]) by smtp.gmail.com with ESMTPSA id w17sm15620948wru.82.2020.12.11.07.08.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Dec 2020 07:08:35 -0800 (PST) From: "Yordan Karadzhov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, "Yordan Karadzhov (VMware)" Subject: [PATCH v7 21/32] kernel-shark: Use only signed types for model defs Date: Fri, 11 Dec 2020 17:07:45 +0200 Message-Id: <20201211150756.577366-22-y.karadz@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201211150756.577366-1-y.karadz@gmail.com> References: <20201211150756.577366-1-y.karadz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org All variables that are used to describe the state of the model, like the range of the model or the size of the bin must have signed integer types. This is a continuation of the change started by switching to signed timestamps. Signed-off-by: Yordan Karadzhov (VMware) --- src/libkshark-model.c | 12 ++++++------ src/libkshark-model.h | 18 +++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/libkshark-model.c b/src/libkshark-model.c index 97cff31..f3864bf 100644 --- a/src/libkshark-model.c +++ b/src/libkshark-model.c @@ -91,10 +91,10 @@ static bool ksmodel_histo_alloc(struct kshark_trace_histo *histo, size_t n) } static void ksmodel_set_in_range_bining(struct kshark_trace_histo *histo, - size_t n, uint64_t min, uint64_t max, + size_t n, int64_t min, int64_t max, bool force_in_range) { - uint64_t corrected_range, delta_range, range = max - min; + int64_t corrected_range, delta_range, range = max - min; struct kshark_entry *last; /* The size of the bin must be >= 1, hence the range must be >= n. */ @@ -163,7 +163,7 @@ static void ksmodel_set_in_range_bining(struct kshark_trace_histo *histo, * @param max: Upper edge of the time-window to be visualized. */ void ksmodel_set_bining(struct kshark_trace_histo *histo, - size_t n, uint64_t min, uint64_t max) + size_t n, int64_t min, int64_t max) { ksmodel_set_in_range_bining(histo, n, min, max, false); } @@ -256,7 +256,7 @@ static size_t ksmodel_set_upper_edge(struct kshark_trace_histo *histo) static void ksmodel_set_next_bin_edge(struct kshark_trace_histo *histo, size_t bin, size_t last_row) { - uint64_t time_min, time_max; + int64_t time_min, time_max; size_t next_bin = bin + 1; ssize_t row; @@ -598,9 +598,9 @@ void ksmodel_shift_backward(struct kshark_trace_histo *histo, size_t n) * @param histo: Input location for the model descriptor. * @param ts: position in time to be visualized. */ -void ksmodel_jump_to(struct kshark_trace_histo *histo, uint64_t ts) +void ksmodel_jump_to(struct kshark_trace_histo *histo, int64_t ts) { - uint64_t min, max, range_min; + int64_t min, max, range_min; if (ts > histo->min && ts < histo->max) { /* diff --git a/src/libkshark-model.h b/src/libkshark-model.h index 87e252e..b862480 100644 --- a/src/libkshark-model.h +++ b/src/libkshark-model.h @@ -58,16 +58,16 @@ struct kshark_trace_histo { * Lower edge of the time-window to be visualized. Only entries having * timestamp >= min will be visualized. */ - uint64_t min; + int64_t min; /** * Upper edge of the time-window to be visualized. Only entries having * timestamp <= max will be visualized. */ - uint64_t max; + int64_t max; /** The size in time for each bin. */ - uint64_t bin_size; + int64_t bin_size; /** Number of bins. */ int n_bins; @@ -78,7 +78,7 @@ void ksmodel_init(struct kshark_trace_histo *histo); void ksmodel_clear(struct kshark_trace_histo *histo); void ksmodel_set_bining(struct kshark_trace_histo *histo, - size_t n, uint64_t min, uint64_t max); + size_t n, int64_t min, int64_t max); void ksmodel_fill(struct kshark_trace_histo *histo, struct kshark_entry **data, size_t n); @@ -89,7 +89,7 @@ void ksmodel_shift_forward(struct kshark_trace_histo *histo, size_t n); void ksmodel_shift_backward(struct kshark_trace_histo *histo, size_t n); -void ksmodel_jump_to(struct kshark_trace_histo *histo, uint64_t ts); +void ksmodel_jump_to(struct kshark_trace_histo *histo, int64_t ts); void ksmodel_zoom_out(struct kshark_trace_histo *histo, double r, int mark); @@ -163,16 +163,16 @@ ksmodel_get_task_missed_events(struct kshark_trace_histo *histo, struct kshark_entry_collection *col, ssize_t *index); -static inline double ksmodel_bin_time(struct kshark_trace_histo *histo, +static inline int64_t ksmodel_bin_ts(struct kshark_trace_histo *histo, int bin) { - return (histo->min + bin*histo->bin_size) * 1e-9; + return (histo->min + bin*histo->bin_size); } -static inline uint64_t ksmodel_bin_ts(struct kshark_trace_histo *histo, +static inline double ksmodel_bin_time(struct kshark_trace_histo *histo, int bin) { - return (histo->min + bin*histo->bin_size); + return ksmodel_bin_ts(histo, bin) * 1e-9; } #ifdef __cplusplus