linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/11 v2] ftrace: Have callbacks handle their own recursion
@ 2020-10-30 21:31 Steven Rostedt
  2020-10-30 21:31 ` [PATCH 01/11 v2] ftrace: Move the recursion testing into global headers Steven Rostedt
                   ` (10 more replies)
  0 siblings, 11 replies; 27+ messages in thread
From: Steven Rostedt @ 2020-10-30 21:31 UTC (permalink / raw)
  To: linux-kernel
  Cc: Masami Hiramatsu, Andrew Morton, Peter Zijlstra, Ingo Molnar,
	Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Petr Mladek

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 v1:

 - Reworded the paragraph that talks about the ftrace_ops default recursion
   in the change logs so that it makes more sense (recommend by Petr Mladek)

 - Rebased on fixes that will be sent upstream as soon as my testing is
   complete, that fixes the recursion logic. NMIs no longer trigger
   false recursion positives, and also logic to handle transitions
   between context that also causes false positives. These fixes are
   not part of this series, but will be added before these patches.

 - Added code to create a "recursed_functions" file in tracefs, that
   lists the functions that triggered recursion. This was how I detected
   the bugs from before. If you enable CONFIG_FTRACE_RECORD_RECURSION
   it will add this logic. If you also enable FTRACE_STARTUP_TEST,
   one of the tests triggers a recursion, and this will be shown in
   the file after boot up (to test if it actually works).

  # cat recursed_functions
  ftrace_ops_assist_func+0x84/0x160:	trace_selftest_dynamic_test_func+0x0/0x10

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           |  13 +-
 arch/powerpc/kernel/kprobes-ftrace.c  |  11 +-
 arch/s390/kernel/ftrace.c             |  13 +-
 arch/x86/kernel/kprobes/ftrace.c      |  12 +-
 fs/pstore/ftrace.c                    |   6 +
 include/linux/ftrace.h                |  13 +-
 include/linux/trace_recursion.h       | 243 ++++++++++++++++++++++++++++++++++
 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 | 220 ++++++++++++++++++++++++++++++
 kernel/trace/trace_selftest.c         |   7 +-
 kernel/trace/trace_stack.c            |   1 -
 23 files changed, 656 insertions(+), 249 deletions(-)
 create mode 100644 include/linux/trace_recursion.h
 create mode 100644 kernel/trace/trace_recursion_record.c

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2020-11-04 19:13 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-30 21:31 [PATCH 00/11 v2] ftrace: Have callbacks handle their own recursion Steven Rostedt
2020-10-30 21:31 ` [PATCH 01/11 v2] ftrace: Move the recursion testing into global headers Steven Rostedt
2020-10-30 21:31 ` [PATCH 02/11 v2] ftrace: Add ftrace_test_recursion_trylock() helper function Steven Rostedt
2020-10-30 21:31 ` [PATCH 03/11 v2] ftrace: Optimize testing what context current is in Steven Rostedt
2020-10-30 21:31 ` [PATCH 04/11 v2] pstore/ftrace: Add recursion protection to the ftrace callback Steven Rostedt
2020-10-30 21:31 ` [PATCH 05/11 v2] kprobes/ftrace: " Steven Rostedt
2020-11-03 11:22   ` Masami Hiramatsu
2020-11-04 18:46     ` [PATCH 05/11 v2.1] " Steven Rostedt
2020-10-30 21:31 ` [PATCH 06/11 v2] livepatch/ftrace: " Steven Rostedt
2020-10-30 21:31 ` [PATCH 07/11 v2] livepatch: Trigger WARNING if livepatch function fails due to recursion Steven Rostedt
2020-11-02 14:41   ` Petr Mladek
2020-11-02 16:56     ` Steven Rostedt
2020-10-30 21:31 ` [PATCH 08/11 v2] perf/ftrace: Add recursion protection to the ftrace callback Steven Rostedt
2020-10-30 21:31 ` [PATCH 09/11 v2] perf/ftrace: Check for rcu_is_watching() in callback function Steven Rostedt
2020-10-30 21:31 ` [PATCH 10/11 v2] ftrace: Reverse what the RECURSION flag means in the ftrace_ops Steven Rostedt
2020-10-30 21:31 ` [PATCH 11/11 v2] ftrace: Add recording of functions that caused recursion Steven Rostedt
2020-11-02 16:41   ` Petr Mladek
2020-11-02 17:09     ` Steven Rostedt
2020-11-02 17:19       ` Steven Rostedt
2020-11-03 10:40       ` Petr Mladek
2020-11-02 17:37     ` Steven Rostedt
2020-11-02 17:46       ` Steven Rostedt
2020-11-02 19:23         ` [PATCH 11/11 v2.2] " Steven Rostedt
2020-11-03 14:10           ` Petr Mladek
2020-11-03 16:14             ` Steven Rostedt
2020-11-04 19:13             ` Steven Rostedt
2020-11-02 19:14       ` [PATCH 11/11 v2.1] " Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).