From: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org,
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Subject: [PATCH v5 17/20] kernel-shark: Add ksmodel_get_bin()
Date: Fri, 20 Nov 2020 11:43:01 +0200 [thread overview]
Message-ID: <20201120094304.271502-18-y.karadz@gmail.com> (raw)
In-Reply-To: <20201120094304.271502-1-y.karadz@gmail.com>
The method retrieves the Id of the bin of the model that contains
given entry.
Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
src/libkshark-model.c | 27 +++++++++++++++++++++++++++
src/libkshark-model.h | 3 +++
2 files changed, 30 insertions(+)
diff --git a/src/libkshark-model.c b/src/libkshark-model.c
index f3864bfd..2301b069 100644
--- a/src/libkshark-model.c
+++ b/src/libkshark-model.c
@@ -1325,3 +1325,30 @@ ksmodel_get_task_missed_events(struct kshark_trace_histo *histo,
match_pid_missed_events, sd, &pid,
col, index);
}
+
+/**
+ * @brief Find the bin Id of a give entry.
+ *
+ * @param histo: Input location for the model descriptor.
+ * @param entry: Input location for entry.
+ *
+ * @returns If the timestamp of the entry is inside the range of the model the
+ * function returns the Id of the bin it belongs to.
+ * If the timestamp of the entry is outside of the range of the model
+ * the function returns UPPER_OVERFLOW_BIN or LOWER_OVERFLOW_BIN
+ * (negative values).
+ */
+int ksmodel_get_bin(struct kshark_trace_histo *histo,
+ const struct kshark_entry *entry)
+{
+ if (entry->ts < histo->min)
+ return UPPER_OVERFLOW_BIN;
+
+ if (entry->ts > histo->max)
+ return LOWER_OVERFLOW_BIN;
+
+ if (entry->ts == histo->max)
+ return histo->n_bins - 1;
+
+ return (entry->ts - histo->min) / histo->bin_size;
+}
diff --git a/src/libkshark-model.h b/src/libkshark-model.h
index b8624809..8989ee0e 100644
--- a/src/libkshark-model.h
+++ b/src/libkshark-model.h
@@ -175,6 +175,9 @@ static inline double ksmodel_bin_time(struct kshark_trace_histo *histo,
return ksmodel_bin_ts(histo, bin) * 1e-9;
}
+int ksmodel_get_bin(struct kshark_trace_histo *histo,
+ const struct kshark_entry *entry);
+
#ifdef __cplusplus
}
#endif // __cplusplus
--
2.25.1
next prev parent reply other threads:[~2020-11-20 9:43 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-20 9:42 [PATCH v5 00/20] * Start KernelShark v2 transformation Yordan Karadzhov (VMware)
2020-11-20 9:42 ` [PATCH v5 01/20] kernel-shark: Use only signed types in kshark_entry Yordan Karadzhov (VMware)
2020-11-20 9:42 ` [PATCH v5 02/20] kernel-shark: Add stream_id to kshark_entry Yordan Karadzhov (VMware)
2020-11-20 9:42 ` [PATCH v5 03/20] kernel-shark: Introduce libkshark-hash Yordan Karadzhov (VMware)
2020-11-20 9:42 ` [PATCH v5 04/20] kernel-shark: Introduce Data streams Yordan Karadzhov (VMware)
2020-11-20 9:42 ` [PATCH v5 05/20] kernel-shark: Rename static methods in libkshark Yordan Karadzhov (VMware)
2020-11-20 9:42 ` [PATCH v5 06/20] kernel-shark: Add basic methods for Data streams Yordan Karadzhov (VMware)
2020-11-20 9:42 ` [PATCH v5 07/20] kernel-shark: Housekeeping before implementing stream interface Yordan Karadzhov (VMware)
2020-11-20 9:42 ` [PATCH v5 08/20] kernel-shark: Add stream interface for trace-cmd data Yordan Karadzhov (VMware)
2020-11-20 9:42 ` [PATCH v5 09/20] kernel-shark: Start introducing KernelShark 2.0 Yordan Karadzhov (VMware)
2020-11-20 9:42 ` [PATCH v5 10/20] kernel-shark: Start using data streams Yordan Karadzhov (VMware)
2020-11-20 9:42 ` [PATCH v5 11/20] kernel-shark: Remove dead code Yordan Karadzhov (VMware)
2020-11-20 9:42 ` [PATCH v5 12/20] kernel-shark: Redesign the plugin interface Yordan Karadzhov (VMware)
2020-11-20 9:42 ` [PATCH v5 13/20] kernel-shark: Complete the stream integration Yordan Karadzhov (VMware)
2020-11-20 9:42 ` [PATCH v5 14/20] kernel-shark: Provide merging of multiple data streams Yordan Karadzhov (VMware)
2020-11-20 9:42 ` [PATCH v5 15/20] kernel-shark: Integrate the stream definitions with data model Yordan Karadzhov (VMware)
2020-11-20 9:43 ` [PATCH v5 16/20] kernel-shark: Use only signed types for model defs Yordan Karadzhov (VMware)
2020-11-20 9:43 ` Yordan Karadzhov (VMware) [this message]
2020-11-20 9:43 ` [PATCH v5 18/20] kernel-shark: Protect ksmodel_set_in_range_bining() Yordan Karadzhov (VMware)
2020-11-20 9:43 ` [PATCH v5 19/20] kernel-shark: Add methods for time calibration Yordan Karadzhov (VMware)
2020-11-20 9:43 ` [PATCH v5 20/20] kernel-shark: Integrate streams with libkshark-configio Yordan Karadzhov (VMware)
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=20201120094304.271502-18-y.karadz@gmail.com \
--to=y.karadz@gmail.com \
--cc=linux-trace-devel@vger.kernel.org \
--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).