From: Will Deacon <will@kernel.org>
To: Joakim Zhang <qiangqing.zhang@nxp.com>
Cc: mark.rutland@arm.com, robin.murphy@arm.com, linux-imx@nxp.com,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH V2] perf/imx_ddr: Add stop event counters support for i.MX8MP
Date: Mon, 21 Sep 2020 21:56:42 +0100 [thread overview]
Message-ID: <20200921205642.GC3811@willie-the-truck> (raw)
In-Reply-To: <20200921183602.GI3141@willie-the-truck>
On Mon, Sep 21, 2020 at 07:36:02PM +0100, Will Deacon wrote:
> On Tue, Sep 08, 2020 at 06:47:34PM +0800, Joakim Zhang wrote:
> > +static void ddr_perf_event_update(struct perf_event *event)
> > +{
> > + struct ddr_pmu *pmu = to_ddr_pmu(event->pmu);
> > + struct hw_perf_event *hwc = &event->hw;
> > + u64 delta, prev_raw_count, new_raw_count;
> > + int counter = hwc->idx;
> > + int ret;
> > +
> > + if (counter == EVENT_CYCLES_COUNTER) {
> > + do {
> > + prev_raw_count = local64_read(&hwc->prev_count);
> > + new_raw_count = ddr_perf_read_counter(pmu, counter);
> > + } while (local64_cmpxchg(&hwc->prev_count, prev_raw_count,
> > + new_raw_count) != prev_raw_count);
> > +
> > + delta = (new_raw_count - prev_raw_count) & 0xFFFFFFFF;
> > +
> > + local64_add(delta, &event->count);
>
> Why do we treat the cycle counter so differently here?
Ah, please can you remind me: does the cycle counter stop on overflow, or
does it continue to count?
> > + } else {
> > + /*
> > + * For legacy SoCs: event counters continue counting when overflow,
> > + * no need to clear the counter.
> > + * For new SoCs: event counters stop counting when overflow, need
> > + * clear counter to let it count again.
> > + */
> > + ret = ddr_perf_counter_overflow(pmu, counter);
> > + if (ret)
> > + dev_warn(pmu->dev, "Event Counter%d overflow happened, data incorrect!!\n", counter);
>
> I don't understand this message: if the data is incorrect, why do we need
> to handle overflow at all/, rather than putting the event into an error
> state?
Also, now I remember how this all works (we use the cycle counter to stop
overflow of the event counter), then warning here is ok, but we should do
something like:
dev_warn_ratelimited(pmu->dev, "events lost due to counter overflow (config 0x%llx)\n", event->attr.config);
instead.
Will
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-09-21 21:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-08 10:47 [PATCH V2] perf/imx_ddr: Add stop event counters support for i.MX8MP Joakim Zhang
2020-09-17 10:22 ` Joakim Zhang
2020-09-21 18:36 ` Will Deacon
2020-09-21 20:56 ` Will Deacon [this message]
2020-09-22 5:37 ` Joakim Zhang
2020-09-22 6:42 ` Joakim Zhang
2020-09-22 5:30 ` Joakim Zhang
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=20200921205642.GC3811@willie-the-truck \
--to=will@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=mark.rutland@arm.com \
--cc=qiangqing.zhang@nxp.com \
--cc=robin.murphy@arm.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