[PATCH v2] perf arm_spe: Add a macro definition to handle offset value

Leo Yan leo.yan at arm.com
Fri Oct 24 01:10:29 PDT 2025


On Fri, Oct 24, 2025 at 09:27:25AM +0300, Adrian Hunter wrote:

[...]

> > --- a/tools/perf/util/arm-spe.c
> > +++ b/tools/perf/util/arm-spe.c
> > @@ -1732,7 +1732,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session)
> >  	attr.sample_period = spe->synth_opts.period;
> >  
> >  	/* create new id val to be a fixed offset from evsel id */
> > -	id = evsel->core.id[0] + 1000000000;
> > +	id = evsel->core.id[0] + PERF_SYNTH_EVENT_ID_OFFSET;
> >  
> >  	if (!id)
> >  		id = 1;
> 
> Functionally this is to find a free range of IDs for synthesized events,
> but also the range can only have one user e.g. in this case auxtrace
> 
> So add to auxtrace.c
> 
> #define AUXTRACE_SYNTH_EVENT_ID_OFFSET	1000000000ULL
> 
> /*
>  * Event IDs are allocated sequentially, so a big offset from any
>  * existing ID will reach a unused range.
>  */
> u64 auxtrace_synth_id_range_start(struct evsel *evsel)
> {
> 	u64 id = evsel->core.id[0] + AUXTRACE_SYNTH_EVENT_ID_OFFSET;
> 
>   	if (!id)
>   		id = 1;
> 
> 	return id;
> }
> 
> And then use that:
> 
> - 	/* create new id val to be a fixed offset from evsel id */
> -	id = evsel->core.id[0] + 1000000000;
> +	id = auxtrace_synth_id_range_start(evsel);
> -
> -	if (!id)
> -		id = 1;

Agreed, much better than I suggested!

Just remind updating subject as well, like:

  perf auxtrace: Refactor AUX event ID calculation
  perf auxtrace: Add auxtrace_synth_id_range_start() helper

Thanks,
Leo



More information about the linux-arm-kernel mailing list