On 1/17/24 17:28, [email protected] wrote:
> From: Alison Schofield <[email protected]>
>
> CXL event tracing provides helpers to iterate through a trace
> buffer and extract events of interest. It offers two parsing
> options: a default parser that adds every field of an event to
> a json object, and a private parsing option where the caller can
> parse each event as it wishes.
>
> Although the private parser can do some conditional parsing based
> on field values, it has no method to receive additional information
> needed to make parsing decisions in the callback.
>
> Add a private_ctx field to the existing 'struct event_context'.
> Replace the jlist_head parameter, used in the default parser,
> with the private_ctx.
>
> This is in preparation for adding a private parser requiring
> additional context for cxl_poison events.
>
> Signed-off-by: Alison Schofield <[email protected]>
Reviewed-by: Dave Jiang <[email protected]>
> ---
> cxl/event_trace.c | 2 +-
> cxl/event_trace.h | 3 ++-
> 2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/cxl/event_trace.c b/cxl/event_trace.c
> index 269060898118..fbf7a77235ff 100644
> --- a/cxl/event_trace.c
> +++ b/cxl/event_trace.c
> @@ -215,7 +215,7 @@ static int cxl_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);
> + event_ctx->private_ctx);
>
> return cxl_event_to_json(event, record, &event_ctx->jlist_head);
> }
> diff --git a/cxl/event_trace.h b/cxl/event_trace.h
> index 7f7773b2201f..ec61962abbc6 100644
> --- a/cxl/event_trace.h
> +++ b/cxl/event_trace.h
> @@ -16,8 +16,9 @@ struct event_ctx {
> struct list_head jlist_head;
> const char *event_name; /* optional */
> int event_pid; /* optional */
> + void *private_ctx; /* required with parse_event() */
> int (*parse_event)(struct tep_event *event, struct tep_record *record,
> - struct list_head *jlist_head); /* optional */
> + void *private_ctx);/* optional */
> };
>
> int cxl_parse_events(struct tracefs_instance *inst, struct event_ctx *ectx);