Masami Hiramatsu (Google)
762abbc0d0
fprobe: Use ftrace_regs in fprobe exit handler
...
Change the fprobe exit handler to use ftrace_regs structure instead of
pt_regs. This also introduce HAVE_FTRACE_REGS_HAVING_PT_REGS which
means the ftrace_regs is including the pt_regs so that ftrace_regs
can provide pt_regs without memory allocation.
Fprobe introduces a new dependency with that.
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org >
Acked-by: Heiko Carstens <hca@linux.ibm.com > # s390
Cc: Huacai Chen <chenhuacai@kernel.org >
Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com >
Cc: Florent Revest <revest@chromium.org >
Cc: bpf <bpf@vger.kernel.org >
Cc: Alan Maguire <alan.maguire@oracle.com >
Cc: Heiko Carstens <hca@linux.ibm.com >
Cc: WANG Xuerui <kernel@xen0n.name >
Cc: Vasily Gorbik <gor@linux.ibm.com >
Cc: Alexander Gordeev <agordeev@linux.ibm.com >
Cc: Christian Borntraeger <borntraeger@linux.ibm.com >
Cc: Sven Schnelle <svens@linux.ibm.com >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Dave Hansen <dave.hansen@linux.intel.com >
Cc: x86@kernel.org
Cc: "H. Peter Anvin" <hpa@zytor.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com >
Cc: Song Liu <song@kernel.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: KP Singh <kpsingh@kernel.org >
Cc: Matt Bobrowski <mattbobrowski@google.com >
Cc: Alexei Starovoitov <ast@kernel.org >
Cc: Daniel Borkmann <daniel@iogearbox.net >
Cc: Andrii Nakryiko <andrii@kernel.org >
Cc: Martin KaFai Lau <martin.lau@linux.dev >
Cc: Eduard Zingerman <eddyz87@gmail.com >
Cc: Yonghong Song <yonghong.song@linux.dev >
Cc: John Fastabend <john.fastabend@gmail.com >
Cc: Stanislav Fomichev <sdf@fomichev.me >
Cc: Hao Luo <haoluo@google.com >
Cc: Andrew Morton <akpm@linux-foundation.org >
Link: https://lore.kernel.org/173518995092.391279.6765116450352977627.stgit@devnote2
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org >
2024-12-26 10:50:03 -05:00
Masami Hiramatsu (Google)
46bc082388
fprobe: Use ftrace_regs in fprobe entry handler
...
This allows fprobes to be available with CONFIG_DYNAMIC_FTRACE_WITH_ARGS
instead of CONFIG_DYNAMIC_FTRACE_WITH_REGS, then we can enable fprobe
on arm64.
Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com >
Cc: Martin KaFai Lau <martin.lau@linux.dev >
Cc: bpf <bpf@vger.kernel.org >
Cc: Alexei Starovoitov <ast@kernel.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Alan Maguire <alan.maguire@oracle.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Link: https://lore.kernel.org/173518994037.391279.2786805566359674586.stgit@devnote2
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org >
Acked-by: Florent Revest <revest@chromium.org >
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org >
2024-12-26 10:50:03 -05:00
Jeff Johnson
df216f5752
fprobe: add missing MODULE_DESCRIPTION() macro
...
make allmodconfig && make W=1 C=1 reports:
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/fprobe/fprobe_example.o
Add the missing invocation of the MODULE_DESCRIPTION() macro.
Link: https://lore.kernel.org/all/20240601-md-samples-fprobe-v1-1-5d256a956612@quicinc.com/
Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com >
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org >
2024-06-12 08:44:27 +09:00
Masami Hiramatsu (Google)
cb16330d12
fprobe: Pass return address to the handlers
...
Pass return address as 'ret_ip' to the fprobe entry and return handlers
so that the fprobe user handler can get the reutrn address without
analyzing arch-dependent pt_regs.
Link: https://lore.kernel.org/all/168507467664.913472.11642316698862778600.stgit@mhiramat.roam.corp.google.com/
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org >
2023-06-06 21:39:55 +09:00
Masami Hiramatsu (Google)
39d954200b
fprobe: Skip exit_handler if entry_handler returns !0
...
Skip hooking function return and calling exit_handler if the
entry_handler() returns !0 .
Link: https://lkml.kernel.org/r/167526699798.433354.10998365726830117303.stgit@mhiramat.roam.corp.google.com
Cc: Florent Revest <revest@chromium.org >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Will Deacon <will@kernel.org >
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org >
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org >
2023-03-28 18:52:22 -04:00
Masami Hiramatsu (Google)
76d0de5729
fprobe: Pass entry_data to handlers
...
Pass the private entry_data to the entry and exit handlers so that
they can share the context data, something like saved function
arguments etc.
User must specify the private entry_data size by @entry_data_size
field before registering the fprobe.
Link: https://lkml.kernel.org/r/167526696173.433354.17408372048319432574.stgit@mhiramat.roam.corp.google.com
Cc: Florent Revest <revest@chromium.org >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Will Deacon <will@kernel.org >
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org >
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org >
2023-03-28 18:52:22 -04:00
Linus Torvalds
b047602d57
Merge tag 'trace-v5.19-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
...
Pull tracing fixes from Steven Rostedt:
"Fixes and minor clean ups for tracing:
- Fix memory leak by reverting what was thought to be a double free.
A static tool had gave a false positive that a double free was
possible in the error path, but it was actually a different
location that confused the static analyzer (and those of us that
reviewed it).
- Move use of static buffers by ftrace_dump() to a location that can
be used by kgdb's ftdump(), as it needs it for the same reasons.
- Clarify in the Kconfig description that function tracing has
negligible impact on x86, but may have a bit bigger impact on other
architectures.
- Remove unnecessary extra semicolon in trace event.
- Make a local variable static that is used in the fprobes sample
- Use KSYM_NAME_LEN for length of function in kprobe sample and get
rid of unneeded macro for the same purpose"
* tag 'trace-v5.19-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
samples: Use KSYM_NAME_LEN for kprobes
fprobe/samples: Make sample_probe static
blk-iocost: tracing: atomic64_read(&ioc->vtime_rate) is assigned an extra semicolon
ftrace: Be more specific about arch impact when function tracer is enabled
tracing: Fix sleeping while atomic in kdb ftdump
tracing/histograms: Fix memory leak problem
2022-07-12 16:17:40 -07:00
sunliming
e3655dfa58
fprobe/samples: Make sample_probe static
...
This symbol is not used outside of fprobe_example.c, so marks it static.
Fixes the following warning:
sparse warnings: (new ones prefixed by >>)
>> samples/fprobe/fprobe_example.c:23:15: sparse: sparse: symbol 'sample_probe'
was not declared. Should it be static?
Link: https://lkml.kernel.org/r/20220606075659.674556-1-sunliming@kylinos.cn
Reported-by: kernel test robot <lkp@intel.com >
Signed-off-by: sunliming <sunliming@kylinos.cn >
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org >
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org >
2022-07-12 16:36:43 -04:00
Masami Hiramatsu (Google)
179a93f74b
fprobe, samples: Add module parameter descriptions
...
Add module parameter descriptions for the fprobe_example module.
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org >
Signed-off-by: Andrii Nakryiko <andrii@kernel.org >
Link: https://lore.kernel.org/bpf/165602349520.56016.1314423560740428008.stgit@devnote2
2022-06-24 15:23:04 -07:00
Masami Hiramatsu (Google)
c88dbbcd88
fprobe, samples: Add use_trace option and show hit/missed counter
...
Add use_trace option to use trace_printk() instead of pr_info()
so that the handler doesn't involve the RCU operations.
And show the hit and missed counter so that the user can check
how many times the probe handler hit and missed.
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org >
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net >
Acked-by: Jiri Olsa <jolsa@kernel.org >
Link: https://lore.kernel.org/bpf/165461826247.280167.11939123218334322352.stgit@devnote2
2022-06-17 21:53:29 +02:00
Masami Hiramatsu
6ee64cc302
fprobe: Add sample program for fprobe
...
Add a sample program for the fprobe. The sample_fprobe puts a fprobe on
kernel_clone() by default. This dump stack and some called address info
at the function entry and exit.
The sample_fprobe.ko gets 2 parameters.
- symbol: you can specify the comma separated symbols or wildcard symbol
pattern (in this case you can not use comma)
- stackdump: a bool value to enable or disable stack dump in the fprobe
handler.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org >
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org >
Tested-by: Steven Rostedt (Google) <rostedt@goodmis.org >
Signed-off-by: Alexei Starovoitov <ast@kernel.org >
Link: https://lore.kernel.org/bpf/164735291987.1084943.4449670993752806840.stgit@devnote2
2022-03-17 20:16:58 -07:00