* [PATCH] perf/arm-cmn: Terminate the discovered node array
@ 2026-12-04 15:47 Leo Yan
2026-12-04 16:28 ` Robin Murphy
0 siblings, 1 reply; 3+ messages in thread
From: Leo Yan @ 2026-12-04 15:47 UTC (permalink / raw)
To: Robin Murphy, Will Deacon, Mark Rutland
Cc: linux-arm-kernel, linux-perf-users, Leo Yan
Discovery writes a child's type into the next free entry before deciding
whether to keep it. If the last type written belongs to a skipped child,
the entry retains a nonzero type, so node walks can run past the end of
the array.
Reset the type to CMN_TYPE_INVALID when discarding a child without
supported PMU events. This restores the zero type that terminates the
array.
Fixes: da5f7d2c8019 ("perf/arm-cmn: Streamline node iteration")
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
drivers/perf/arm-cmn.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c
index 68a096c1fe6b0be793fba9a9461905e67d2d7703..5fe31310c5feb0b4b96022e7ec1d478720db792c 100644
--- a/drivers/perf/arm-cmn.c
+++ b/drivers/perf/arm-cmn.c
@@ -2751,6 +2751,8 @@ static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset)
case CMN_TYPE_HNS_MPAM_S:
case CMN_TYPE_HNS_MPAM_NS:
case CMN_TYPE_APB:
+ /* This entry may be the array terminator */
+ dn->type = CMN_TYPE_INVALID;
break;
/*
* Split "optimised" combination nodes into separate
---
base-commit: 007722b8211f7b34fdf21b1e6a9c32497633ea29
change-id: 20261204-b4-arm_cmn_fix_node_sentinel-40b54e3a9ff0
Best regards,
--
Leo Yan <leo.yan@arm.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] perf/arm-cmn: Terminate the discovered node array
2026-12-04 15:47 [PATCH] perf/arm-cmn: Terminate the discovered node array Leo Yan
@ 2026-12-04 16:28 ` Robin Murphy
2026-12-04 16:46 ` Leo Yan
0 siblings, 1 reply; 3+ messages in thread
From: Robin Murphy @ 2026-12-04 16:28 UTC (permalink / raw)
To: Leo Yan, Will Deacon, Mark Rutland; +Cc: linux-arm-kernel, linux-perf-users
On 04/12/2026 3:47 pm, Leo Yan wrote:
> Discovery writes a child's type into the next free entry before deciding
> whether to keep it. If the last type written belongs to a skipped child,
> the entry retains a nonzero type, so node walks can run past the end of
> the array.
Oooh, subtle... :(
> Reset the type to CMN_TYPE_INVALID when discarding a child without
> supported PMU events. This restores the zero type that terminates the
> array.
I think I'd rather just explicitly clear the sentinel element after the
realloc "adds" it, that seems even more robust and obvious.
Thanks,
Robin.
> Fixes: da5f7d2c8019 ("perf/arm-cmn: Streamline node iteration")
> Signed-off-by: Leo Yan <leo.yan@arm.com>
> ---
> drivers/perf/arm-cmn.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c
> index 68a096c1fe6b0be793fba9a9461905e67d2d7703..5fe31310c5feb0b4b96022e7ec1d478720db792c 100644
> --- a/drivers/perf/arm-cmn.c
> +++ b/drivers/perf/arm-cmn.c
> @@ -2751,6 +2751,8 @@ static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset)
> case CMN_TYPE_HNS_MPAM_S:
> case CMN_TYPE_HNS_MPAM_NS:
> case CMN_TYPE_APB:
> + /* This entry may be the array terminator */
> + dn->type = CMN_TYPE_INVALID;
> break;
> /*
> * Split "optimised" combination nodes into separate
>
> ---
> base-commit: 007722b8211f7b34fdf21b1e6a9c32497633ea29
> change-id: 20261204-b4-arm_cmn_fix_node_sentinel-40b54e3a9ff0
>
> Best regards,
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] perf/arm-cmn: Terminate the discovered node array
2026-12-04 16:28 ` Robin Murphy
@ 2026-12-04 16:46 ` Leo Yan
0 siblings, 0 replies; 3+ messages in thread
From: Leo Yan @ 2026-12-04 16:46 UTC (permalink / raw)
To: Robin Murphy
Cc: Will Deacon, Mark Rutland, linux-arm-kernel, linux-perf-users
On Fri, Dec 04, 2026 at 04:28:38PM +0000, Robin Murphy wrote:
[...]
> > Reset the type to CMN_TYPE_INVALID when discarding a child without
> > supported PMU events. This restores the zero type that terminates the
> > array.
>
> I think I'd rather just explicitly clear the sentinel element after the
> realloc "adds" it, that seems even more robust and obvious.
Will do, thanks for review!
Leo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-04 16:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 15:47 [PATCH] perf/arm-cmn: Terminate the discovered node array Leo Yan
2026-12-04 16:28 ` Robin Murphy
2026-12-04 16:46 ` Leo Yan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox