[PATCH v6 6/8] perf cs-etm: Filter synthesized branch samples

James Clark james.clark at linaro.org
Mon Jun 8 05:35:24 PDT 2026



On 08/06/2026 12:28 pm, Leo Yan wrote:
> On Thu, Jun 04, 2026 at 03:42:32PM +0100, James Clark wrote:
> 
> [...]
> 
>>> @@ -3442,6 +3447,16 @@ int cs_etm__process_auxtrace_info_full(union perf_event *event,
>>>    		etm->synth_opts.thread_stack = session->itrace_synth_opts->thread_stack;
>>>    	}
>>> +	if (etm->synth_opts.calls)
>>> +		etm->branches_filter |= PERF_IP_FLAG_CALL |
>>> +					PERF_IP_FLAG_TRACE_BEGIN |
>>> +					PERF_IP_FLAG_TRACE_END;
>>> +
>>> +	if (etm->synth_opts.returns)
>>> +		etm->branches_filter |= PERF_IP_FLAG_RETURN |
>>> +					PERF_IP_FLAG_TRACE_BEGIN |
>>> +					PERF_IP_FLAG_TRACE_END;
>>> +
>>
>> This changes the default "perf script" output quite significantly and will
>> possibly break people's workflows. synth_opts.calls is true by default but
>> synth_opts.returns is false so we lose all the returns that we used to have.
>> Not sure if the new behavior is more consistent with other tools so we can
>> justify changing it? Personally I think including returns by default made
>> more sense, and it's a more literal representation of the flow.
> 
> Makes sense. I will add below chunk to enable return events for default
> option:
> 
> diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
> index ab3aa76dddb3..bd9eb794cc07 100644
> --- a/tools/perf/util/cs-etm.c
> +++ b/tools/perf/util/cs-etm.c
> @@ -3541,6 +3541,14 @@ int cs_etm__process_auxtrace_info_full(union perf_event *event,
>                                  session->itrace_synth_opts->default_no_sample);
>                  etm->synth_opts.callchain = false;
>                  etm->synth_opts.thread_stack = session->itrace_synth_opts->thread_stack;
> +
> +               /*
> +                * By default, only call events are enabled but no return
> +                * events. Enable return events to better represent the
> +                * execution flow.
> +                */
> +               if (etm->synth_opts.calls)
> +                       etm->synth_opts.returns = true;
>          }
> 
>>
>> itrace.txt says the default is "all events i.e. the same as
>> --itrace=iybxwpe", but I thought the default was branches? At least for
>> Coresight it is, so I'm a bit confused.
> 
> "--itrace=iybxwpe" would be used for "perf report" command, the doc also
> mentions "--itrace=ce" for "perf script" specific.
> 
> Thanks,
> Leo

Ah I missed that. In that case maybe it makes sense to break it and 
treat it as a bug fix. 'c' is quite clearly documented as calls only, 
and the workaround you suggested above makes it impossible to get only 
calls so it makes separate options for call and return a bit useless.




More information about the linux-arm-kernel mailing list