Linux Perf Users
 help / color / mirror / Atom feed
* [PATCH] perf/arm-cmn: Use at least 2 bits per XP coordinate in node IDs
@ 2026-11-25 16:15 Sylvain Chouleur via B4 Relay
  2026-11-25 16:19 ` sashiko-bot
  2026-11-25 16:58 ` Robin Murphy
  0 siblings, 2 replies; 3+ messages in thread
From: Sylvain Chouleur via B4 Relay @ 2026-11-25 16:15 UTC (permalink / raw)
  To: Robin Murphy, Will Deacon, Mark Rutland
  Cc: linux-arm-kernel, linux-perf-users, stable, Sylvain Chouleur

From: Sylvain Chouleur <schouleur@snap.com>

The X and Y coordinates in a CMN/CI-700 node ID are encoded in 2 bits
each for any mesh up to 4x4 (7-bit node IDs), and in 3 bits each for
larger meshes (9-bit node IDs). The width does not shrink for smaller
meshes: a 2x2 mesh still uses 2 bits per coordinate.

arm_cmn_xyidbits() derives the width from the actual mesh dimensions,
which yields 1 bit for a mesh with both dimensions <= 2. On such a
mesh arm_cmn_node_to_xp() then decodes every device on the X=1 column
into the wrong XP: X=1,Y=0 devices are attributed to XP (0,1), and
X=1,Y=1 devices to an index past the end of the XP array. Their PMU
events end up programmed into another XP's DTM, with the port/device
select of the intended XP, so the counters silently read zero while
the rest of the mesh works.

Observed on a CI-700 r3 with a 2x2 mesh (part 0x43a), where the SBSX
and HN-D nodes on the X=1 column never counted although the XP flit
counters showed the traffic. Forcing a minimum of 2 coordinate bits
matches the documented node ID format and makes all nodes count;
the minimum had been there until the node ID refactor dropped it.

Fixes: e79634b53e39 ("perf/arm-cmn: Refactor node ID handling. Again.")
Cc: stable@vger.kernel.org
Signed-off-by: Sylvain Chouleur <schouleur@snap.com>
---
 drivers/perf/arm-cmn.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c
