From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Ira Weiny <ira.weiny@intel.com>,
Dan Williams <dan.j.williams@intel.com>,
Alison Schofield <alison.schofield@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Ben Widawsky <bwidawsk@kernel.org>,
"Davidlohr Bueso" <dave@stgolabs.net>,
<linux-kernel@vger.kernel.org>, <linux-cxl@vger.kernel.org>
Subject: Re: [RFC V2 PATCH 05/11] cxl/mem: Trace General Media Event Record
Date: Tue, 18 Oct 2022 10:46:36 +0100 [thread overview]
Message-ID: <20221018104636.000016fc@huawei.com> (raw)
In-Reply-To: <20221017132143.360d2d46@gandalf.local.home>
On Mon, 17 Oct 2022 13:21:43 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:
> On Mon, 17 Oct 2022 17:37:17 +0100
> Jonathan Cameron <Jonathan.Cameron@huawei.com> wrote:
>
> > Looking at other similar cases though and we have a lot of use
> > of trace_seq_printf() e.g. libata_trace_parse_status() though note
> > there is some magic macro stuff in include/trace/events/libata.h
> > to tie that together.
> > https://elixir.bootlin.com/linux/latest/source/drivers/ata/libata-trace.c#L14
> >
> > That seems to get you access to the actual buffer we are printing into
> > in similar cases.
>
> Looking at the code you linked to, I wonder why __print_flags() wasn't used?
>
> For instance, you have:
>
> const char *
> libata_trace_parse_status(struct trace_seq *p, unsigned char status)
> {
> const char *ret = trace_seq_buffer_ptr(p);
>
> trace_seq_printf(p, "{ ");
> if (status & ATA_BUSY)
> trace_seq_printf(p, "BUSY ");
> if (status & ATA_DRDY)
> trace_seq_printf(p, "DRDY ");
> if (status & ATA_DF)
> trace_seq_printf(p, "DF ");
> if (status & ATA_DSC)
> trace_seq_printf(p, "DSC ");
> if (status & ATA_DRQ)
> trace_seq_printf(p, "DRQ ");
> if (status & ATA_CORR)
> trace_seq_printf(p, "CORR ");
> if (status & ATA_SENSE)
> trace_seq_printf(p, "SENSE ");
> if (status & ATA_ERR)
> trace_seq_printf(p, "ERR ");
> trace_seq_putc(p, '}');
> trace_seq_putc(p, 0);
>
> return ret;
> }
>
>
> Which is just a re-implementation of:
>
> __print_flags(status, " ",
> { ATA_BUSY, "BUSY" },
> { ATA_DRDY, "DRDY" },
> { ATA_DF, "DF" },
> { ATA_DSC, "DSC" },
> { ATA_DRQ, "DRQ" },
> { ATA_CORR, "CORR" },
> { ATA_SENSE, "SENSE" },
> { ATA_ERR, "ERR" })
>
>
> The major difference between the two, is that libtraceevent will be able to
> parse the above and convert the status bits into strings, whereas using
> libata_trace_parse_status() will just give you a parsing error.
>
> That is, perf and trace-cmd will not be able to parse it unless you write a
> separate plugin for libtraceevent to do it but that means you'll have
> duplicate code.
>
> I know you just want echo and cat, but that will still work, and this will
> make it work for the tooling as well.
Excellent point, though in the case we are interested in for CXL,
__print_flags() is not enough.
We have a mass of fields that only contain something useful to print if
the valid bits in a mask are set. I just pulled that example to
show how trace_seq_printf() could be used to achieve optional printing
as opposed to current situation where the reader of the print has
to interpret the mask to work out if fields contain anything useful.
To do something nice with them in perf (well probably ras-daemon in
this case) we'll have to parse the valid bits anyway so effectively
write such a plugin. There we need to do a bunch of mangling to get
the events stored in a DB anyway, so this isn't a huge overhead.
Jonathan
>
> -- Steve
>
next prev parent reply other threads:[~2022-10-18 9:46 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-10 22:41 [RFC V2 PATCH 00/11] CXL: Process event logs ira.weiny
2022-10-10 22:41 ` [RFC V2 PATCH 01/11] cxl/mbox: Add debug of hardware error code ira.weiny
2022-10-11 10:41 ` Jonathan Cameron
2022-10-14 16:29 ` Davidlohr Bueso
2022-10-14 16:31 ` Davidlohr Bueso
2022-10-14 17:00 ` Ira Weiny
2022-10-10 22:41 ` [RFC V2 PATCH 02/11] cxl/mem: Implement Get Event Records command ira.weiny
2022-10-11 12:39 ` Jonathan Cameron
2022-10-14 19:21 ` Ira Weiny
2022-10-15 11:28 ` Steven Rostedt
2022-10-16 21:43 ` Ira Weiny
2022-10-20 21:50 ` Smita Koralahalli
2022-10-21 5:11 ` Ira Weiny
2022-10-10 22:41 ` [RFC V2 PATCH 03/11] cxl/mem: Implement Clear " ira.weiny
2022-10-10 22:41 ` [RFC V2 PATCH 04/11] cxl/mem: Clear events on driver load ira.weiny
2022-10-11 12:42 ` Jonathan Cameron
2022-10-10 22:41 ` [RFC V2 PATCH 05/11] cxl/mem: Trace General Media Event Record ira.weiny
2022-10-11 12:57 ` Jonathan Cameron
2022-10-14 23:33 ` Ira Weiny
2022-10-17 16:37 ` Jonathan Cameron
2022-10-17 17:21 ` Steven Rostedt
2022-10-18 9:46 ` Jonathan Cameron [this message]
2022-10-21 5:13 ` Ira Weiny
2022-10-15 11:30 ` Steven Rostedt
2022-10-10 22:41 ` [RFC V2 PATCH 06/11] cxl/mem: Trace DRAM " ira.weiny
2022-10-11 13:47 ` Jonathan Cameron
2022-10-14 23:45 ` Ira Weiny
2022-10-15 11:31 ` Steven Rostedt
2022-10-10 22:41 ` [RFC V2 PATCH 07/11] cxl/mem: Trace Memory Module " ira.weiny
2022-10-11 13:54 ` Jonathan Cameron
2022-10-15 11:32 ` Steven Rostedt
2022-10-10 22:41 ` [RFC V2 PATCH 08/11] cxl/test: Add generic mock events ira.weiny
2022-10-10 22:41 ` [RFC V2 PATCH 09/11] cxl/test: Add specific events ira.weiny
2022-10-10 22:41 ` [RFC V2 PATCH 10/11] cxl/test: Simulate event log overflow ira.weiny
2022-10-10 22:41 ` [RFC V2 PATCH 11/11] cxl/mem: Wire up event interrupts ira.weiny
2022-10-12 18:01 ` Davidlohr Bueso
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=20221018104636.000016fc@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=alison.schofield@intel.com \
--cc=bwidawsk@kernel.org \
--cc=dan.j.williams@intel.com \
--cc=dave@stgolabs.net \
--cc=ira.weiny@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.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;
as well as URLs for NNTP newsgroup(s).