Skip to content

tracing/arm: Fix the stack tracer when LR is saved after local storage

Steven Rostedt linux-arm-kernel lkml 2 versions In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 11 repliesIn review
  2. v12 patches 3 repliesSuperseded

Changes in v2 from the cover letter

- Fixed wrong value in stack_trace_index[] array in comment

- Added a comment about gcc currently saves the LR after local variables, but there's no guarantee that it will be like that in the future. (Notified of this by Mark Rutland)

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2tracing/arm64: Have max stack tracer handle the case of return address after dataarch/arm64/include/asm/ftrace.h kernel/trace/trace_stack.c+27 -010 replies
2/2tracing: Document the stack trace algorithm in the commentskernel/trace/trace_stack.c+98 -01 reply

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchWill DeaconJoel Fernandes (Google)Mark Rutland
1/2A-b A-b A-b
2/2A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v2 thread

Cover letter [PATCH 0/2 v2] tracing/arm: Fix the stack tracer when LR is saved after local storage

As arm64 saves the link register after a function's local variables are stored, it causes the max stack tracer to be off by one in its output of which function has the bloated stack frame.

The first patch fixes this by creating a ARCH_RET_ADDR_BEFORE_LOCAL_VARS define that an achitecture (arm64) may set in asm/ftrace.h, and this will cause the stack tracer to make the shift.

As it has been proven that the stack tracer isn't the most trivial algorithm to understand by staring at the code, the second patch adds comments to the code to explain the algorithm with and without the ARCH_RET_ADDR_BEFORE_LOCAL_VARS.

Hmm, should this be sent to stable (and for inclusion now?)

-- Steve

Changes since v1:

- Fixed wrong value in stack_trace_index[] array in comment

- Added a comment about gcc currently saves the LR after local variables, but there's no guarantee that it will be like that in the future. (Notified of this by Mark Rutland)

Steven Rostedt (VMware) (2):
tracing/arm64: Have max stack tracer handle the case of return address after data
tracing: Document the stack trace algorithm in the comments

----

 arch/arm64/include/asm/ftrace.h |  13 +++++
 kernel/trace/trace_stack.c      | 112 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 125 insertions(+)