From: Alison Schofield <alison.schofield@intel.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>,
nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org,
Dave Jiang <dave.jiang@intel.com>
Subject: Re: [ndctl PATCH v10 4/7] cxl/event_trace: add helpers to retrieve tep fields by type
Date: Thu, 7 Mar 2024 20:06:01 -0800 [thread overview]
Message-ID: <ZeqOqcwjbdmTS1ij@aschofie-mobl2> (raw)
In-Reply-To: <65e902155a5b4_12713294e2@dwillia2-mobl3.amr.corp.intel.com.notmuch>
On Wed, Mar 06, 2024 at 03:53:57PM -0800, Dan Williams wrote:
> alison.schofield@ wrote:
> > From: Alison Schofield <alison.schofield@intel.com>
> >
> > Add helpers to extract the value of an event record field given the
> > field name. This is useful when the user knows the name and format
> > of the field and simply needs to get it.
> >
> > Since this is in preparation for adding a cxl_poison private parser
> > for 'cxl list --media-errors' support, add those specific required
> > types: u8, u32, u64, char*
> >
> > Signed-off-by: Alison Schofield <alison.schofield@intel.com>
> > Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> > ---
> > cxl/event_trace.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++
> > cxl/event_trace.h | 10 ++++++-
> > 2 files changed, 84 insertions(+), 1 deletion(-)
> >
> > diff --git a/cxl/event_trace.c b/cxl/event_trace.c
> > index bdad0c19dbd4..6cc9444f3204 100644
> > --- a/cxl/event_trace.c
> > +++ b/cxl/event_trace.c
> > @@ -15,6 +15,81 @@
> > #define _GNU_SOURCE
> > #include <string.h>
> >
> > +static struct tep_format_field *__find_field(struct tep_event *event,
> > + const char *name)
> > +{
> > + struct tep_format_field **fields;
> > +
> > + fields = tep_event_fields(event);
> > + if (!fields)
> > + return NULL;
> > +
> > + for (int i = 0; fields[i]; i++) {
> > + struct tep_format_field *f = fields[i];
> > +
> > + if (strcmp(f->name, name) != 0)
> > + continue;
> > +
> > + return f;
> > + }
> > + return NULL;
> > +}
>
> Is this open-coded tep_find_field()?
Yes it is and now it is gone.
>
> > +
> > +u64 cxl_get_field_u64(struct tep_event *event, struct tep_record *record,
> > + const char *name)
> > +{
> > + struct tep_format_field *f;
> > + unsigned char *val;
> > + int len;
> > +
> > + f = __find_field(event, name);
> > + if (!f)
> > + return ULLONG_MAX;
> > +
> > + val = tep_get_field_raw(NULL, event, f->name, record, &len, 0);
> > + if (!val)
> > + return ULLONG_MAX;
> > +
> > + return *(u64 *)val;
> > +}
>
> Is this just open-coded tep_get_any_field_val()?
It's a bit more. It returns ULLONG_MAX and casts to the u64 which
makes the call site cleaner.
I did change it to use tep_get_field_val(). Please look at next rev.
>
> > +
> > +char *cxl_get_field_string(struct tep_event *event, struct tep_record *record,
> > + const char *name)
>
> Return a 'const char *'?
>
> > +{
> > + struct tep_format_field *f;
> > + int len;
> > +
> > + f = __find_field(event, name);
> > + if (!f)
> > + return NULL;
> > +
> > + return tep_get_field_raw(NULL, event, f->name, record, &len, 0);
>
> Is this guaranteed to be a string? ...and guaranteed to be NULL
> terminated?
>
It's gone. Using tep_get_field_raw() directly for str.
Thanks for reviewing!
next prev parent reply other threads:[~2024-03-08 4:06 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-06 18:42 [ndctl PATCH v10 0/7] Support poison list retrieval alison.schofield
2024-03-06 18:42 ` [ndctl PATCH v10 1/7] libcxl: add interfaces for GET_POISON_LIST mailbox commands alison.schofield
2024-03-06 23:07 ` Dan Williams
2024-03-06 18:42 ` [ndctl PATCH v10 2/7] cxl: add an optional pid check to event parsing alison.schofield
2024-03-06 23:11 ` Dan Williams
2024-03-06 18:42 ` [ndctl PATCH v10 3/7] cxl/event_trace: add a private context for private parsers alison.schofield
2024-03-06 23:36 ` Dan Williams
2024-03-10 22:39 ` Alison Schofield
2024-03-06 18:42 ` [ndctl PATCH v10 4/7] cxl/event_trace: add helpers to retrieve tep fields by type alison.schofield
2024-03-06 23:53 ` Dan Williams
2024-03-08 4:06 ` Alison Schofield [this message]
2024-03-06 18:42 ` [ndctl PATCH v10 5/7] cxl/list: collect and parse media_error records alison.schofield
2024-03-07 0:50 ` Dan Williams
2024-03-06 18:42 ` [ndctl PATCH v10 6/7] cxl/list: add --media-errors option to cxl list alison.schofield
2024-03-07 1:09 ` Dan Williams
2024-03-06 18:42 ` [ndctl PATCH v10 7/7] cxl/test: add cxl-poison.sh unit test alison.schofield
2024-03-06 23:03 ` [ndctl PATCH v10 0/7] Support poison list retrieval Dan Williams
2024-03-08 3:58 ` Alison Schofield
2024-03-08 4:03 ` Dan Williams
2024-03-10 19:21 ` 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=ZeqOqcwjbdmTS1ij@aschofie-mobl2 \
--to=alison.schofield@intel.com \
--cc=dan.j.williams@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