linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] kretprobe: produce sane stack traces
@ 2018-11-01  8:35 Aleksa Sarai
  2018-11-01  8:35 ` [PATCH v3 1/2] " Aleksa Sarai
  2018-11-01  8:35 ` [PATCH v3 2/2] trace: remove kretprobed checks Aleksa Sarai
  0 siblings, 2 replies; 35+ messages in thread
From: Aleksa Sarai @ 2018-11-01  8:35 UTC (permalink / raw)
  To: Naveen N. Rao, Anil S Keshavamurthy, David S. Miller,
	Masami Hiramatsu, Jonathan Corbet, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, Steven Rostedt, Shuah Khan, Alexei Starovoitov,
	Daniel Borkmann
  Cc: Aleksa Sarai, Aleksa Sarai, Christian Brauner, Brendan Gregg,
	netdev, linux-doc, linux-kernel, linux-kselftest

Historically, kretprobe has always produced unusable stack traces
(kretprobe_trampoline is the only entry in most cases, because of the
funky stack pointer overwriting). This has caused quite a few annoyances
when using tracing to debug problems[1] -- since return values are only
available with kretprobes but stack traces were only usable for kprobes,
users had to probe both and then manually associate them.

This patch series stores the stack trace within kretprobe_instance on
the kprobe entry used to set up the kretprobe. This allows for
DTrace-style stack aggregation between function entry and exit with
tools like BPFtrace -- which would not really be doable if the stack
unwinder understood kretprobe_trampoline.

We also revert commit 76094a2cf46e ("ftrace: distinguish kretprobe'd
functions in trace logs") and any follow-up changes because that code is
no longer necessary now that stack traces are sane. *However* this patch
might be a bit contentious since the original usecase (that ftrace
returns shouldn't show kretprobe_trampoline) is arguably still an
issue. Feel free to drop it if you think it is wrong.

Patch changelog:
 v3:
   * kprobe: fix build on !CONFIG_KPROBES
 v2:
   * documentation: mention kretprobe stack-stashing
   * ftrace: add self-test for fixed kretprobe stacktraces
   * ftrace: remove [unknown/kretprobe'd] handling
   * kprobe: remove needless EXPORT statements
   * kprobe: minor corrections to current_kretprobe_instance (switch
     away from hlist_for_each_entry_safe)
   * kprobe: make maximum stack size 127, which is the ftrace default

Aleksa Sarai (2):
  kretprobe: produce sane stack traces
  trace: remove kretprobed checks

 Documentation/kprobes.txt                     |   6 +-
 include/linux/kprobes.h                       |  27 +++++
 kernel/events/callchain.c                     |   8 +-
 kernel/kprobes.c                              | 101 +++++++++++++++++-
 kernel/trace/trace.c                          |  11 +-
 kernel/trace/trace_output.c                   |  34 +-----
 .../test.d/kprobe/kretprobe_stacktrace.tc     |  25 +++++
 7 files changed, 177 insertions(+), 35 deletions(-)
 create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_stacktrace.tc

-- 
2.19.1


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

end of thread, other threads:[~2018-11-12 10:36 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-01  8:35 [PATCH v3 0/2] kretprobe: produce sane stack traces Aleksa Sarai
2018-11-01  8:35 ` [PATCH v3 1/2] " Aleksa Sarai
2018-11-01 15:20   ` Masami Hiramatsu
2018-11-01 21:13     ` Aleksa Sarai
2018-11-02  3:04       ` Masami Hiramatsu
2018-11-02  4:37         ` Aleksa Sarai
2018-11-03 12:47           ` Masami Hiramatsu
2018-11-02  0:47   ` Steven Rostedt
2018-11-02  5:05     ` Aleksa Sarai
2018-11-02  6:59       ` Aleksa Sarai
2018-11-02 13:16         ` Steven Rostedt
2018-11-02 15:43           ` Josh Poimboeuf
2018-11-02 16:13             ` Steven Rostedt
2018-11-03 13:00               ` Masami Hiramatsu
2018-11-03 13:13                 ` Steven Rostedt
2018-11-03 16:34                   ` Masami Hiramatsu
2018-11-03 17:30                     ` Steven Rostedt
2018-11-03 17:33                       ` Steven Rostedt
2018-11-04  2:25                       ` Masami Hiramatsu
2018-11-03  7:02           ` Aleksa Sarai
2018-11-04 11:59             ` Aleksa Sarai
2018-11-06 22:15               ` Steven Rostedt
2018-11-08  7:46                 ` Aleksa Sarai
2018-11-08  8:04                   ` Aleksa Sarai
2018-11-08 14:44                     ` Josh Poimboeuf
2018-11-09  7:26                       ` Masami Hiramatsu
2018-11-09 15:10                         ` Aleksa Sarai
2018-11-09  7:15                     ` Masami Hiramatsu
2018-11-09 15:06                       ` Aleksa Sarai
2018-11-10 15:31                         ` Masami Hiramatsu
2018-11-12 10:38                           ` Aleksa Sarai
2018-11-03 13:23           ` Masami Hiramatsu
2018-11-02  7:58       ` Aleksa Sarai
2018-11-02  4:01   ` kbuild test robot
2018-11-01  8:35 ` [PATCH v3 2/2] trace: remove kretprobed checks Aleksa Sarai

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).