Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
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 2/2] perf/imx_ddr: Add stop counter support for i.MX8MP
Date: Mon, 2 Mar 2020 11:24:41 +0000	[thread overview]
Message-ID: <20200302112441.GB7995@willie-the-truck> (raw)
In-Reply-To: <20200225125644.18853-2-qiangqing.zhang@nxp.com>

On Tue, Feb 25, 2020 at 08:56:44PM +0800, Joakim Zhang wrote:
> DDR perf driver now only supports free-running event counters
> (counter1/2/3), which means that event counters will continue counting
> even they are overflow.
> 
> However, the situation is changed on i.MX8MP, event counters are not
> free-running any more. Event counters would stop counting if they are
> overflow. So we need clear event counters when cycle counter overflow.
> 
> The patch adds stop counter support which would be compatible to
> free-running counter.

Hmm, are you saying that the hardware behaviour has changed here, so that
newer SoCs force the behaviour where all the counters stop when one
overflows? Is there any way to control that behaviour?

> @@ -566,6 +571,25 @@ static irqreturn_t ddr_perf_irq_handler(int irq, void *p)
>  			cycle_event = event;
>  	}
>  
> +	spin_lock(&pmu->lock);
> +
> +	for (i = 0; i < NUM_COUNTERS; i++) {
> +		if (!pmu->events[i])
> +			continue;
> +
> +		event = pmu->events[i];
> +
> +		if (event->hw.idx == EVENT_CYCLES_COUNTER)
> +			continue;
> +
> +		/* clear non-cycle counters */
> +		ddr_perf_counter_enable(pmu, event->attr.config, event->hw.idx, true);
> +
> +		local64_set(&event->hw.prev_count, 0);
> +	}
> +
> +	spin_unlock(&pmu->lock);

I'm suspicious of this locking, as it's /very/ fine-grained. What prevents
racing with a concurrent ddr_perf_counter_enable() call? Also, doesn't perf
core need to be aware that you're stopping counters here?

Finally, this looks like it's an unconditional change in user-visible
behaviour. Why doesn't it break existing usage of the perf tool?

Will

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-03-02 11:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-25 12:56 [PATCH 1/2] perf/imx_ddr: Correct the CLEAR bit definition Joakim Zhang
2020-02-25 12:56 ` [PATCH 2/2] perf/imx_ddr: Add stop counter support for i.MX8MP Joakim Zhang
2020-03-02 11:24   ` Will Deacon [this message]
2020-03-03  5:34     ` Joakim Zhang
2020-04-16  9:51       ` Joakim Zhang
2020-05-20  7:51         ` Will Deacon
2020-05-21  4:57           ` Joakim Zhang
2020-03-02 11:25 ` [PATCH 1/2] perf/imx_ddr: Correct the CLEAR bit definition Will Deacon
2020-03-03  5:34   ` 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=20200302112441.GB7995@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