Skip to content

ftrace: Have callbacks handle their own recursion

Steven Rostedt (VMware) linux-csky linux-doc linux-parisc linux-s390 linuxppc-dev live-patching lkml 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest11 patches 8 repliesIn review
  2. v211 patches 12 repliesSuperseded
  3. v19 patches 14 repliesSuperseded

Changes in v3 from the cover letter

- Move get_kprobe() into preempt disabled sections for various archs
- Use trace_recursion flags in current for protecting recursion of recursion recording
- Make the recursion logic a little cleaner
- Export GPL the recursion recording

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/11ftrace: Move the recursion testing into global headersinclude/linux/ftrace.h include/linux/trace_recursion.h kernel/trace/trace.h+188 -1770 replies
2/11ftrace: Add ftrace_test_recursion_trylock() helper functioninclude/linux/trace_recursion.h kernel/trace/trace_functions.c+30 -70 replies
3/11ftrace: Optimize testing what context current is ininclude/linux/trace_recursion.h+20 -132 replies
4/11pstore/ftrace: Add recursion protection to the ftrace callbackfs/pstore/ftrace.c+6 -00 replies
5/11kprobes/ftrace: Add recursion protection to the ftrace callbackarch/csky/kernel/probes/ftrace.c arch/parisc/kernel/ftrace.c arch/powerpc/kernel/kprobes-ftrace.c +2 more+56 -111 reply
6/11livepatch/ftrace: Add recursion protection to the ftrace callbackkernel/livepatch/patch.c+5 -01 reply
7/11livepatch: Trigger WARNING if livepatch function fails due to recursionkernel/livepatch/patch.c+1 -11 reply
8/11perf/ftrace: Add recursion protection to the ftrace callbackkernel/trace/trace_event_perf.c+8 -10 replies
9/11perf/ftrace: Check for rcu_is_watching() in callback functionkernel/trace/trace_event_perf.c+3 -10 replies
10/11ftrace: Reverse what the RECURSION flag means in the ftrace_opsDocumentation/trace/ftrace-uses.rst include/linux/ftrace.h kernel/trace/fgraph.c +5 more+79 -490 replies
11/11ftrace: Add recording of functions that caused recursionDocumentation/trace/ftrace-uses.rst arch/csky/kernel/probes/ftrace.c arch/parisc/kernel/ftrace.c +14 more+306 -203 replies

Reviews trailers per patch

4 of 11 patches have a Reviewed-by or Acked-by.

PatchPetr MladekKees CookMiroslav BenesMasami Hiramatsu
1/11
2/11
3/11
4/11R-b
5/11A-b
6/11R-b A-b
7/11R-b A-b
8/11
9/11
10/11
11/11

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

Read the v3 thread

Cover letter [PATCH 00/11 v3] ftrace: Have callbacks handle their own recursion

I found that having the ftrace infrastructure use its own trampoline to handle recursion and RCU by defaulte unless the ftrace_ops set the appropriate flags, was an issue that nobody set those flags. But then their callbacks would suffer from an unnecessary overhead instead of simply handling the recursion itself.

This series makes it mandatory that ftrace callbacks handle recursion or set a flag asking ftrace to do it for it. It also creates helper functions to help these callbacks to have recursion protection.

Changes since v2:

- Move get_kprobe() into preempt disabled sections for various archs
- Use trace_recursion flags in current for protecting recursion of recursion recording
- Make the recursion logic a little cleaner
- Export GPL the recursion recording

Steven Rostedt (VMware) (11):
ftrace: Move the recursion testing into global headers
ftrace: Add ftrace_test_recursion_trylock() helper function
ftrace: Optimize testing what context current is in pstore/ftrace: Add recursion protection to the ftrace callback kprobes/ftrace: Add recursion protection to the ftrace callback livepatch/ftrace: Add recursion protection to the ftrace callback
livepatch: Trigger WARNING if livepatch function fails due to recursion perf/ftrace: Add recursion protection to the ftrace callback perf/ftrace: Check for rcu_is_watching() in callback function
ftrace: Reverse what the RECURSION flag means in the ftrace_ops
ftrace: Add recording of functions that caused recursion

----

 Documentation/trace/ftrace-uses.rst   |  84 ++++++++----
 arch/csky/kernel/probes/ftrace.c      |  12 +-
 arch/parisc/kernel/ftrace.c           |  16 ++-
 arch/powerpc/kernel/kprobes-ftrace.c  |  11 +-
 arch/s390/kernel/ftrace.c             |  16 ++-
 arch/x86/kernel/kprobes/ftrace.c      |  12 +-
 fs/pstore/ftrace.c                    |   6 +
 include/linux/ftrace.h                |  13 +-
 include/linux/trace_recursion.h       | 240 ++++++++++++++++++++++++++++++++++
 kernel/livepatch/patch.c              |   5 +
 kernel/trace/Kconfig                  |  25 ++++
 kernel/trace/Makefile                 |   1 +
 kernel/trace/fgraph.c                 |   3 +-
 kernel/trace/ftrace.c                 |  24 ++--
 kernel/trace/trace.h                  | 177 -------------------------
 kernel/trace/trace_event_perf.c       |  13 +-
 kernel/trace/trace_events.c           |   1 -
 kernel/trace/trace_functions.c        |  14 +-
 kernel/trace/trace_output.c           |   6 +-
 kernel/trace/trace_output.h           |   1 +
 kernel/trace/trace_recursion_record.c | 236 +++++++++++++++++++++++++++++++++
 kernel/trace/trace_selftest.c         |   7 +-
 kernel/trace/trace_stack.c            |   1 -
 23 files changed, 673 insertions(+), 251 deletions(-)
 create mode 100644 include/linux/trace_recursion.h
 create mode 100644 kernel/trace/trace_recursion_record.c