All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ross Zwisler <zwisler@google.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-trace-devel@vger.kernel.org,
	Stevie Alvarez <stevie.6strings@gmail.com>
Subject: Re: [PATCH 5/9] libtraceeval histogram: Add type to traceeval_data and make it a structure
Date: Thu, 24 Aug 2023 15:09:34 -0600	[thread overview]
Message-ID: <20230824210934.GF110858@google.com> (raw)
In-Reply-To: <20230817222422.118568-6-rostedt@goodmis.org>

On Thu, Aug 17, 2023 at 06:24:18PM -0400, Steven Rostedt wrote:
> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
> 
> Having a straight union for passing in the data that must match the types
> is dangerous and prone for buggy code. If some data doesn't match its
> type, there's nothing to catch it.
> 
> Instead of having a union traceeval_data of each type, have it be a
> structure with a "type" field follow by a union, where the type defines
> what kind of data it is.
> 
> Add helper macros to make it easy to define the data when using it.
> 
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
>  include/traceeval-hist.h |  88 ++++++++++++++++---------
>  samples/task-eval.c      | 137 ++++++++++++++++-----------------------
>  src/eval-local.h         |   4 +-
>  src/histograms.c         |  68 +++++++++----------
>  4 files changed, 150 insertions(+), 147 deletions(-)
> 
<>
> @@ -802,13 +779,9 @@ static void display_process_stats(struct traceeval *teval,
>  {
>  	struct traceeval_stat *stat;
>  	unsigned long long delta;
> -	union traceeval_data keys[] = {
> -		{
> -			.cstring = comm,
> -		},
> -		{
> -			.number = RUNNING,
> -		}
> +	struct traceeval_data keys[] = {
> +		DEFINE_TRACEEVAL_CSTRING(	comm		),
> +		DEFINE_TRACEEVAL_NUMBER(	RUNNING		),
>  	};
>  
>  	for (int i = 0; i < OTHER; i++) {

Just after this in display_process_stats we have:

> 	for (int i = 0; i < OTHER; i++) {
> 		keys[1].number = i;

Which I think we want to set with the new macro TRACEEVAL_SET_NUMBER().

                TRACEEVAL_SET_NUMBER(keys[1], i)

Other than that you can add:

Reviewed-by: Ross Zwisler <zwisler@google.com>

  reply	other threads:[~2023-08-24 21:10 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-17 22:24 [PATCH 0/9] libtraceeval: Even more updates! Steven Rostedt
2023-08-17 22:24 ` [PATCH 1/9] libtraceeval: Add check for updates to know to recreate iter array Steven Rostedt
2023-08-24 19:41   ` Ross Zwisler
2023-08-17 22:24 ` [PATCH 2/9] libtraceeval: Add traceeval_iterator_query() Steven Rostedt
2023-08-17 22:50   ` Steven Rostedt
2023-08-20 18:18   ` Stevie Alvarez
2023-08-21 14:33     ` Steven Rostedt
2023-08-24 19:57   ` Ross Zwisler
2023-08-17 22:24 ` [PATCH 3/9] libtraceeval: Add traceeval_iterator_stat() Steven Rostedt
2023-08-24 20:07   ` Ross Zwisler
2023-08-17 22:24 ` [PATCH 4/9] libtraceeval: Add traceeval_iterator_remove() Steven Rostedt
2023-08-24 20:19   ` Ross Zwisler
2023-08-24 20:23     ` Ross Zwisler
2023-09-27  9:51       ` Steven Rostedt
2023-09-27  9:09     ` Steven Rostedt
2023-08-17 22:24 ` [PATCH 5/9] libtraceeval histogram: Add type to traceeval_data and make it a structure Steven Rostedt
2023-08-24 21:09   ` Ross Zwisler [this message]
2023-08-17 22:24 ` [PATCH 6/9] libtraceveal: Add type checks to traceeval_data vals and keys Steven Rostedt
2023-08-24 21:23   ` Ross Zwisler
2023-08-17 22:24 ` [PATCH 7/9] libtraceeval: Add size checks to insert and query functions Steven Rostedt
2023-08-17 22:39   ` Steven Rostedt
2023-08-17 22:24 ` [PATCH 8/9] libtraceeval: Add checks to traceeval_insert() and query() Steven Rostedt
2023-08-24 21:36   ` Ross Zwisler
2023-08-17 22:24 ` [PATCH 9/9] libtraceeval: Only do stats on values marked with the STAT flag Steven Rostedt
2023-08-24 22:02   ` 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=20230824210934.GF110858@google.com \
    --to=zwisler@google.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=stevie.6strings@gmail.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.