diff mbox series

[9/9] libtraceeval: Only do stats on values marked with the STAT flag

Message ID 20230817222422.118568-10-rostedt@goodmis.org (mailing list archive)
State Superseded
Headers show
Series libtraceeval: Even more updates! | expand

Commit Message

Steven Rostedt Aug. 17, 2023, 10:24 p.m. UTC
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         | 2 +-
 3 files changed, 3 insertions(+), 1 deletion(-)

Comments

Ross Zwisler Aug. 24, 2023, 10:02 p.m. UTC | #1
On Thu, Aug 17, 2023 at 06:24:22PM -0400, Steven Rostedt wrote:
> 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         | 2 +-
>  3 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/include/traceeval-hist.h b/include/traceeval-hist.h
> index 81fe805e691d..34f01a51a334 100644
> --- a/include/traceeval-hist.h
> +++ b/include/traceeval-hist.h
> @@ -36,6 +36,7 @@ enum traceeval_flags {
>  	TRACEEVAL_FL_VALUE		= (1 << 1),
>  	TRACEEVAL_FL_SIGNED		= (1 << 2),
>  	TRACEEVAL_FL_TIMESTAMP		= (1 << 3),
> +	TRACEEVAL_FL_STAT		= (1 << 3),

	TRACEEVAL_FL_STAT		= (1 << 4),

>  };
>  
>  /*
> diff --git a/samples/task-eval.c b/samples/task-eval.c
> index ed3a1a95f097..0e3acb7644ef 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 973bf3ad279c..8f1cf4187713 100644
> --- a/src/histograms.c
> +++ b/src/histograms.c
> @@ -571,7 +571,7 @@ static int copy_traceeval_data(struct traceeval_type *type,
>  		return 0;
>  	}
>  
> -	if (!stat)
> +	if (!stat || !(type->flags & TRACEEVAL_FL_STAT))

I think we actually want to check the TRACEEVAL_FL_STAT flag in is_stat_type()
and then use that check here.  This will help cover other cases where the type
means we can keep stats (values which are numbers) but we can bail if the flag
isn't set.

This will cover traceeval_stat() and traceeval_iterator_stat().

>  		return 0;
>  
>  	if (!stat->count++) {
> -- 
> 2.40.1
>
diff mbox series

Patch

diff --git a/include/traceeval-hist.h b/include/traceeval-hist.h
index 81fe805e691d..34f01a51a334 100644
--- a/include/traceeval-hist.h
+++ b/include/traceeval-hist.h
@@ -36,6 +36,7 @@  enum traceeval_flags {
 	TRACEEVAL_FL_VALUE		= (1 << 1),
 	TRACEEVAL_FL_SIGNED		= (1 << 2),
 	TRACEEVAL_FL_TIMESTAMP		= (1 << 3),
+	TRACEEVAL_FL_STAT		= (1 << 3),
 };
 
 /*
diff --git a/samples/task-eval.c b/samples/task-eval.c
index ed3a1a95f097..0e3acb7644ef 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 973bf3ad279c..8f1cf4187713 100644
--- a/src/histograms.c
+++ b/src/histograms.c
@@ -571,7 +571,7 @@  static int copy_traceeval_data(struct traceeval_type *type,
 		return 0;
 	}
 
-	if (!stat)
+	if (!stat || !(type->flags & TRACEEVAL_FL_STAT))
 		return 0;
 
 	if (!stat->count++) {