Skip to content

RFC stacktrace: Avoid the pointless redirection through struct stack_trace

Thomas Gleixner dm-devel dri-devel intel-gfx linux-arm-kernel linux-btrfs linux-iommu linux-mm linux-parisc linux-riscv linux-s390 linux-sh linux-um lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest41 patches 30 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/41um/stacktrace: Remove the pointless ULONG_MAX markerarch/um/kernel/stacktrace.c+0 -20 replies
2/41x86/stacktrace: Remove the pointless ULONG_MAX markerarch/x86/kernel/stacktrace.c+2 -120 replies
3/41arm/stacktrace: Remove the pointless ULONG_MAX markerarch/arm/kernel/stacktrace.c+0 -60 replies
4/41sh/stacktrace: Remove the pointless ULONG_MAX markerarch/sh/kernel/stacktrace.c+0 -40 replies
5/41unicore32/stacktrace: Remove the pointless ULONG_MAX markerarch/unicore32/kernel/stacktrace.c+0 -20 replies
6/41riscv/stacktrace: Remove the pointless ULONG_MAX markerarch/riscv/kernel/stacktrace.c+0 -20 replies
7/41arm64/stacktrace: Remove the pointless ULONG_MAX markerarch/arm64/kernel/stacktrace.c+0 -40 replies
8/41parisc/stacktrace: Remove the pointless ULONG_MAX markerarch/parisc/kernel/stacktrace.c+0 -50 replies
9/41s390/stacktrace: Remove the pointless ULONG_MAX markerarch/s390/kernel/stacktrace.c+0 -60 replies
10/41lockdep: Remove the ULONG_MAX stack trace hackerykernel/locking/lockdep.c+0 -110 replies
11/41mm/slub: Remove the ULONG_MAX stack trace hackerymm/slub.c+4 -90 replies
12/41mm/page_owner: Remove the ULONG_MAX stack trace hackerymm/page_owner.c+0 -30 replies
13/41mm/kasan: Remove the ULONG_MAX stack trace hackerymm/kasan/common.c+0 -31 reply
14/41latency_top: Remove the ULONG_MAX stack trace hackeryfs/proc/base.c kernel/latencytop.c+7 -80 replies
15/41drm: Remove the ULONG_MAX stack trace hackerydrivers/gpu/drm/drm_mm.c drivers/gpu/drm/i915/intel_runtime_pm.c+0 -70 replies
16/41tracing: Remove the ULONG_MAX stack trace hackerykernel/trace/trace_events_hist.c kernel/trace/trace_stack.c+6 -162 replies
17/41tracing: Make stack_trace_print() static and rename itinclude/linux/ftrace.h kernel/trace/trace_stack.c+2 -32 replies
18/41stacktrace: Provide helpers for common stack trace operationsinclude/linux/stacktrace.h kernel/stacktrace.c+140 -150 replies
19/41lib/stackdepot: Provide functions which operate on plain storage arraysinclude/linux/stackdepot.h lib/stackdepot.c+51 -191 reply
20/41backtrace-test: Simplify stack trace handlingkernel/backtracetest.c+3 -81 reply
21/41proc: Simplify task stack retrievalfs/proc/base.c+5 -101 reply
22/41latency_top: Simplify stack trace handlingkernel/latencytop.c+2 -150 replies
23/41mm/slub: Simplify stack trace retrievalmm/slub.c+4 -80 replies
24/41mm/kmemleak: Simplify stacktrace handlingmm/kmemleak.c+3 -210 replies
25/41mm/kasan: Simplify stacktrace handlingmm/kasan/common.c mm/kasan/report.c+16 -214 replies
26/41mm/page_owner: Simplify stack trace handlingmm/page_owner.c+28 -510 replies
27/41fault-inject: Simplify stacktrace retrievallib/fault-inject.c+3 -90 replies
28/41dma/debug: Simplify stracktrace retrievalkernel/dma/debug.c+5 -88 replies
29/41btrfs: ref-verify: Simplify stack trace retrievalfs/btrfs/ref-verify.c+2 -135 replies
30/41dm bufio: Simplify stack trace retrievaldrivers/md/dm-bufio.c+6 -90 replies
31/41dm persistent data: Simplify stack trace handlingdrivers/md/persistent-data/dm-block-manager.c+9 -100 replies
32/41drm: Simplify stacktrace handlingdrivers/gpu/drm/drm_mm.c drivers/gpu/drm/i915/i915_vma.c drivers/gpu/drm/i915/intel_runtime_pm.c+18 -360 replies
33/41lockdep: Remove unused trace argument from print_circular_bug()kernel/locking/lockdep.c+4 -50 replies
34/41lockdep: Move stack trace logic into check_prev_add()kernel/locking/lockdep.c+8 -220 replies
35/41lockdep: Simplify stack trace handlinginclude/linux/lockdep.h kernel/locking/lockdep.c+27 -210 replies
36/41tracing: Simplify stacktrace retrieval in histogramskernel/trace/trace_events_hist.c+3 -90 replies
37/41tracing: Use percpu stack trace buffer more intelligentlykernel/trace/trace.c+39 -380 replies
38/41tracing: Make ftrace_trace_userstack() static and conditionalkernel/trace/trace.c kernel/trace/trace.h+8 -140 replies
39/41tracing: Simplify stack trace retrievalkernel/trace/trace.c+9 -250 replies
40/41stacktrace: Remove obsolete functionsinclude/linux/stacktrace.h kernel/stacktrace.c+16 -443 replies
41/41lib/stackdepot: Remove obsolete functionsinclude/linux/stackdepot.h lib/stackdepot.c+0 -241 reply

