All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-trace-devel@vger.kernel.org
Cc: Ross Zwisler <zwisler@google.com>,
	Stevie Alvarez <stevie.6strings@gmail.com>,
	"Steven Rostedt (Google)" <rostedt@goodmis.org>
Subject: [PATCH v2 11/11] libtraceeval: Only do stats on values marked with the STAT flag
Date: Wed, 27 Sep 2023 08:33:14 -0400	[thread overview]
Message-ID: <20230927123314.989589-12-rostedt@goodmis.org> (raw)
In-Reply-To: <20230927123314.989589-1-rostedt@goodmis.org>

From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

Add TRACEEVAL_FL_STAT to perform stats on the value, otherwise ignore it.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 include/traceeval-hist.h |  1 +
 samples/task-eval.c      |  1 +
 src/histograms.c         | 39 ++++++++++++++++++++-------------------
 3 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/include/traceeval-hist.h b/include/traceeval-hist.h
index a1b498108fb4..618e67593dc0 100644
--- a/include/traceeval-hist.h
+++ b/include/traceeval-hist.h
@@ -38,6 +38,7 @@ enum traceeval_flags {
 	TRACEEVAL_FL_VALUE		= (1 << 1),
 	TRACEEVAL_FL_SIGNED		= (1 << 2),
 	TRACEEVAL_FL_TIMESTAMP		= (1 << 3),
+	TRACEEVAL_FL_STAT		= (1 << 4),
 };
 
 /*
diff --git a/samples/task-eval.c b/samples/task-eval.c
index 475df190acd2..6b01b8d076f2 100644
--- a/samples/task-eval.c
+++ b/samples/task-eval.c
@@ -147,6 +147,7 @@ static struct traceeval_type delta_vals[] = {
 	{
 		.type	= TRACEEVAL_TYPE_NUMBER_64,
 		.name	= "delta",
+		.flags = TRACEEVAL_FL_STAT,
 	},
 	{
 		.type	= TRACEEVAL_TYPE_NONE,
diff --git a/src/histograms.c b/src/histograms.c
index 4d534d127cff..0a3ab84d288e 100644
--- a/src/histograms.c
+++ b/src/histograms.c
@@ -505,6 +505,25 @@ static int get_entry(struct traceeval *teval, const struct traceeval_data *keys,
 	return check;
 }
 
+static bool is_stat_type(struct traceeval_type *type)
+{
+	/* Only value numbers have stats */
+	if (!(type->flags & TRACEEVAL_FL_VALUE) ||
+	    !(type->flags & TRACEEVAL_FL_STAT))
+		return false;
+
+	switch (type->type) {
+	case TRACEEVAL_TYPE_NUMBER:
+	case TRACEEVAL_TYPE_NUMBER_64:
+	case TRACEEVAL_TYPE_NUMBER_32:
+	case TRACEEVAL_TYPE_NUMBER_16:
+	case TRACEEVAL_TYPE_NUMBER_8:
+		return true;
+	default:
+		return false;
+	}
+}
+
 /*
  * Copy @src to @dst with respect to @type.
  *
@@ -571,7 +590,7 @@ static int copy_traceeval_data(struct traceeval_type *type,
 		return 0;
 	}
 
-	if (!stat)
+	if (!stat || !is_stat_type(type))
 		return 0;
 
 	if (!stat->count++) {
@@ -826,24 +845,6 @@ static int update_entry(struct traceeval *teval, struct entry *entry,
 	return -1;
 }
 
-static bool is_stat_type(struct traceeval_type *type)
-{
-	/* Only value numbers have stats */
-	if (!(type->flags & TRACEEVAL_FL_VALUE))
-		return false;
-
-	switch (type->type) {
-	case TRACEEVAL_TYPE_NUMBER:
-	case TRACEEVAL_TYPE_NUMBER_64:
-	case TRACEEVAL_TYPE_NUMBER_32:
-	case TRACEEVAL_TYPE_NUMBER_16:
-	case TRACEEVAL_TYPE_NUMBER_8:
-		return true;
-	default:
-		return false;
-	}
-}
-
 struct traceeval_stat *traceeval_stat_size(struct traceeval *teval,
 					   const struct traceeval_data *keys,
 					   size_t nr_keys,
-- 
2.40.1


  parent reply	other threads:[~2023-09-27 12:32 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-27 12:33 [PATCH v2 00/11] libtraceeval: Even more updates! Steven Rostedt
2023-09-27 12:33 ` [PATCH v2 01/11] libtraceeval: Add check for updates to know to recreate iter array Steven Rostedt
2023-09-27 12:33 ` [PATCH v2 02/11] libtraceeval: Add traceeval_iterator_query() Steven Rostedt
2023-09-27 12:33 ` [PATCH v2 03/11] libtraceeval: Add traceeval_iterator_results_release() Steven Rostedt
2023-10-02 19:23   ` Ross Zwisler
2023-09-27 12:33 ` [PATCH v2 04/11] libtraceeval: Add traceeval_iterator_stat() Steven Rostedt
2023-09-27 12:33 ` [PATCH v2 05/11] libtraceeval: Add traceeval_iterator_remove() Steven Rostedt
2023-10-02 19:45   ` Ross Zwisler
2023-09-27 12:33 ` [PATCH v2 06/11] libtraceeval histogram: Add type to traceeval_data and make it a structure Steven Rostedt
2023-10-02 19:53   ` Ross Zwisler
2023-10-02 19:54     ` Ross Zwisler
2023-10-03 13:22       ` Steven Rostedt
2023-10-02 20:16     ` Steven Rostedt
2023-09-27 12:33 ` [PATCH v2 07/11] libtraceveal: Add type checks to traceeval_data vals and keys Steven Rostedt
2023-10-02 19:59   ` Ross Zwisler
2023-09-27 12:33 ` [PATCH v2 08/11] libtraceeval: Add size checks to insert and query functions Steven Rostedt
2023-09-27 12:33 ` [PATCH v2 09/11] libtraceeval: Make traceeval_remove() check size of keys array Steven Rostedt
2023-10-02 20:03   ` Ross Zwisler
2023-09-27 12:33 ` [PATCH v2 10/11] libtraceeval: Make traceeval_stat() " Steven Rostedt
2023-10-02 20:07   ` Ross Zwisler
2023-09-27 12:33 ` Steven Rostedt [this message]
2023-10-02 20:15   ` [PATCH v2 11/11] libtraceeval: Only do stats on values marked with the STAT flag Ross Zwisler

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=20230927123314.989589-12-rostedt@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=stevie.6strings@gmail.com \
    --cc=zwisler@google.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.