diff mbox series

[v4,03/10] cxl: add common function to enable event trace

Message ID 166793220535.3768752.9190750068767610122.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
Add a common function for cxl command to enable event tracing for the
instance created. The interested "systems" will be enabled for tracing
as well.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
 cxl/event_trace.c |   16 ++++++++++++++++
 cxl/event_trace.h |    2 ++
 2 files changed, 18 insertions(+)
diff mbox series

Patch

diff --git a/cxl/event_trace.c b/cxl/event_trace.c
index 4667044e4a66..95b0ce071166 100644
--- a/cxl/event_trace.c
+++ b/cxl/event_trace.c
@@ -235,3 +235,19 @@  int cxl_parse_events(struct tracefs_instance *inst, struct event_ctx *ectx)
 	tep_free(tep);
 	return rc;
 }
+
+int cxl_event_tracing_enable(struct tracefs_instance *inst, const char *system,
+		const char *event)
+{
+	int rc;
+
+	rc = tracefs_event_enable(inst, system, event);
+	if (rc == -1)
+		return -errno;
+
+	if (tracefs_trace_is_on(inst))
+		return 0;
+
+	tracefs_trace_on(inst);
+	return 0;
+}
diff --git a/cxl/event_trace.h b/cxl/event_trace.h
index 582882c1eb35..aecf9aa96187 100644
--- a/cxl/event_trace.h
+++ b/cxl/event_trace.h
@@ -20,5 +20,7 @@  struct event_ctx {
 };
 
 int cxl_parse_events(struct tracefs_instance *inst, struct event_ctx *ectx);
+int cxl_event_tracing_enable(struct tracefs_instance *inst, const char *system,
+		const char *event);
 
 #endif