[PATCH 2/3] perf cs-etm: Use the packet instruction size for stack events

James Clark james.clark at linaro.org
Thu Nov 26 05:53:13 PST 2026



On 13/11/2026 10:54, Leo Yan wrote:
> cs_etm__add_stack_event() uses the last executed instruction of the
> previous packet as the branch source. The decoder already records this
> instruction's size in last_instr_size, including for T32 instructions.
> 
> Use the recorded size directly instead of reading instruction memory
> again. This removes an unnecessary read and the dependency on DSO data
> when updating the thread stack.
> 
> Signed-off-by: Leo Yan <leo.yan at arm.com>
> ---
>   tools/perf/util/cs-etm.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
> index 25f12bd110934a204d79244f45317085b7a81666..312d4a734e84faa0d24c4ac1fee16f4dae4c2398 100644
> --- a/tools/perf/util/cs-etm.c
> +++ b/tools/perf/util/cs-etm.c
> @@ -1626,7 +1626,6 @@ static void cs_etm__add_stack_event(struct cs_etm_queue *etmq,
>   {
>   	struct cs_etm_auxtrace *etm = etmq->etm;
>   	u64 from, to;
> -	int size;
>   
>   	if (!etm->synth_opts.branches && !etm->synth_opts.instructions)
>   		return;
> @@ -1638,11 +1637,10 @@ static void cs_etm__add_stack_event(struct cs_etm_queue *etmq,
>   		from = cs_etm__last_executed_instr(tidq->prev_packet);
>   		to = cs_etm__first_executed_instr(tidq->packet);
>   
> -		size = cs_etm__instr_size(etmq, tidq, tidq->prev_packet, from);
> -
>   		/* Enable callchain so thread stack entry can be allocated */
>   		thread_stack__event(tidq->frontend_thread, tidq->prev_packet->cpu,
> -				    tidq->prev_packet->flags, from, to, size,
> +				    tidq->prev_packet->flags, from, to,
> +				    tidq->prev_packet->last_instr_size,
>   				    etmq->buffer->buffer_nr + 1,
>   				    etmq->etm->use_callchain,
>   				    tidq->br_stack_sz, 0);
> 

Reviewed-by: James Clark <james.clark at linaro.org>



More information about the linux-arm-kernel mailing list