Linux-CXL Archive mirror
 help / color / mirror / Atom feed
From: Alison Schofield <alison.schofield@intel.com>
To: Dave Jiang <dave.jiang@intel.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>,
	nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org
Subject: Re: [ndctl PATCH v9 5/7] cxl/list: collect and parse media_error records
Date: Wed, 6 Mar 2024 10:39:35 -0800	[thread overview]
Message-ID: <Zei4Z9sukWIEqkAn@aschofie-mobl2> (raw)
In-Reply-To: <85f2763b-6665-4f76-9175-d7c5acaf2a3d@intel.com>

On Mon, Mar 04, 2024 at 01:03:55PM -0700, Dave Jiang wrote:
> 
> 
> On 2/29/24 6:31 PM, alison.schofield@intel.com wrote:
> > From: Alison Schofield <alison.schofield@intel.com>
> > 
> > Media_error records are logged as events in the kernel tracing
> > subsystem. To prepare the media_error records for cxl list, enable
> > tracing, trigger the poison list read, and parse the generated
> > cxl_poison events into a json representation.
> > 
> > Use the event_trace private parsing option to customize the json
> > representation based on cxl-list calling options and event field
> > settings.
> > 
> > Signed-off-by: Alison Schofield <alison.schofield@intel.com>
> > ---
> >  cxl/json.c | 271 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 271 insertions(+)
> > 

snip

> > +static int poison_event_to_json(struct tep_event *event,
> > +				struct tep_record *record, void *ctx)
> > +{
> > +	struct poison_ctx *p_ctx = (struct poison_ctx *)ctx;
> > +	struct json_object *jobj, *jp, *jpoison = p_ctx->jpoison;
> > +	unsigned long flags = p_ctx->flags;
> > +	char flag_str[32] = { '\0' };
> > +	bool overflow = false;
> > +	u8 source, pflags;
> > +	const char *name;
> > +	u64 addr, ts;
> > +	u32 length;
> > +	char *str;
> > +
> > +	jp = json_object_new_object();
> > +	if (!jp)
> > +		return -ENOMEM;
> > +
> > +	/* Skip records not in this region when listing by region */
> > +	name = p_ctx->region ? cxl_region_get_devname(p_ctx->region) : NULL;
> > +	if (name)
> > +		str = cxl_get_field_string(event, record, "region");
> > +
> > +	if ((name) && (strcmp(name, str) != 0)) {
> > +		json_object_put(jp);
> > +		return 0;
> > +	}
> > +
> > +	/* Include endpoint decoder name with hpa, when present */
> > +	name = cxl_get_field_string(event, record, "memdev");
> > +	addr = cxl_get_field_u64(event, record, "hpa");
> > +	if (addr != ULLONG_MAX)
> > +		name = find_decoder_name(p_ctx, name, addr);
> > +	else
> > +		name = NULL;
> 
> Why assign name a few lines above and then reassign here without using?

name is used as a param to find_decoder_name(). I'll move that to
only retrieve from the record if we're doing find_decod_name().


> Also I noticed the name gets reassigned for different purposes a few times. Can we have separate variables in order to make the code cleaner to read? I think maybe a region_name and a decoder_name.

Yes, done in v10.

> > 

snip

> > +
> > +	source = cxl_get_field_u8(event, record, "source");
> > +	switch (source) {
> > +	case CXL_POISON_SOURCE_UNKNOWN:
> > +		jobj = json_object_new_string("Unknown");
> > +		break;
> > +	case CXL_POISON_SOURCE_EXTERNAL:
> > +		jobj = json_object_new_string("External");
> > +		break;
> > +	case CXL_POISON_SOURCE_INTERNAL:
> > +		jobj = json_object_new_string("Internal");
> > +		break;
> > +	case CXL_POISON_SOURCE_INJECTED:
> > +		jobj = json_object_new_string("Injected");
> > +		break;
> > +	case CXL_POISON_SOURCE_VENDOR:
> > +		jobj = json_object_new_string("Vendor");
> > +		break;
> > +	default:
> > +		jobj = json_object_new_string("Reserved");
> > +	}
> 
> Seems like you can have a static string table here? Then you can do something like:
> if (source < CXL_POISON_SOURCE_MAX)
> 	jobj = json_object_new_string(cxl_poison_source[source]);
> else
> 	jobj = json_object_new_string("Reserved");
> 
> DJ

Nice! Please take a look at in v10.

Thanks for the review!

snip

  reply	other threads:[~2024-03-06 18:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-01  1:31 [ndctl PATCH v9 0/7] Support poison list retrieval alison.schofield
2024-03-01  1:31 ` [ndctl PATCH v9 1/7] libcxl: add interfaces for GET_POISON_LIST mailbox commands alison.schofield
2024-03-01  1:31 ` [ndctl PATCH v9 2/7] cxl: add an optional pid check to event parsing alison.schofield
2024-03-01  1:31 ` [ndctl PATCH v9 3/7] cxl/event_trace: add a private context for private parsers alison.schofield
2024-03-01  1:31 ` [ndctl PATCH v9 4/7] cxl/event_trace: add helpers to retrieve tep fields by type alison.schofield
2024-03-04 18:26   ` Dave Jiang
2024-03-01  1:31 ` [ndctl PATCH v9 5/7] cxl/list: collect and parse media_error records alison.schofield
2024-03-04 20:03   ` Dave Jiang
2024-03-06 18:39     ` Alison Schofield [this message]
2024-03-01  1:31 ` [ndctl PATCH v9 6/7] cxl/list: add --media-errors option to cxl list alison.schofield
2024-03-01  1:31 ` [ndctl PATCH v9 7/7] cxl/test: add cxl-poison.sh unit test alison.schofield

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=Zei4Z9sukWIEqkAn@aschofie-mobl2 \
    --to=alison.schofield@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).