From: "Verma, Vishal L" <vishal.l.verma@intel.com>
To: "Jiang, Dave" <dave.jiang@intel.com>,
"linux-cxl@vger.kernel.org" <linux-cxl@vger.kernel.org>
Cc: "Williams, Dan J" <dan.j.williams@intel.com>,
"Schofield, Alison" <alison.schofield@intel.com>,
"rostedt@goodmis.org" <rostedt@goodmis.org>,
"Weiny, Ira" <ira.weiny@intel.com>
Subject: Re: [PATCH v4 02/10] cxl: add helper to parse through all current events
Date: Tue, 8 Nov 2022 23:45:48 +0000 [thread overview]
Message-ID: <6e0d8c9cfb2adb2c0039d1bbe42cc8a0dbc0a9ec.camel@intel.com> (raw)
In-Reply-To: <166793219956.3768752.10060411389279195687.stgit@djiang5-desk3.ch.intel.com>
On Tue, 2022-11-08 at 11:29 -0700, Dave Jiang wrote:
> Add common function to iterate through and extract the events in the
> current trace buffer. The function uses tracefs_iterate_raw_events() from
> libtracefs to go through all the events loaded into a tep_handle. A
> callback is provided to the API call in order to parse the event. For cxl
> monitor, an array of interested "systems" is provided in order to filter
I couldn't tell what a 'system' means here - maybe clarify that?
> for the interested events.
s/interested events/events of interest/ ?
>
> Tested-by: Alison Schofield <alison.schofield@intel.com>
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> ---
> cxl/event_trace.c | 36 ++++++++++++++++++++++++++++++++++++
> cxl/event_trace.h | 10 ++++++++++
> cxl/meson.build | 1 +
> meson.build | 2 ++
> 4 files changed, 49 insertions(+)
>
> diff --git a/cxl/event_trace.c b/cxl/event_trace.c
> index 1b1b037e48bf..4667044e4a66 100644
> --- a/cxl/event_trace.c
> +++ b/cxl/event_trace.c
> @@ -16,6 +16,7 @@
> #include <libcxl.h>
> #include <uuid/uuid.h>
> #include <traceevent/event-parse.h>
> +#include <tracefs/tracefs.h>
> #include "json.h"
> #include "event_trace.h"
>
> @@ -199,3 +200,38 @@ err_jevent:
> free(jnode);
> return rc;
> }
> +
> +static int cxl_event_parse_cb(struct tep_event *event, struct tep_record *record,
> + int cpu, void *ctx)
What does the _cb mean? I couldn't tell from what it's parsing what it
stands for - might be better to expand it?
> +{
> + struct event_ctx *event_ctx = (struct event_ctx *)ctx;
> +
> + /* Filter out all the events that the caller isn't interested in. */
> + if (strcmp(event->system, event_ctx->system) != 0)
> + return 0;
> +
> + if (event_ctx->event_name) {
> + if (strcmp(event->name, event_ctx->event_name) != 0)
> + return 0;
> + }
> +
> + if (event_ctx->parse_event)
> + return event_ctx->parse_event(event, record, &event_ctx->jlist_head);
> +
> + return cxl_event_to_json_callback(event, record, &event_ctx->jlist_head);
> +}
> +
> +int cxl_parse_events(struct tracefs_instance *inst, struct event_ctx *ectx)
> +{
> + struct tep_handle *tep;
> + int rc;
> +
> + tep = tracefs_local_events(NULL);
> + if (!tep)
> + return -ENOMEM;
> +
> + rc = tracefs_iterate_raw_events(tep, inst, NULL, 0,
> + cxl_event_parse_cb, ectx);
> + tep_free(tep);
> + return rc;
> +}
> diff --git a/cxl/event_trace.h b/cxl/event_trace.h
> index 00975a0b5680..582882c1eb35 100644
> --- a/cxl/event_trace.h
> +++ b/cxl/event_trace.h
> @@ -11,4 +11,14 @@ struct jlist_node {
> struct list_node list;
> };
>
> +struct event_ctx {
> + const char *system;
> + struct list_head jlist_head;
> + const char *event_name; /* optional */
> + int (*parse_event)(struct tep_event *event, struct tep_record *record,
> + struct list_head *jlist_head); /* optional */
> +};
> +
> +int cxl_parse_events(struct tracefs_instance *inst, struct event_ctx *ectx);
> +
> #endif
> diff --git a/cxl/meson.build b/cxl/meson.build
> index 8c7733431613..c59876262e76 100644
> --- a/cxl/meson.build
> +++ b/cxl/meson.build
> @@ -21,6 +21,7 @@ cxl_tool = executable('cxl',
> json,
> versiondep,
> traceevent,
> + tracefs,
> ],
> install : true,
> install_dir : rootbindir,
> diff --git a/meson.build b/meson.build
> index f611e0bdd7f3..c204c8ac52de 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -143,6 +143,8 @@ libudev = dependency('libudev')
> uuid = dependency('uuid')
> json = dependency('json-c')
> traceevent = dependency('libtraceevent')
> +tracefs = dependency('libtracefs')
> +
> if get_option('docs').enabled()
> if get_option('asciidoctor').enabled()
> asciidoc = find_program('asciidoctor', required : true)
>
>
next prev parent reply other threads:[~2022-11-08 23:46 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-08 18:29 [PATCH v4 00/10] cxl: add monitor support for trace events Dave Jiang
2022-11-08 18:29 ` [PATCH v4 01/10] cxl: add helper function to parse trace event to json object Dave Jiang
2022-11-08 23:02 ` Verma, Vishal L
2022-11-09 21:27 ` Dave Jiang
2022-11-08 18:29 ` [PATCH v4 02/10] cxl: add helper to parse through all current events Dave Jiang
2022-11-08 23:45 ` Verma, Vishal L [this message]
2022-11-09 21:30 ` Dave Jiang
2022-11-08 18:30 ` [PATCH v4 03/10] cxl: add common function to enable event trace Dave Jiang
2022-11-08 18:30 ` [PATCH v4 04/10] cxl: add common function to disable " Dave Jiang
2022-11-08 23:47 ` Verma, Vishal L
2022-11-08 18:30 ` [PATCH v4 05/10] cxl: add monitor function for event trace events Dave Jiang
2022-11-17 18:37 ` Steven Rostedt
2022-11-17 20:29 ` Dave Jiang
2022-11-17 20:33 ` Steven Rostedt
2022-11-17 20:44 ` Dave Jiang
2022-11-08 18:30 ` [PATCH v4 06/10] cxl: add logging functions for monitor Dave Jiang
2022-11-09 0:31 ` Verma, Vishal L
2022-11-08 18:30 ` [PATCH v4 07/10] cxl: add monitor command to cxl Dave Jiang
2022-11-09 0:35 ` Verma, Vishal L
2022-11-08 18:30 ` [PATCH v4 08/10] cxl: add an optional pid check to event parsing Dave Jiang
2022-11-09 0:48 ` Verma, Vishal L
2022-11-09 22:44 ` Dave Jiang
2022-11-08 18:30 ` [PATCH v4 09/10] cxl: add systemd service for monitor Dave Jiang
2022-11-09 0:48 ` Verma, Vishal L
2022-11-08 18:30 ` [PATCH v4 10/10] cxl: add man page documentation " Dave Jiang
2022-11-09 0:58 ` Verma, Vishal L
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6e0d8c9cfb2adb2c0039d1bbe42cc8a0dbc0a9ec.camel@intel.com \
--to=vishal.l.verma@intel.com \
--cc=alison.schofield@intel.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=ira.weiny@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox