public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Robin Murphy <robin.murphy@arm.com>
Cc: will@kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, ilkka@os.amperecomputing.com
Subject: Re: [PATCH 5/8] perf/arm-cmn: Make cycle counts less surprising
Date: Fri, 16 Aug 2024 11:25:28 +0100	[thread overview]
Message-ID: <Zr8pGEMmzmexNGL8@J2N7QTR9R3> (raw)
In-Reply-To: <570c473134426b8e11bb043aa59e3cde3dab8af3.1723229941.git.robin.murphy@arm.com>

On Fri, Aug 09, 2024 at 08:15:44PM +0100, Robin Murphy wrote:
> By default, CMN has automatic clock-gating with the implication that a
> DTC's cycle counter may not increment while the domain is sufficiently
> idle.

Similar is true for the cycles event on the CPU side, so this has some
precedent.

> Given that we may have up to 4 DTCs to choose from when scheduling
> a cycles event, this may potentially lead to surprising results if
> trying to measure metrics based on activity in a different DTC domain
> from where cycles end up being counted. Make the reasonable assumption
> that if the user wants to count cycles, they almost certainly want to
> count all of the cycles, and disable clock gating while a DTC's cycle
> counter is in use.

As above, the default does match the CPU side behaviour, and a user
might be trying to determine how much clock gating occurs over some
period, so it's not necessarily right to always disable clock gating.
That might need to be an explicit option on the cycles event.

Do we always have the ability to disable clock gating, or can that be
locked down by system integration or FW?

Mark.

> 
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
>  drivers/perf/arm-cmn.c | 16 +++++++++++-----
>  1 file changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c
> index 8f7a1a6f8ab7..4d128db2040c 100644
> --- a/drivers/perf/arm-cmn.c
> +++ b/drivers/perf/arm-cmn.c
> @@ -115,6 +115,7 @@
>  /* The DTC node is where the magic happens */
>  #define CMN_DT_DTC_CTL			0x0a00
>  #define CMN_DT_DTC_CTL_DT_EN		BIT(0)
> +#define CMN_DT_DTC_CTL_CG_DISABLE	BIT(10)
>  
>  /* DTC counters are paired in 64-bit registers on a 16-byte stride. Yuck */
>  #define _CMN_DT_CNT_REG(n)		((((n) / 2) * 4 + (n) % 2) * 4)
> @@ -1544,9 +1545,12 @@ static void arm_cmn_event_start(struct perf_event *event, int flags)
>  	int i;
>  
>  	if (type == CMN_TYPE_DTC) {
> -		i = hw->dtc_idx[0];
> -		writeq_relaxed(CMN_CC_INIT, cmn->dtc[i].base + CMN_DT_PMCCNTR);
> -		cmn->dtc[i].cc_active = true;
> +		struct arm_cmn_dtc *dtc = cmn->dtc + hw->dtc_idx[0];
> +
> +		writel_relaxed(CMN_DT_DTC_CTL_DT_EN | CMN_DT_DTC_CTL_CG_DISABLE,
> +			       dtc->base + CMN_DT_DTC_CTL);
> +		writeq_relaxed(CMN_CC_INIT, dtc->base + CMN_DT_PMCCNTR);
> +		dtc->cc_active = true;
>  	} else if (type == CMN_TYPE_WP) {
>  		u64 val = CMN_EVENT_WP_VAL(event);
>  		u64 mask = CMN_EVENT_WP_MASK(event);
> @@ -1575,8 +1579,10 @@ static void arm_cmn_event_stop(struct perf_event *event, int flags)
>  	int i;
>  
>  	if (type == CMN_TYPE_DTC) {
> -		i = hw->dtc_idx[0];
> -		cmn->dtc[i].cc_active = false;
> +		struct arm_cmn_dtc *dtc = cmn->dtc + hw->dtc_idx[0];
> +
> +		dtc->cc_active = false;
> +		writel_relaxed(CMN_DT_DTC_CTL_DT_EN, dtc->base + CMN_DT_DTC_CTL);
>  	} else if (type == CMN_TYPE_WP) {
>  		for_each_hw_dn(hw, dn, i) {
>  			void __iomem *base = dn->pmu_base + CMN_DTM_OFFSET(hw->dtm_offset);
> -- 
> 2.39.2.101.g768bb238c484.dirty
> 


  reply	other threads:[~2024-08-16 10:26 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-09 19:15 [PATCH 0/8] perf/arm-cmn: Fixes and updates Robin Murphy
2024-08-09 19:15 ` [PATCH 1/8] perf/arm-cmn: Refactor node ID handling. Again Robin Murphy
2024-08-16  9:33   ` Mark Rutland
2024-08-16 11:56     ` Robin Murphy
2024-08-16 12:45       ` Mark Rutland
2024-08-16 13:21         ` Robin Murphy
2024-08-24  1:00   ` Ilkka Koskinen
2024-08-27 13:51     ` Robin Murphy
2024-08-09 19:15 ` [PATCH 2/8] perf/arm-cmn: Fix CCLA register offset Robin Murphy
2024-08-16 10:00   ` Mark Rutland
2024-08-16 18:33     ` Robin Murphy
2024-08-23 23:18       ` Ilkka Koskinen
2024-08-09 19:15 ` [PATCH 3/8] perf/arm-cmn: Ensure dtm_idx is big enough Robin Murphy
2024-08-16 10:14   ` Mark Rutland
2024-08-19 15:00     ` Robin Murphy
2024-08-20  9:27       ` Mark Rutland
2024-08-23 23:58       ` Ilkka Koskinen
2024-08-09 19:15 ` [PATCH 4/8] perf/arm-cmn: Improve build-time assertions Robin Murphy
2024-08-16 10:20   ` Mark Rutland
2024-08-09 19:15 ` [PATCH 5/8] perf/arm-cmn: Make cycle counts less surprising Robin Murphy
2024-08-16 10:25   ` Mark Rutland [this message]
2024-08-19 16:35     ` Robin Murphy
2024-08-09 19:15 ` [PATCH 6/8] perf/arm-cmn: Refactor DTC PMU register access Robin Murphy
2024-08-16 10:29   ` Mark Rutland
2024-08-19 16:41     ` Robin Murphy
2024-08-20  9:23       ` Mark Rutland
2024-08-23 23:46         ` Ilkka Koskinen
2024-08-09 19:15 ` [PATCH 7/8] dt-bindings: perf: arm-cmn: Add CMN S3 Robin Murphy
2024-08-15 15:20   ` Rob Herring (Arm)
2024-08-09 19:15 ` [PATCH 8/8] perf/arm-cmn: Support " Robin Murphy
2024-08-16 10:32   ` Mark Rutland
2024-08-23 23:38   ` Ilkka Koskinen

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=Zr8pGEMmzmexNGL8@J2N7QTR9R3 \
    --to=mark.rutland@arm.com \
    --cc=ilkka@os.amperecomputing.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robin.murphy@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox