Linux CXL
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Dave Jiang <dave.jiang@intel.com>
Cc: linux-cxl@vger.kernel.org, dan.j.williams@intel.com,
	ira.weiny@intel.com, vishal.l.verma@intel.com,
	alison.schofield@intel.com
Subject: Re: [PATCH v3 08/10] cxl: add an optional pid check to event parsing
Date: Thu, 3 Nov 2022 02:08:19 -0400	[thread overview]
Message-ID: <20221103020819.6e9ec973@rorschach.local.home> (raw)
In-Reply-To: <166742404957.2654617.13465219167688999810.stgit@djiang5-desk3.ch.intel.com>

On Wed, 02 Nov 2022 14:20:49 -0700
Dave Jiang <dave.jiang@intel.com> wrote:

> From: Alison Schofield <alison.schofield@intel.com>
> 
> When parsing CXL events, callers may only be interested in events
> that originate from the current process. Introduce an optional
> argument to the event trace context: event_pid. When event_pid is
> present, only include events with a matching pid in the returned
> JSON list. It is not a failure to see other, non matching results.
> Simply skip those.
> 
> The initial use case for this is the listing of media errors,
> where only the media-errors requested by this process are wanted.
> 
> Signed-off-by: Alison Schofield <alison.schofield@intel.com>
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> ---
>  cxl/event_trace.c |   18 ++++++++++++++++++
>  cxl/event_trace.h |    1 +
>  2 files changed, 19 insertions(+)
> 
> diff --git a/cxl/event_trace.c b/cxl/event_trace.c
> index bcd4f8b2968e..0be6317e6ada 100644
> --- a/cxl/event_trace.c
> +++ b/cxl/event_trace.c
> @@ -166,6 +166,19 @@ err_jevent:
>  	return rc;
>  }
>  
> +static bool cxl_match_pid(struct tep_event *event, struct tep_record *record,
> +			  int pid)
> +{
> +	unsigned long long val;
> +
> +	if (tep_get_common_field_val(NULL, event, "common_pid", record, &val, 0))

There's also a way to get the pid directly:

   pid = tep_data_pid(tep, record);

-- Steve

> +		return false;
> +	if (pid != (int)val)
> +		return false;
> +
> +	return true;
> +}
> +
>  static int cxl_event_parse_cb(struct tep_event *event, struct tep_record *record,
>  		int cpu, void *ctx)
>  {
> @@ -180,6 +193,11 @@ static int cxl_event_parse_cb(struct tep_event *event, struct tep_record *record
>  			return 0;
>  	}
>  
> +	if (event_ctx->event_pid) {
> +		if (!cxl_match_pid(event, record, event_ctx->event_pid))
> +			return 0;
> +	}
> +
>  	if (event_ctx->parse_event)
>  		return event_ctx->parse_event(event, record, &event_ctx->jlist_head);
>  
> diff --git a/cxl/event_trace.h b/cxl/event_trace.h
> index 17d922f922c1..64f07854b91b 100644
> --- a/cxl/event_trace.h
> +++ b/cxl/event_trace.h
> @@ -15,6 +15,7 @@ struct event_ctx {
>  	const char *system;
>  	struct list_head jlist_head;
>  	const char *event_name;					/* optional */
> +	int event_pid;						/* optional */
>  	int (*parse_event)(struct tep_event *event, struct tep_record *record,
>  			   struct list_head *jlist_head);	/* optional */
>  };
> 


  reply	other threads:[~2022-11-03  6:08 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-02 21:20 [PATCH v3 00/10] cxl: add monitor support for trace events Dave Jiang
2022-11-02 21:20 ` [PATCH v3 01/10] cxl: add helper function to parse trace event to json object Dave Jiang
2022-11-03  5:48   ` Steven Rostedt
2022-11-03 16:15     ` Dave Jiang
2022-11-04 18:56       ` Ira Weiny
2022-11-14 17:32         ` Steven Rostedt
2022-11-14 20:44           ` Alison Schofield
2022-11-14 20:53             ` Steven Rostedt
2022-11-02 21:20 ` [PATCH v3 02/10] cxl: add helper to parse through all current events Dave Jiang
2022-11-02 21:20 ` [PATCH v3 03/10] cxl: add common function to enable event trace Dave Jiang
2022-11-03  6:00   ` Steven Rostedt
2022-11-03 16:21     ` Dave Jiang
2022-11-02 21:20 ` [PATCH v3 04/10] cxl: add common function to disable " Dave Jiang
2022-11-03  6:02   ` Steven Rostedt
2022-11-03 16:30     ` Dave Jiang
2022-11-02 21:20 ` [PATCH v3 05/10] cxl: add monitor function for event trace events Dave Jiang
2022-11-03  6:06   ` Steven Rostedt
2022-11-03 16:34     ` Dave Jiang
2022-11-02 21:20 ` [PATCH v3 06/10] cxl: add logging functions for monitor Dave Jiang
2022-11-02 21:20 ` [PATCH v3 07/10] cxl: add monitor command to cxl Dave Jiang
2022-11-02 21:20 ` [PATCH v3 08/10] cxl: add an optional pid check to event parsing Dave Jiang
2022-11-03  6:08   ` Steven Rostedt [this message]
2022-11-03 15:57     ` Alison Schofield
2022-11-02 21:20 ` [PATCH v3 09/10] cxl: add systemd service for monitor Dave Jiang
2022-11-02 21:21 ` [PATCH v3 10/10] 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=20221103020819.6e9ec973@rorschach.local.home \
    --to=rostedt@goodmis.org \
    --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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox