diff mbox series

[ndctl,v12,2/8] util/trace: add an optional pid check to event parsing

Message ID efabce2812206f59d85cfb0490e946a26d640713.1711519822.git.alison.schofield@intel.com (mailing list archive)
State New
Delegated to: Patchwork Bot
Headers show
Series Support poison list retrieval | expand

Commit Message

Alison Schofield March 27, 2024, 7:52 p.m. UTC
From: Alison Schofield <alison.schofield@intel.com>

When parsing 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, simply skip the parsing of events without a matching pid.
It is not a failure to see other, non matching events.

The initial use case for this is CXL device poison listings where
only the media-error records requested by this process are wanted.

Signed-off-by: Alison Schofield <alison.schofield@intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
---
 util/event_trace.c | 5 +++++
 util/event_trace.h | 1 +
 2 files changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/util/event_trace.c b/util/event_trace.c
index 16013412bc06..57318e2adace 100644
--- a/util/event_trace.c
+++ b/util/event_trace.c
@@ -214,6 +214,11 @@  static int event_parse(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/util/event_trace.h b/util/event_trace.h
index 37c39aded871..6586e1dc254d 100644
--- a/util/event_trace.h
+++ b/util/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 */
 };