All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joakim Zhang <qiangqing.zhang@nxp.com>
To: Will Deacon <will@kernel.org>
Cc: "mark.rutland@arm.com" <mark.rutland@arm.com>,
	Frank Li <frank.li@nxp.com>, dl-linux-imx <linux-imx@nxp.com>,
	"kernel@pengutronix.de" <kernel@pengutronix.de>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: RE: [PATCH] perf: imx8_ddr_perf: calculate ddr bandwidth via virtual event read-bytes/write-bytes
Date: Fri, 12 Jul 2019 07:18:14 +0000	[thread overview]
Message-ID: <DB7PR04MB4618081D853C6CF9015D86EFE6F20@DB7PR04MB4618.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <20190709155606.x45nmew253giwvgf@willie-the-truck>


> -----Original Message-----
> From: Will Deacon <will@kernel.org>
> Sent: 2019年7月9日 23:56
> To: Joakim Zhang <qiangqing.zhang@nxp.com>
> Cc: mark.rutland@arm.com; Frank Li <frank.li@nxp.com>;
> kernel@pengutronix.de; dl-linux-imx <linux-imx@nxp.com>;
> linux-arm-kernel@lists.infradead.org
> Subject: Re: [PATCH] perf: imx8_ddr_perf: calculate ddr bandwidth via virtual
> event read-bytes/write-bytes
> 
> On Tue, Jul 09, 2019 at 05:46:44AM +0000, Joakim Zhang wrote:
> > We can calculate ddr bandwidth via virtual event
> > read-bytes/write-bytes based on ddr burst width, which actually share
> > event read-cycles/write-cycles. Burst width is 32 bit on i.MX8 board.
> >
> > The ddr interface will generate 2 up edges and 2 down edges in an
> > internal clock cycle, so it can pass 4 beats of data. 4 bytes of each
> > beat if ddr burst width is 32 bit.
> >
> > for example:
> > perf stat -a -e imx8_ddr0/read-bytes/,imx8_ddr0/write-bytes/ ls
> 
> I don't think you should be doing this in the kernel. Can you look at
> implementing it in perf tool instead by adding a .json file for your PMU and
> expressing this compound event using "MetricExpr"?

Hi Will,

I try to implement it in perf tool, but it shows nothing with perf list metricgroup.

A. Add JSON metric.
diff --git a/tools/perf/pmu-events/arch/arm64/imx/imx8/ddr-metric.json b/tools/perf/pmu-events/arch/arm64/imx/imx8/ddr-metric.json
new file mode 100644
index 000000000000..3588dc5a4f46
--- /dev/null
+++ b/tools/perf/pmu-events/arch/arm64/imx/imx8/ddr-metric.json
@@ -0,0 +1,20 @@
+[
+    {
+       "PublicDescription": "Calculate DDR read bandwidth based on read-cycles event. DDR interface generates 2 up and 2 down edges in an internal clock cycle, can pass 4 beats of data. 4 bytes of each beat if DDR burst width is 32 bit.",
+       "MetricName": "imx8_ddr0/read-bytes/",
+       "MetricGroup": "bandwidth",
+       "MetricExpr": "imx8_ddr0/read-cycles/ * 4 * 4",
+        "Unit": "MB",
+       "ScaleUnit": "0.000001",
+       "BriefDescription": "DDR read bandwidth"
+    },
+    {
+       "PublicDescription": "Calculate DDR write bandwidth based on write-cycles event. DDR interface generates 2 up and 2 down edges in an internal clock cycle, can pass 4 beats of data. 4 bytes of each beat if DDR burst width is 32 bit.",
+       "MetricName": "imx8_ddr0/write-bytes/",
+       "MetricGroup": "bandwidth",
+       "MetricExpr": "imx8_ddr0/write-cycles * 4 * 4",
+        "Unit": "MB",
+       "ScaleUnit": "0.000001",
+       "BriefDescription": "DDR write bandwidth"
+    }
+]
diff --git a/tools/perf/pmu-events/arch/arm64/mapfile.csv b/tools/perf/pmu-events/arch/arm64/mapfile.csv
index 927fcddcb4aa..12d378dca0d1 100644
--- a/tools/perf/pmu-events/arch/arm64/mapfile.csv
+++ b/tools/perf/pmu-events/arch/arm64/mapfile.csv
@@ -20,3 +20,4 @@
 0x00000000430f0af0,v1,cavium/thunderx2,core
 0x00000000480fd010,v1,hisilicon/hip08,core
 0x00000000500f0000,v1,ampere/emag,core
+0x000000004108d040,v1,imx/imx8,core

B. Test
root@imx8qxpmek:~# perf list metricgroup

List of pre-defined events (to be used in -e):

root@imx8qxpmek:~#

It generates the C source file, 'pmu-events.c', as /tools/perf/pmu-events/README said, but it can't generate this C file on my side.

Please tell me if something I missed. Thanks a lot!

Best Regards,
Joakim Zhang
> Will
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2019-07-12  7:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-09  5:46 [PATCH] perf: imx8_ddr_perf: calculate ddr bandwidth via virtual event read-bytes/write-bytes Joakim Zhang
2019-07-09 15:56 ` Will Deacon
2019-07-12  7:18   ` Joakim Zhang [this message]
2019-07-31 18:01     ` Will Deacon

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=DB7PR04MB4618081D853C6CF9015D86EFE6F20@DB7PR04MB4618.eurprd04.prod.outlook.com \
    --to=qiangqing.zhang@nxp.com \
    --cc=frank.li@nxp.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=mark.rutland@arm.com \
    --cc=will@kernel.org \
    /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.