All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alison Schofield <alison.schofield@intel.com>
To: Dave Jiang <dave.jiang@intel.com>
Cc: linux-cxl@vger.kernel.org, vishal.l.verma@intel.com,
	ira.weiny@intel.com, bwidawsk@kernel.org,
	dan.j.williams@intel.com, nafonten@amd.com,
	nvdimm@lists.linux.dev
Subject: Re: [PATCH v2 2/9] cxl: add helper to parse through all current events
Date: Wed, 21 Sep 2022 14:09:03 -0700	[thread overview]
Message-ID: <Yyt9b99nWEaM5jEF@aschofie-mobl2> (raw)
In-Reply-To: <166363120598.3861186.12071132915910252601.stgit@djiang5-desk3.ch.intel.com>


On Mon, Sep 19, 2022 at 04:46:46PM -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
> for the interested events.
> 
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> ---
>  cxl/event_trace.c |   33 +++++++++++++++++++++++++++++++++
>  cxl/event_trace.h |    7 +++++++
>  cxl/meson.build   |    1 +
>  meson.build       |    2 ++
>  4 files changed, 43 insertions(+)
> 
> diff --git a/cxl/event_trace.c b/cxl/event_trace.c
> index ffa2a9b9b036..430146ce66f5 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"
>  
> @@ -164,3 +165,35 @@ err_jevent:
>  	free(jnode);
>  	return rc;
>  }
> +
> +static int cxl_event_parse_cb(struct tep_event *event, struct tep_record *record,
> +		int cpu, void *ctx)
> +{
> +	struct event_ctx *event_ctx = (struct event_ctx *)ctx;
> +	int rc;
> +
> +	/* Filter out all the events that the caller isn't interested in. */
> +	if (strcmp(event->system, event_ctx->system) != 0)
> +		return 0;
> +

While integrating w poison events, I find I'd like to filter on 
tep_event->name == "cxl_poison" here.

Something like this:

+	if (event_ctx->name) {
+		if (strcmp(event->name, event_ctx->name) != 0)
+			return 0;
+	}
 
along w this:

struct event_ctx {
 	const char *system;
+	const char *name;
 	struct list_head jlist_head;
 };

I guess an all|1 option won't suffice for users wanting a subset.
See how that fits it w your needs for monitor command. I can always
filter after the fact if this type of change is not generally useful.

Thanks,
Alison


> +	rc = cxl_event_to_json_callback(event, record, &event_ctx->jlist_head);
> +	if (rc < 0)
> +		return rc;
> +
> +	return 0;
> +}
> +
> +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..2fbefa1586d9 100644
> --- a/cxl/event_trace.h
> +++ b/cxl/event_trace.h
> @@ -11,4 +11,11 @@ struct jlist_node {
>  	struct list_node list;
>  };
>  
> +struct event_ctx {
> +	const char *system;
> +	struct list_head jlist_head;
> +};
> +
> +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)
> 
> 

  reply	other threads:[~2022-09-21 21:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-19 23:46 [PATCH v2 0/9] cxl: add monitor support for trace events Dave Jiang
2022-09-19 23:46 ` [PATCH v2 1/9] cxl: add helper function to parse trace event to json object Dave Jiang
2022-09-19 23:46 ` [PATCH v2 2/9] cxl: add helper to parse through all current events Dave Jiang
2022-09-21 21:09   ` Alison Schofield [this message]
2022-09-21 21:46     ` Dave Jiang
2022-09-19 23:46 ` [PATCH v2 3/9] cxl: add common function to enable event trace Dave Jiang
2022-09-19 23:46 ` [PATCH v2 4/9] cxl: add common function to disable " Dave Jiang
2022-09-19 23:47 ` [PATCH v2 5/9] cxl: add monitor function for event trace events Dave Jiang
2022-09-19 23:47 ` [PATCH v2 6/9] cxl: add logging functions for monitor Dave Jiang
2022-09-19 23:47 ` [PATCH v2 7/9] cxl: add monitor command to cxl Dave Jiang
2022-09-19 23:47 ` [PATCH v2 8/9] cxl: add systemd service for monitor Dave Jiang
2022-09-19 23:47 ` [PATCH v2 9/9] cxl: add man page documentation " Dave Jiang

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=Yyt9b99nWEaM5jEF@aschofie-mobl2 \
    --to=alison.schofield@intel.com \
    --cc=bwidawsk@kernel.org \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=ira.weiny@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=nafonten@amd.com \
    --cc=nvdimm@lists.linux.dev \
    --cc=vishal.l.verma@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.