diff mbox series

[v4,08/10] cxl: add an optional pid check to event parsing

Message ID 166793223408.3768752.4466685754838805704.stgit@djiang5-desk3.ch.intel.com
State New, archived
Headers show
Series cxl: add monitor support for trace events | expand

Commit Message

Dave Jiang Nov. 8, 2022, 6:30 p.m. UTC
From: Alison Schofield <alison.schofield@intel.com>

When parsing CXL events, callers may only be interested in events
that originate from the current process. Introduce an optional
argument to the event trace context: event_pid. When event_pid is
present, only include events with a matching pid in the returned
JSON list. It is not a failure to see other, non matching results.
Simply skip those.

The initial use case for this is the listing of media errors,
where only the media-errors requested by this process are wanted.

Signed-off-by: Alison Schofield <alison.schofield@intel.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
 cxl/event_trace.c |    5 +++++
 cxl/event_trace.h |    1 +
 2 files changed, 6 insertions(+)

Comments

Verma, Vishal L Nov. 9, 2022, 12:48 a.m. UTC | #1
On Tue, 2022-11-08 at 11:30 -0700, Dave Jiang wrote:
> From: Alison Schofield <alison.schofield@intel.com>
> 
> When parsing CXL events, callers may only be interested in events
> that originate from the current process. Introduce an optional
> argument to the event trace context: event_pid. When event_pid is
> present, only include events with a matching pid in the returned
> JSON list. It is not a failure to see other, non matching results.
> Simply skip those.
> 
> The initial use case for this is the listing of media errors,
> where only the media-errors requested by this process are wanted.
> 
> Signed-off-by: Alison Schofield <alison.schofield@intel.com>
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> ---
>  cxl/event_trace.c |    5 +++++
>  cxl/event_trace.h |    1 +
>  2 files changed, 6 insertions(+)

I might be missing something - but this patch is added at then end,
without subsequently using the event_pid in cxl-monitor? So why not
leave this to be part of the media errors patches?

> 
> diff --git a/cxl/event_trace.c b/cxl/event_trace.c
> index 490c30e1dbfc..89c9c2db26a3 100644
> --- a/cxl/event_trace.c
> +++ b/cxl/event_trace.c
> @@ -215,6 +215,11 @@ static int cxl_event_parse_cb(struct tep_event *event, struct tep_record *record
>                         return 0;
>         }
>  
> +       if (event_ctx->event_pid) {
> +               if (event_ctx->event_pid != tep_data_pid(event->tep, record))
> +                       return 0;
> +       }
> +
>         if (event_ctx->parse_event)
>                 return event_ctx->parse_event(event, record, &event_ctx->jlist_head);
>  
> diff --git a/cxl/event_trace.h b/cxl/event_trace.h
> index 89e98cafb320..e72b4347175e 100644
> --- a/cxl/event_trace.h
> +++ b/cxl/event_trace.h
> @@ -15,6 +15,7 @@ struct event_ctx {
>         const char *system;
>         struct list_head jlist_head;
>         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 */
>  };
> 
>
Dave Jiang Nov. 9, 2022, 10:44 p.m. UTC | #2
On 11/8/2022 4:48 PM, Verma, Vishal L wrote:
> On Tue, 2022-11-08 at 11:30 -0700, Dave Jiang wrote:
>> From: Alison Schofield <alison.schofield@intel.com>
>>
>> When parsing CXL events, callers may only be interested in events
>> that originate from the current process. Introduce an optional
>> argument to the event trace context: event_pid. When event_pid is
>> present, only include events with a matching pid in the returned
>> JSON list. It is not a failure to see other, non matching results.
>> Simply skip those.
>>
>> The initial use case for this is the listing of media errors,
>> where only the media-errors requested by this process are wanted.
>>
>> Signed-off-by: Alison Schofield <alison.schofield@intel.com>
>> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
>> ---
>>   cxl/event_trace.c |    5 +++++
>>   cxl/event_trace.h |    1 +
>>   2 files changed, 6 insertions(+)
> 
> I might be missing something - but this patch is added at then end,
> without subsequently using the event_pid in cxl-monitor? So why not
> leave this to be part of the media errors patches?

Alison, you want to move this to your series?

> 
>>
>> diff --git a/cxl/event_trace.c b/cxl/event_trace.c
>> index 490c30e1dbfc..89c9c2db26a3 100644
>> --- a/cxl/event_trace.c
>> +++ b/cxl/event_trace.c
>> @@ -215,6 +215,11 @@ static int cxl_event_parse_cb(struct tep_event *event, struct tep_record *record
>>                          return 0;
>>          }
>>   
>> +       if (event_ctx->event_pid) {
>> +               if (event_ctx->event_pid != tep_data_pid(event->tep, record))
>> +                       return 0;
>> +       }
>> +
>>          if (event_ctx->parse_event)
>>                  return event_ctx->parse_event(event, record, &event_ctx->jlist_head);
>>   
>> diff --git a/cxl/event_trace.h b/cxl/event_trace.h
>> index 89e98cafb320..e72b4347175e 100644
>> --- a/cxl/event_trace.h
>> +++ b/cxl/event_trace.h
>> @@ -15,6 +15,7 @@ struct event_ctx {
>>          const char *system;
>>          struct list_head jlist_head;
>>          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 */
>>   };
>>
>>
>
diff mbox series

Patch

diff --git a/cxl/event_trace.c b/cxl/event_trace.c
index 490c30e1dbfc..89c9c2db26a3 100644
--- a/cxl/event_trace.c
+++ b/cxl/event_trace.c
@@ -215,6 +215,11 @@  static int cxl_event_parse_cb(struct tep_event *event, struct tep_record *record
 			return 0;
 	}
 
+	if (event_ctx->event_pid) {
+		if (event_ctx->event_pid != tep_data_pid(event->tep, record))
+			return 0;
+	}
+
 	if (event_ctx->parse_event)
 		return event_ctx->parse_event(event, record, &event_ctx->jlist_head);
 
diff --git a/cxl/event_trace.h b/cxl/event_trace.h
index 89e98cafb320..e72b4347175e 100644
--- a/cxl/event_trace.h
+++ b/cxl/event_trace.h
@@ -15,6 +15,7 @@  struct event_ctx {
 	const char *system;
 	struct list_head jlist_head;
 	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 */
 };