Message ID | 166742402130.2654617.9308255604215496136.stgit@djiang5-desk3.ch.intel.com |
---|---|
State | Superseded |
Headers | show |
Series | cxl: add monitor support for trace events | expand |
On Wed, 02 Nov 2022 14:20:21 -0700 Dave Jiang <dave.jiang@intel.com> wrote: > 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 | 21 +++++++++++++++++++++ > cxl/event_trace.h | 1 + > 2 files changed, 22 insertions(+) > > diff --git a/cxl/event_trace.c b/cxl/event_trace.c > index cf63d2346f6e..d59e54c33df6 100644 > --- a/cxl/event_trace.c > +++ b/cxl/event_trace.c > @@ -200,3 +200,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) > +{ > + int rc; > + char *path; > + > + rc = asprintf(&path, "events/%s/enable", system); > + if (rc == -1) > + return -errno; > + > + rc = tracefs_instance_file_write(inst, path, "1"); > + free(path); > + if (rc == -1) > + return -errno; Latest libtracefs has: tracefs_event_enable(inst, system, NULL); That enables all events for a system in the instance "inst". -- Steve > + > + 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..0258b8dc65a3 100644 > --- a/cxl/event_trace.h > +++ b/cxl/event_trace.h > @@ -20,5 +20,6 @@ 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); > > #endif >
On 11/2/2022 11:00 PM, Steven Rostedt wrote: > On Wed, 02 Nov 2022 14:20:21 -0700 > Dave Jiang <dave.jiang@intel.com> wrote: > >> 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 | 21 +++++++++++++++++++++ >> cxl/event_trace.h | 1 + >> 2 files changed, 22 insertions(+) >> >> diff --git a/cxl/event_trace.c b/cxl/event_trace.c >> index cf63d2346f6e..d59e54c33df6 100644 >> --- a/cxl/event_trace.c >> +++ b/cxl/event_trace.c >> @@ -200,3 +200,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) >> +{ >> + int rc; >> + char *path; >> + >> + rc = asprintf(&path, "events/%s/enable", system); >> + if (rc == -1) >> + return -errno; >> + >> + rc = tracefs_instance_file_write(inst, path, "1"); >> + free(path); >> + if (rc == -1) >> + return -errno; > > Latest libtracefs has: > > tracefs_event_enable(inst, system, NULL); > > That enables all events for a system in the instance "inst". Great. Thanks! I will switch to that. > > -- Steve > > >> + >> + 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..0258b8dc65a3 100644 >> --- a/cxl/event_trace.h >> +++ b/cxl/event_trace.h >> @@ -20,5 +20,6 @@ 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); >> >> #endif >> >
diff --git a/cxl/event_trace.c b/cxl/event_trace.c index cf63d2346f6e..d59e54c33df6 100644 --- a/cxl/event_trace.c +++ b/cxl/event_trace.c @@ -200,3 +200,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) +{ + int rc; + char *path; + + rc = asprintf(&path, "events/%s/enable", system); + if (rc == -1) + return -errno; + + rc = tracefs_instance_file_write(inst, path, "1"); + free(path); + 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..0258b8dc65a3 100644 --- a/cxl/event_trace.h +++ b/cxl/event_trace.h @@ -20,5 +20,6 @@ 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); #endif
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 | 21 +++++++++++++++++++++ cxl/event_trace.h | 1 + 2 files changed, 22 insertions(+)