index 68a096c1fe6b..5f369c7a7a35 100644
--- a/drivers/perf/arm-cmn.c
+++ b/drivers/perf/arm-cmn.c
@@ -406,7 +406,8 @@ struct arm_cmn_nodeid {
 
 static int arm_cmn_xyidbits(const struct arm_cmn *cmn)
 {
-	return fls((cmn->mesh_x - 1) | (cmn->mesh_y - 1));
+	/* Node IDs never use fewer than 2 bits per XP coordinate */
+	return fls((cmn->mesh_x - 1) | (cmn->mesh_y - 1) | 2);
 }
 
 static struct arm_cmn_nodeid arm_cmn_nid(const struct arm_cmn_node *dn)

---
base-commit: 4dce97c6c265544342e716e62fd24bbb232590c5
change-id: 20261125-arm-cmn-xyidbits-16076edf28a2

Best regards,
--  
Sylvain Chouleur <schouleur@snap.com>



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf/arm-cmn: Use at least 2 bits per XP coordinate in node IDs
  2026-11-25 16:15 [PATCH] perf/arm-cmn: Use at least 2 bits per XP coordinate in node IDs Sylvain Chouleur via B4 Relay
@ 2026-11-25 16:19 ` sashiko-bot
  2026-11-25 16:58 ` Robin Murphy
  1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-11-25 16:19 UTC (permalink / raw)
  To: Sylvain Chouleur; +Cc: linux-perf-users

> From: Sylvain Chouleur <schouleur@snap.com>
> 
> The X and Y coordinates in a CMN/CI-700 node ID are encoded in 2 bits
> each for any mesh up to 4x4 (7-bit node IDs), and in 3 bits each for
> larger meshes (9-bit node IDs). The width does not shrink for smaller
> meshes: a 2x2 mesh still uses 2 bits per coordinate.
> 
> arm_cmn_xyidbits() derives the width from the actual mesh dimensions,
> which yields 1 bit for a mesh with both dimensions <= 2. On such a
> mesh arm_cmn_node_to_xp() then decodes every device on the X=1 column
> into the wrong XP: X=1,Y=0 devices are attributed to XP (0,1), and
> X=1,Y=1 devices to an index past the end of the XP array. Their PMU
> events end up programmed into another XP's DTM, with the port/device
> select of the intended XP, so the counters silently read zero while
> the rest of the mesh works.
> 
> Observed on a CI-700 r3 with a 2x2 mesh (part 0x43a), where the SBSX
> and HN-D nodes on the X=1 column never counted although the XP flit
> counters showed the traffic. Forcing a minimum of 2 coordinate bits
> matches the documented node ID format and makes all nodes count;
> the minimum had been there until the node ID refactor dropped it.
> 
> Fixes: e79634b53e39 ("perf/arm-cmn: Refactor node ID handling. Again.")
> Cc: stable@vger.kernel.org
> Signed-off-by: Sylvain Chouleur <schouleur@snap.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261125-arm-cmn-xyidbits-v1-1-6f7bee891859@snap.com?part=1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf/arm-cmn: Use at least 2 bits per XP coordinate in node IDs
  2026-11-25 16:15 [PATCH] perf/arm-cmn: Use at least 2 bits per XP coordinate in node IDs Sylvain Chouleur via B4 Relay
  2026-11-25 16:19 ` sashiko-bot
@ 2026-11-25 16:58 ` Robin Murphy
  1 sibling, 0 replies; 3+ messages in thread
From: Robin Murphy @ 2026-11-25 16:58 UTC (permalink / raw)
  To: schouleur, Will Deacon, Mark Rutland
  Cc: linux-arm-kernel, linux-perf-users, stable

On 25/11/2026 4:15 pm, Sylvain Chouleur via B4 Relay wrote:
> From: Sylvain Chouleur <schouleur@snap.com>
> 
> The X and Y coordinates in a CMN/CI-700 node ID are encoded in 2 bits
> each for any mesh up to 4x4 (7-bit node IDs), and in 3 bits each for
> larger meshes (9-bit node IDs). The width does not shrink for smaller
> meshes: a 2x2 mesh still uses 2 bits per coordinate.
> 
> arm_cmn_xyidbits() derives the width from the actual mesh dimensions,
> which yields 1 bit for a mesh with both dimensions <= 2. On such a
> mesh arm_cmn_node_to_xp() then decodes every device on the X=1 column
> into the wrong XP: X=1,Y=0 devices are attributed to XP (0,1), and
> X=1,Y=1 devices to an index past the end of the XP array. Their PMU
> events end up programmed into another XP's DTM, with the port/device
> select of the intended XP, so the counters silently read zero while
> the rest of the mesh works.
> 
> Observed on a CI-700 r3 with a 2x2 mesh (part 0x43a), where the SBSX
> and HN-D nodes on the X=1 column never counted although the XP flit
> counters showed the traffic. Forcing a minimum of 2 coordinate bits
> matches the documented node ID format and makes all nodes count;
> the minimum had been there until the node ID refactor dropped it.

Oof, I guess it had slipped my mind that 2x2 configs are legal, but then 
come to think of it, for CI-700 I think 2x1 and 1x2 aren't illegal 
either. As far as I can remember there wasn't any reason for dropping 
the "| 2" term other than thinking it was a simplification we could get 
away with. Oops :(

FWIW I also can't see that it matters to go back to reporting 2 bits 
instead of 1 for 1x1 configs, where the "correct" value is arguably 0 
anyway.

Reviewed-by: Robin Murphy <robin.murphy@arm.com>

> Fixes: e79634b53e39 ("perf/arm-cmn: Refactor node ID handling. Again.")
> Cc: stable@vger.kernel.org
> Signed-off-by: Sylvain Chouleur <schouleur@snap.com>
> ---
>   drivers/perf/arm-cmn.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c
> index 68a096c1fe6b..5f369c7a7a35 100644
> --- a/drivers/perf/arm-cmn.c
> +++ b/drivers/perf/arm-cmn.c
> @@ -406,7 +406,8 @@ struct arm_cmn_nodeid {
>   
>   static int arm_cmn_xyidbits(const struct arm_cmn *cmn)
>   {
> -	return fls((cmn->mesh_x - 1) | (cmn->mesh_y - 1));
> +	/* Node IDs never use fewer than 2 bits per XP coordinate */
> +	return fls((cmn->mesh_x - 1) | (cmn->mesh_y - 1) | 2);
>   }
>   
>   static struct arm_cmn_nodeid arm_cmn_nid(const struct arm_cmn_node *dn)
> 
> ---
> base-commit: 4dce97c6c265544342e716e62fd24bbb232590c5
> change-id: 20261125-arm-cmn-xyidbits-16076edf28a2
> 
> Best regards,
> --
> Sylvain Chouleur <schouleur@snap.com>
> 
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-25 16:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 16:15 [PATCH] perf/arm-cmn: Use at least 2 bits per XP coordinate in node IDs Sylvain Chouleur via B4 Relay
2026-11-25 16:19 ` sashiko-bot
2026-11-25 16:58 ` Robin Murphy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox