diff mbox series

[v5,3/7] ndctl: cxl: add common function to enable/disable event trace

Message ID 166803886584.145141.15515518810880150458.stgit@djiang5-desk3.ch.intel.com (mailing list archive)
State Accepted
Commit 1bd8259f29183aba7af7028137ae04bad30a8cc6
Headers show
Series ndctl: cxl: add monitor support for trace events | expand

Commit Message

Dave Jiang Nov. 10, 2022, 12:07 a.m. UTC
Add a common function for cxl command to enable and disable event
tracing for the instance created. Will only enable "cxl" system.

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

Patch

diff --git a/cxl/event_trace.c b/cxl/event_trace.c
index d7bbd3cf4946..a973a1f62d35 100644
--- a/cxl/event_trace.c
+++ b/cxl/event_trace.c
@@ -228,3 +228,24 @@  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;
+}
+
+int cxl_event_tracing_disable(struct tracefs_instance *inst)
+{
+	return tracefs_trace_off(inst);
+}
diff --git a/cxl/event_trace.h b/cxl/event_trace.h
index e83737de0ad5..ec6267202c8b 100644
--- a/cxl/event_trace.h
+++ b/cxl/event_trace.h
@@ -20,5 +20,8 @@  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);
+int cxl_event_tracing_disable(struct tracefs_instance *inst);
 
 #endif