Reviews trailers per patch

6 of 41 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchDmitry VyukovPeter Zijlstra (Intel)Johannes ThumshirnDavid SterbaAlexander PotapenkoAlexey Dobriyan
SeriesA-b
1/41
2/41
3/41
4/41
5/41
6/41
7/41
8/41
9/41
10/41
11/41
12/41
13/41A-b
14/41
15/41
16/41
17/41
18/41
19/41A-b
20/41
21/41R-b
22/41
23/41
24/41
25/41A-b
26/41
27/41
28/41
29/41R-b A-b
30/41
31/41
32/41
33/41
34/41
35/41
36/41
37/41
38/41
39/41
40/41
41/41A-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 6 reviewers.

Read the v1 thread

Cover letter [RFC patch 00/41] stacktrace: Avoid the pointless redirection through struct stack_trace

Struct stack_trace is a sinkhole for input and output parameters which is largely pointless for most usage sites. In fact if embedded into other data structures it creates indirections and extra storage overhead for no benefit.

Looking at all usage sites makes it clear that they just require an interface which is based on a storage array. That array is either on stack, global or embedded into some other data structure.

Some of the stack depot usage sites are outright wrong, but fortunately the wrongness just causes more stack being used for nothing and does not have functional impact.

Another oddity is the inconsistent termination of the stack trace with ULONG_MAX. It's pointless as the number of entries is what determines the length of the stored trace. In fact quite some call sites remove the ULONG_MAX marker afterwards with or without nasty comments about it. Not all architectures do that and those which do, do it inconsistenly either conditional on nr_entries == 0 or unconditionally.

The following series cleans that up by:

1) Removing the ULONG_MAX termination in the architecture code

2) Removing the ULONG_MAX fixups at the call sites

3) Providing plain storage array based interfaces for stacktrace and stackdepot.

4) Cleaning up the mess at the callsites including some related cleanups.

5) Removing the struct stack_trace based interfaces

This is not changing the struct stack_trace interfaces at the architecture level, but it removes the exposure to the generic code.

It's only lightly tested as I'm traveling and access to my test boxes is limited.

Thanks,

tglx

8<-----------------

 arch/um/kernel/stacktrace.c                   |    2 
 b/arch/arm/kernel/stacktrace.c                |    6 -
 b/arch/arm64/kernel/stacktrace.c              |    4 
 b/arch/parisc/kernel/stacktrace.c             |    5 -
 b/arch/riscv/kernel/stacktrace.c              |    2 
 b/arch/s390/kernel/stacktrace.c               |    6 -
 b/arch/sh/kernel/stacktrace.c                 |    4 
 b/arch/unicore32/kernel/stacktrace.c          |    2 
 b/arch/x86/kernel/stacktrace.c                |   14 --
 drivers/gpu/drm/drm_mm.c                      |   27 +----
 drivers/gpu/drm/i915/i915_vma.c               |   11 --
 drivers/gpu/drm/i915/intel_runtime_pm.c       |   25 +----
 drivers/md/dm-bufio.c                         |   15 +--
 drivers/md/persistent-data/dm-block-manager.c |   19 +--
 fs/btrfs/ref-verify.c                         |   15 ---
 fs/proc/base.c                                |   18 +--
 include/linux/ftrace.h                        |    1 
 include/linux/lockdep.h                       |    9 +
 include/linux/stackdepot.h                    |    8 -
 include/linux/stacktrace.h                    |   40 ++++----
 kernel/backtracetest.c                        |   11 --
 kernel/dma/debug.c                            |   13 +-
 kernel/latencytop.c                           |   29 +----
 kernel/locking/lockdep.c                      |   87 ++++++-----------
 kernel/stacktrace.c                           |  127 ++++++++++++++++++++++----
 kernel/trace/trace.c                          |  103 +++++++++------------
 kernel/trace/trace.h                          |    8 -
 kernel/trace/trace_events_hist.c              |   14 --
 kernel/trace/trace_stack.c                    |   24 +---
 lib/fault-inject.c                            |   12 --
 lib/stackdepot.c                              |   50 +++++-----
 mm/kasan/common.c                             |   33 ++----
 mm/kasan/report.c                             |    7 -
 mm/kmemleak.c                                 |   24 ----
 mm/page_owner.c                               |   82 +++++-----------
 mm/slub.c                                     |   21 +---
 36 files changed, 375 insertions(+), 503 deletions(-)