diff mbox series

[ndctl,v13,3/8] util/trace: pass an event_ctx to its own parse_event method

Message ID da9be6ff7edcaef18470cc1579343fc08bc1dc1e.1720241079.git.alison.schofield@intel.com (mailing list archive)
State Accepted
Commit eff9f1f287a3d747232f7a9254386abb3526416b
Headers show
Series Support poison list retrieval | expand

Commit Message

Alison Schofield July 6, 2024, 6:24 a.m. UTC
From: Alison Schofield <alison.schofield@intel.com>

Tidy-up the calling convention used in trace event parsing by
passing the entire event_ctx to its parse_event method. This
makes it explicit that a parse_event operates on an event_ctx
object and it allows the parse_event function to access any
members of the event_ctx structure.

This is in preparation for adding a private parser requiring more
context for cxl_poison events.

Signed-off-by: Alison Schofield <alison.schofield@intel.com>
---
 util/event_trace.c | 9 ++++-----
 util/event_trace.h | 2 +-
 2 files changed, 5 insertions(+), 6 deletions(-)

Comments

Dave Jiang July 24, 2024, 8:55 p.m. UTC | #1
On 7/5/24 11:24 PM, alison.schofield@intel.com wrote:
> From: Alison Schofield <alison.schofield@intel.com>
> 
> Tidy-up the calling convention used in trace event parsing by
> passing the entire event_ctx to its parse_event method. This
> makes it explicit that a parse_event operates on an event_ctx
> object and it allows the parse_event function to access any
> members of the event_ctx structure.
> 
> This is in preparation for adding a private parser requiring more
> context for cxl_poison events.
> 
> Signed-off-by: Alison Schofield <alison.schofield@intel.com>

Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
>  util/event_trace.c | 9 ++++-----
>  util/event_trace.h | 2 +-
>  2 files changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/util/event_trace.c b/util/event_trace.c
> index 57318e2adace..1f5c180a030b 100644
> --- a/util/event_trace.c
> +++ b/util/event_trace.c
> @@ -60,7 +60,7 @@ static struct json_object *num_to_json(void *num, int elem_size, unsigned long f
>  }
>  
>  static int event_to_json(struct tep_event *event, struct tep_record *record,
> -			 struct list_head *jlist_head)
> +			 struct event_ctx *ctx)
>  {
>  	struct json_object *jevent, *jobj, *jarray;
>  	struct tep_format_field **fields;
> @@ -190,7 +190,7 @@ static int event_to_json(struct tep_event *event, struct tep_record *record,
>  		}
>  	}
>  
> -	list_add_tail(jlist_head, &jnode->list);
> +	list_add_tail(&ctx->jlist_head, &jnode->list);
>  	return 0;
>  
>  err_jevent:
> @@ -220,10 +220,9 @@ static int event_parse(struct tep_event *event, struct tep_record *record,
>  	}
>  
>  	if (event_ctx->parse_event)
> -		return event_ctx->parse_event(event, record,
> -					      &event_ctx->jlist_head);
> +		return event_ctx->parse_event(event, record, event_ctx);
>  
> -	return event_to_json(event, record, &event_ctx->jlist_head);
> +	return event_to_json(event, record, event_ctx);
>  }
>  
>  int trace_event_parse(struct tracefs_instance *inst, struct event_ctx *ectx)
> diff --git a/util/event_trace.h b/util/event_trace.h
> index 6586e1dc254d..9c53eba7533f 100644
> --- a/util/event_trace.h
> +++ b/util/event_trace.h
> @@ -17,7 +17,7 @@ struct event_ctx {
>  	const char *event_name; /* optional */
>  	int event_pid; /* optional */
>  	int (*parse_event)(struct tep_event *event, struct tep_record *record,
> -			   struct list_head *jlist_head); /* optional */
> +			   struct event_ctx *ctx);
>  };
>  
>  int trace_event_parse(struct tracefs_instance *inst, struct event_ctx *ectx);
diff mbox series

Patch

diff --git a/util/event_trace.c b/util/event_trace.c
index 57318e2adace..1f5c180a030b 100644
--- a/util/event_trace.c
+++ b/util/event_trace.c
@@ -60,7 +60,7 @@  static struct json_object *num_to_json(void *num, int elem_size, unsigned long f
 }
 
 static int event_to_json(struct tep_event *event, struct tep_record *record,
-			 struct list_head *jlist_head)
+			 struct event_ctx *ctx)
 {
 	struct json_object *jevent, *jobj, *jarray;
 	struct tep_format_field **fields;
@@ -190,7 +190,7 @@  static int event_to_json(struct tep_event *event, struct tep_record *record,
 		}
 	}
 
-	list_add_tail(jlist_head, &jnode->list);
+	list_add_tail(&ctx->jlist_head, &jnode->list);
 	return 0;
 
 err_jevent:
@@ -220,10 +220,9 @@  static int event_parse(struct tep_event *event, struct tep_record *record,
 	}
 
 	if (event_ctx->parse_event)
-		return event_ctx->parse_event(event, record,
-					      &event_ctx->jlist_head);
+		return event_ctx->parse_event(event, record, event_ctx);
 
-	return event_to_json(event, record, &event_ctx->jlist_head);
+	return event_to_json(event, record, event_ctx);
 }
 
 int trace_event_parse(struct tracefs_instance *inst, struct event_ctx *ectx)
diff --git a/util/event_trace.h b/util/event_trace.h
index 6586e1dc254d..9c53eba7533f 100644
--- a/util/event_trace.h
+++ b/util/event_trace.h
@@ -17,7 +17,7 @@  struct event_ctx {
 	const char *event_name; /* optional */
 	int event_pid; /* optional */
 	int (*parse_event)(struct tep_event *event, struct tep_record *record,
-			   struct list_head *jlist_head); /* optional */
+			   struct event_ctx *ctx);
 };
 
 int trace_event_parse(struct tracefs_instance *inst, struct event_ctx *ectx);