[PATCH v8 28/35] tracing/fprobe: Enable fprobe events with CONFIG_DYNAMIC_FTRACE_WITH_ARGS

2024-02-25 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Allow fprobe events to be enabled with CONFIG_DYNAMIC_FTRACE_WITH_ARGS. With this change, fprobe events mostly use ftrace_regs instead of pt_regs. Note that if the arch doesn't enable HAVE_PT_REGS_COMPAT_FTRACE_REGS, fprobe events will not be able to be used

[PATCH v8 27/35] tracing: Add ftrace_fill_perf_regs() for perf event

2024-02-25 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Add ftrace_fill_perf_regs() which should be compatible with the perf_fetch_caller_regs(). In other words, the pt_regs returned from the ftrace_fill_perf_regs() must satisfy 'user_mode(regs) == false' and can be used for stack tracing. Signed-off-

[PATCH v8 26/35] tracing: Add ftrace_partial_regs() for converting ftrace_regs to pt_regs

2024-02-25 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Add ftrace_partial_regs() which converts the ftrace_regs to pt_regs. This is for the eBPF which needs this to keep the same pt_regs interface to access registers. Thus when replacing the pt_regs with ftrace_regs in fprobes (which is used by kprobe_multi eBPF event

[PATCH v8 25/35] fprobe: Use ftrace_regs in fprobe exit handler

2024-02-25 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Change the fprobe exit handler to use ftrace_regs structure instead of pt_regs. This also introduce HAVE_PT_REGS_TO_FTRACE_REGS_CAST which means the ftrace_regs's memory layout is equal to the pt_regs so that those are able to cast. Fprobe introduces

[PATCH v8 24/35] fprobe: Use ftrace_regs in fprobe entry handler

2024-02-25 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) 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. Signed-off-by: Masami Hiramatsu (Google) Acked-by: Florent Revest --- Changes in v6: - Keep using

[PATCH v8 23/35] function_graph: Pass ftrace_regs to retfunc

2024-02-25 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Pass ftrace_regs to the fgraph_ops::retfunc(). If ftrace_regs is not available, it passes a NULL instead. User callback function can access some registers (including return address) via this ftrace_regs. Signed-off-by: Masami Hiramatsu (Google) --- Changes in

[PATCH v8 22/35] function_graph: Replace fgraph_ret_regs with ftrace_regs

2024-02-25 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Use ftrace_regs instead of fgraph_ret_regs for tracing return value on function_graph tracer because of simplifying the callback interface. The CONFIG_HAVE_FUNCTION_GRAPH_RETVAL is also replaced by CONFIG_HAVE_FUNCTION_GRAPH_FREGS. Signed-off-by: Masami

[PATCH v8 21/35] function_graph: Pass ftrace_regs to entryfunc

2024-02-25 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Pass ftrace_regs to the fgraph_ops::entryfunc(). If ftrace_regs is not available, it passes a NULL instead. User callback function can access some registers (including return address) via this ftrace_regs. Signed-off-by: Masami Hiramatsu (Google) --- Changes in

[PATCH v8 20/35] ftrace: Add multiple fgraph storage selftest

2024-02-25 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Add a selftest for multiple function graph tracer with storage on a same function. In this case, the shadow stack entry will be shared among those fgraph with different data storage. So this will ensure the fgraph will not mixed those storage data. Signed-off-by

[PATCH v8 19/35] function_graph: Add selftest for passing local variables

2024-02-25 Thread Masami Hiramatsu (Google)
From: Steven Rostedt (VMware) Add boot up selftest that passes variables from a function entry to a function exit, and make sure that they do get passed around. Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - Add reserved size test

[PATCH v8 18/35] function_graph: Implement fgraph_reserve_data() and fgraph_retrieve_data()

2024-02-25 Thread Masami Hiramatsu (Google)
x27;s shadow ret_stack and this then can be retrieved by fgraph_retrieve_data() called by the corresponding retfunc(). Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v8: - Avoid using DIV_ROUND_UP() in the hot path. Changes in v3: -

[PATCH v8 17/35] function_graph: Move graph notrace bit to shadow stack global var

2024-02-25 Thread Masami Hiramatsu (Google)
are) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - Make description lines shorter than 76 chars. --- include/linux/trace_recursion.h |7 --- kernel/trace/trace.h |9 + kernel/trace/trace_functions_graph.c | 10 ++ 3 files chan

[PATCH v8 16/35] function_graph: Move graph depth stored data to shadow stack global var

2024-02-25 Thread Masami Hiramatsu (Google)
are) Signed-off-by: Masami Hiramatsu (Google) --- include/linux/trace_recursion.h | 29 - kernel/trace/trace.h| 34 -- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/include/linux/trace_recursion.h b/incl

[PATCH v8 15/35] function_graph: Move set_graph_function tests to shadow stack global var

2024-02-25 Thread Masami Hiramatsu (Google)
are) Signed-off-by: Masami Hiramatsu (Google) --- include/linux/trace_recursion.h |5 + kernel/trace/trace.h | 32 +--- kernel/trace/trace_functions_graph.c |6 +++--- kernel/trace/trace_irqsoff.c |4 ++-- kernel/tr

[PATCH v8 14/35] function_graph: Add "task variables" per task for fgraph_ops

2024-02-25 Thread Masami Hiramatsu (Google)
atures on a per task basis having a way to maintain state for each task. Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v3: - Move fgraph_ops::idx to previous patch in the series. Changes in v2: - Make description lines shorter than 76 char

[PATCH v8 13/35] function_graph: Use a simple LRU for fgraph_array index number

2024-02-25 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Since the fgraph_array index is used for the bitmap on the shadow stack, it may leave some entries after a function_graph instance is removed. Thus if another instance reuses the fgraph_array index soon after releasing it, the fgraph may confuse to call the newer

[PATCH v8 12/35] function_graph: Have the instances use their own ftrace_ops for filtering

2024-02-25 Thread Masami Hiramatsu (Google)
function_graph_enter_ops() instead of function_graph_enter() so that it avoid pushing on shadow stack multiple times on the same function. Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v8: - Fix a compilation error in loongarch implementation

[PATCH v8 11/35] ftrace: Allow ftrace startup flags exist without dynamic ftrace

2024-02-25 Thread Masami Hiramatsu (Google)
compile because dynamic ftrace is disabled. This change is needed to move some of the logic of what is passed to ftrace_startup() out of the parameters of ftrace_startup(). Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- include/linux/ftrace.h | 18

[PATCH v8 10/35] ftrace: Allow function_graph tracer to be enabled in instances

2024-02-25 Thread Masami Hiramatsu (Google)
: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - Fix to remove set_graph_array() completely. --- include/linux/ftrace.h |1 + kernel/trace/ftrace.c|1 + kernel/trace/trace.h | 13 ++- kernel

[PATCH v8 09/35] ftrace/function_graph: Pass fgraph_ops to function graph callbacks

2024-02-25 Thread Masami Hiramatsu (Google)
to the function graph tracer. Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - cleanup to set argument name on function prototype. --- include/linux/ftrace.h | 10 +++--- kernel/trace/fgraph.c| 16

[PATCH v8 08/35] function_graph: Remove logic around ftrace_graph_entry and return

2024-02-25 Thread Masami Hiramatsu (Google)
function_graph tracer. Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - Fix typo and make lines shorter than 76 chars in the description. - Remove unneeded return from return_run() function. --- kernel/trace/fgraph.c | 67

[PATCH v8 07/35] function_graph: Allow multiple users to attach to function graph

2024-02-25 Thread Masami Hiramatsu (Google)
s when both are called is not completely handled yet, but that shouldn't be too hard to manage. Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v7: - Fix max limitation check in ftrace_graph_push_return(). - Rewrite the shadow stack impleme

[PATCH v8 06/35] function_graph: Add an array structure that will allow multiple callbacks

2024-02-25 Thread Masami Hiramatsu (Google)
n the shadow stack. We need to only save the index, because this will allow the fgraph_ops to be freed before the function returns (which may happen if the function call schedule for a long time). Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - R

[PATCH v8 05/35] fgraph: Use BUILD_BUG_ON() to make sure we have structures divisible by long

2024-02-25 Thread Masami Hiramatsu (Google)
dt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v7: - Use DIV_ROUND_UP() to calculate FGRAPH_RET_INDEX --- kernel/trace/fgraph.c |9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c index 30

[PATCH v8 04/35] function_graph: Convert ret_stack to a series of longs

2024-02-25 Thread Masami Hiramatsu (Google)
the return side of the functions. Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- include/linux/sched.h |2 - kernel/trace/fgraph.c | 124 - 2 files changed, 71 insertions(+), 55 deletions(-) diff --git a

[PATCH v8 03/35] x86: tracing: Add ftrace_regs definition in the header

2024-02-25 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Add ftrace_regs definition for x86_64 in the ftrace header to clarify what register will be accessible from ftrace_regs. Signed-off-by: Masami Hiramatsu (Google) --- Changes in v3: - Add rip to be saved. Changes in v2: - Newly added. --- arch/x86/include

[PATCH v8 02/35] tracing: Rename ftrace_regs_return_value to ftrace_regs_get_return_value

2024-02-25 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Rename ftrace_regs_return_value to ftrace_regs_get_return_value as same as other ftrace_regs_get/set_* APIs. Signed-off-by: Masami Hiramatsu (Google) Acked-by: Mark Rutland --- Changes in v6: - Moved to top of the series. Changes in v3: - Newly added

[PATCH v8 01/35] tracing: Add a comment about ftrace_regs definition

2024-02-25 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) To clarify what will be expected on ftrace_regs, add a comment to the architecture independent definition of the ftrace_regs. Signed-off-by: Masami Hiramatsu (Google) Acked-by: Mark Rutland --- Changes in v8: - Update that the saved registers depends on the

[PATCH v8 00/35] tracing: fprobe: function_graph: Multi-function graph and fprobe on fgraph

2024-02-25 Thread Masami Hiramatsu (Google)
before the return callback runs. Thus the address validation must be done before using it in the return callback. This series can be applied against the v6.8-rc4 kernel. This series can also be found below branch. https://git.kernel.org/pub/scm/linux/kernel/git/mhiramat/linux.git/log/?h=topi

Re: [PATCH v7 23/36] function_graph: Add a new exit handler with parent_ip and ftrace_regs

2024-02-19 Thread Google
Hi Steve, On Sun, 18 Feb 2024 11:53:28 +0900 Masami Hiramatsu (Google) wrote: > On Fri, 16 Feb 2024 17:51:08 +0900 > Masami Hiramatsu (Google) wrote: > > > > > @@ -798,10 +798,6 @@ ftrace_pop_return_trace(struct ftrace_graph_ret > > >

Re: [PATCH v7 23/36] function_graph: Add a new exit handler with parent_ip and ftrace_regs

2024-02-17 Thread Google
On Fri, 16 Feb 2024 17:51:08 +0900 Masami Hiramatsu (Google) wrote: > > > @@ -798,10 +798,6 @@ ftrace_pop_return_trace(struct ftrace_graph_ret > > > *trace, unsigned long *ret, > > > > > > *index += FGRAPH_RET_INDEX; > > > *ret = ret_stac

Re: [PATCH v7 20/36] function_graph: Improve push operation for several interrupts

2024-02-17 Thread Google
On Thu, 15 Feb 2024 09:57:39 -0500 Steven Rostedt wrote: > On Wed, 7 Feb 2024 00:11:12 +0900 > "Masami Hiramatsu (Google)" wrote: > > > From: Masami Hiramatsu (Google) > > > > Improve push and data reserve operation on the shadow stack for > > seve

Re: [PATCH RFC 1/5] tracing/probes: Fix to search structure fields correctly

2024-02-17 Thread Google
Let me pick this patch because this is a real bugfix. On Wed, 14 Feb 2024 22:22:23 +0900 "Masami Hiramatsu (Google)" wrote: > From: Masami Hiramatsu (Google) > > Fix to search a field from the structure which has anonymous union > correctly. > Since the reference `typ

Re: [PATCH v7 28/36] tracing: Add ftrace_partial_regs() for converting ftrace_regs to pt_regs

2024-02-16 Thread Google
On Thu, 15 Feb 2024 11:11:34 -0500 Steven Rostedt wrote: > On Wed, 7 Feb 2024 00:12:40 +0900 > "Masami Hiramatsu (Google)" wrote: > > > From: Masami Hiramatsu (Google) > > > > Add ftrace_partial_regs() which converts the ftrace_regs to pt_regs. &g

Re: [PATCH v7 25/36] arm64: ftrace: Enable HAVE_FUNCTION_GRAPH_FREGS

2024-02-16 Thread Google
On Thu, 15 Feb 2024 11:10:21 -0500 Steven Rostedt wrote: > On Wed, 7 Feb 2024 00:12:06 +0900 > "Masami Hiramatsu (Google)" wrote: > > > From: Masami Hiramatsu (Google) > > > > Enable CONFIG_HAVE_FUNCTION_GRAPH_FREGS on arm64. Note that this > > dep

Re: [PATCH v7 24/36] x86/ftrace: Enable HAVE_FUNCTION_GRAPH_FREGS

2024-02-16 Thread Google
On Thu, 15 Feb 2024 11:08:08 -0500 Steven Rostedt wrote: > On Wed, 7 Feb 2024 00:11:56 +0900 > "Masami Hiramatsu (Google)" wrote: > > > From: Masami Hiramatsu (Google) > > > > Support HAVE_FUNCTION_GRAPH_FREGS on x86-64, which saves ftrace_regs &g

Re: [PATCH v7 23/36] function_graph: Add a new exit handler with parent_ip and ftrace_regs

2024-02-16 Thread Google
On Thu, 15 Feb 2024 11:04:04 -0500 Steven Rostedt wrote: > On Wed, 7 Feb 2024 00:11:44 +0900 > "Masami Hiramatsu (Google)" wrote: > > > diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h > > index c88bf47f46da..a061f8832b20 100644

Re: [PATCH v7 23/36] function_graph: Add a new exit handler with parent_ip and ftrace_regs

2024-02-16 Thread Google
On Thu, 15 Feb 2024 10:49:03 -0500 Steven Rostedt wrote: > On Wed, 7 Feb 2024 00:11:44 +0900 > "Masami Hiramatsu (Google)" wrote: > > > diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig > > index 61c541c36596..308b3bec01b1 100644 > > --- a/kernel

Re: [PATCH v7 23/36] function_graph: Add a new exit handler with parent_ip and ftrace_regs

2024-02-16 Thread Google
On Thu, 15 Feb 2024 10:39:43 -0500 Steven Rostedt wrote: > On Wed, 7 Feb 2024 00:11:44 +0900 > "Masami Hiramatsu (Google)" wrote: > > > From: Masami Hiramatsu (Google) > > > > Add a new return handler to fgraph_ops as 'retregfunc' which

Re: [PATCH v7 21/36] function_graph: Add selftest for passing local variables

2024-02-16 Thread Google
On Thu, 15 Feb 2024 10:02:54 -0500 Steven Rostedt wrote: > On Wed, 7 Feb 2024 00:11:22 +0900 > "Masami Hiramatsu (Google)" wrote: > > > From: Steven Rostedt (VMware) > > > > Add boot up selftest that passes variables from a function entry to a > >

Re: [PATCH v7 19/36] function_graph: Implement fgraph_reserve_data() and fgraph_retrieve_data()

2024-02-15 Thread Google
On Wed, 14 Feb 2024 18:54:07 -0500 Steven Rostedt wrote: > On Thu, 15 Feb 2024 08:45:52 +0900 > Masami Hiramatsu (Google) wrote: > > > > Hmm, the above is a fast path. I wonder if we should add a patch to make > > > that into: > > > > > >

Re: [PATCH] synthetic tracing: Fix trace_string() return value

2024-02-15 Thread Google
Good catch! Acked-by: Masami Hiramatsu (Google) Fixes: ddeea494a16f ("tracing/synthetic: Use union instead of casts") Cc: sta...@vger.kernel.org Thanks! > Signed-off-by: Thorsten Blum > --- > kernel/trace/trace_events_synth.c | 3 ++- > 1 file changed, 2 insertions(+),

Re: [PATCH v7 14/36] function_graph: Use a simple LRU for fgraph_array index number

2024-02-14 Thread Google
On Wed, 14 Feb 2024 13:04:09 -0500 Steven Rostedt wrote: > On Wed, 7 Feb 2024 00:10:04 +0900 > "Masami Hiramatsu (Google)" wrote: > > > diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c > > index ae42de909845..323a74623543 100644 > > --- a/kernel/

Re: [PATCH v7 19/36] function_graph: Implement fgraph_reserve_data() and fgraph_retrieve_data()

2024-02-14 Thread Google
On Wed, 14 Feb 2024 13:59:58 -0500 Steven Rostedt wrote: > On Wed, 7 Feb 2024 00:11:01 +0900 > "Masami Hiramatsu (Google)" wrote: > > > From: Ste > > +/** > > + * fgraph_reserve_data - Reserve storage on the task's ret_stack > > + * @idx: Th

Re: [PATCH v7 10/36] ftrace/function_graph: Pass fgraph_ops to function graph callbacks

2024-02-14 Thread Google
On Tue, 13 Feb 2024 20:42:18 -0500 Steven Rostedt wrote: > On Wed, 7 Feb 2024 00:09:21 +0900 > "Masami Hiramatsu (Google)" wrote: > > > From: Steven Rostedt (VMware) > > > > Pass the fgraph_ops structure to the function graph callbacks. This will > &g

[PATCH RFC 5/5] tracing/probes: Support $argN in return probe (kprobe and fprobe)

2024-02-14 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Support accessing $argN in the return probe events. This will help users to record entry data in function return (exit) event for simplfing the function entry/exit information in one event, and record the result values (e.g. allocated object/initialized object) at

[PATCH RFC 4/5] tracing/probes: cleanup: Set trace_probe::nr_args at trace_probe_init

2024-02-14 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Instead of incrementing the trace_probe::nr_args, init it at trace_probe_init(). This is a cleanup, so the behavior is not changed. Signed-off-by: Masami Hiramatsu (Google) --- kernel/trace/trace_eprobe.c |2 +- kernel/trace/trace_probe.c | 10

[PATCH RFC 3/5] tracing/probes: Cleanup probe argument parser

2024-02-14 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Cleanup traceprobe_parse_probe_arg_body() to split out the type parser and post-processing part of fetch_insn. This makes no functional change. Signed-off-by: Masami Hiramatsu (Google) --- kernel/trace/trace_probe.c | 230

[PATCH RFC 2/5] tracing/fprobe-event: cleanup: Fix a wrong comment in fprobe event

2024-02-14 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Despite the fprobe event, "Kretprobe" was commented. So fix it. Signed-off-by: Masami Hiramatsu (Google) --- kernel/trace/trace_fprobe.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/trace_fprobe.c b/ke

[PATCH RFC 1/5] tracing/probes: Fix to search structure fields correctly

2024-02-14 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Fix to search a field from the structure which has anonymous union correctly. Since the reference `type` pointer was updated in the loop, the search loop suddenly aborted where it hits an anonymous union. Thus it can not find the field after the anonymous union

[PATCH RFC 0/5] tracing/probes: Support function parameter access from return probe

2024-02-14 Thread Masami Hiramatsu (Google)
e those fields are initialized at exit. TODO: - update README file - add/update ftracetest - update documents Thank you, --- Masami Hiramatsu (Google) (5): tracing/probes: Fix to search structure fields correctly tracing/fprobe-event: cleanup: Fix a wrong comment in fprobe e

Re: [PATCH v2] tracing: Have saved_cmdlines arrays all in one allocation

2024-02-13 Thread Google
On Tue, 13 Feb 2024 11:52:32 -0500 Steven Rostedt wrote: > From: "Steven Rostedt (Google)" > > The saved_cmdlines have three arrays for mapping PIDs to COMMs: > > - map_pid_to_cmdline[] > - map_cmdline_to_pid[] > - saved_cmdlines > > The map_pid_to_cmd

Re: [PATCH] tracing: Have saved_cmdlines arrays all in one allocation

2024-02-12 Thread Google
On Mon, 12 Feb 2024 18:09:41 -0500 Steven Rostedt wrote: > From: "Steven Rostedt (Google)" > > The saved_cmdlines have three arrays for mapping PIDs to COMMs: > > - map_pid_to_cmdline[] > - map_cmdline_to_pid[] > - saved_cmdlines > > The map_pid_to_cmd

Re: [PATCH v2] tracing: Fix wasted memory in saved_cmdlines logic

2024-02-12 Thread Google
On Fri, 9 Feb 2024 06:36:22 -0500 Steven Rostedt wrote: > From: "Steven Rostedt (Google)" > > While looking at improving the saved_cmdlines cache I found a huge amount > of wasted memory that should be used for the cmdlines. > > The tracing data saves pids durin

Re: [PATCH v5 7/8] selftests/ftrace: add kprobe test cases for VFS type "%pd" and "%pD"

2024-02-07 Thread Google
vents > +echo 1 > events/kprobes/testprobe/enable > +grep -q "1" events/kprobes/testprobe/enable > +echo 0 > events/kprobes/testprobe/enable > +grep "vfs_read" trace | grep -q "enable" > +echo "" > kprobe_events > +echo "" > trace > + > +: "Test argument %pD without name" > +echo 'p:testprobe vfs_read $arg1:%pD' > kprobe_events > +echo 1 > events/kprobes/testprobe/enable > +grep -q "1" events/kprobes/testprobe/enable > +echo 0 > events/kprobes/testprobe/enable > +grep "vfs_read" trace | grep -q "enable" > +echo "" > kprobe_events > +echo "" > trace > -- > 2.31.1 > > -- Masami Hiramatsu (Google)

Re: [PATCH v5 5/8] tracing: add new type "%pd/%pD" in readme_msg[]

2024-02-07 Thread Google
"\tfield: ;\n" > "\tstype: u8/u16/u32/u64, s8/s16/s32/s64, pid_t,\n" > -- > 2.31.1 > > -- Masami Hiramatsu (Google)

Re: [PATCH v5 4/8] tracing/probes: support '%pd/%pD' type for fprobe

2024-02-07 Thread Google
On Thu, 25 Jan 2024 15:39:19 +0800 Ye Bin wrote: > Support print type '%pd/%pD' for print dentry's or file's name. > nit: Looks good to me. but the patch ordering seems a bit strange. This should be next to [2/8]. Acked-by: Masami Hiramatsu (Google) Thank you

Re: [PATCH v5 1/8] tracing/probes: add traceprobe_expand_dentry_args() helper

2024-02-07 Thread Google
E_LEN) > > @@ -402,6 +403,7 @@ extern int traceprobe_parse_probe_arg(struct trace_probe > *tp, int i, > const char **traceprobe_expand_meta_args(int argc, const char *argv[], >int *new_argc, char *buf, int bufsize, >struct traceprobe_parse_context *ctx); > +extern int traceprobe_expand_dentry_args(int argc, const char *argv[], char > **buf); > > extern int traceprobe_update_arg(struct probe_arg *arg); > extern void traceprobe_free_probe_arg(struct probe_arg *arg); > -- > 2.31.1 > -- Masami Hiramatsu (Google)

Re: [PATCH v7 13/36] function_graph: Have the instances use their own ftrace_ops for filtering

2024-02-07 Thread Google
On Wed, 7 Feb 2024 00:09:54 +0900 "Masami Hiramatsu (Google)" wrote: > diff --git a/arch/loongarch/kernel/ftrace_dyn.c > b/arch/loongarch/kernel/ftrace_dyn.c > index 73858c9029cc..81d18b911cc1 100644 > --- a/arch/loongarch/kernel/ftrace_dyn.c > +++ b/arch/loon

Re: [PATCH v2 3/3] x86/kprobes: Boost more instructions from grp2/3/4/5

2024-02-06 Thread Google
On Sun, 4 Feb 2024 22:39:32 -0600 Jinghao Jia wrote: > On 2/4/24 06:09, Masami Hiramatsu (Google) wrote: > > On Sat, 3 Feb 2024 21:13:00 -0600 > > Jinghao Jia wrote: > > > >> With the instruction decoder, we are now able to decode and recognize > >> ins

[PATCH v7 35/36] selftests/ftrace: Add a test case for repeating register/unregister fprobe

2024-02-06 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) This test case repeats define and undefine the fprobe dynamic event to ensure that the fprobe does not cause any issue with such operations. Signed-off-by: Masami Hiramatsu (Google) --- .../test.d/dynevent/add_remove_fprobe_repeat.tc| 19

[PATCH v7 20/36] function_graph: Improve push operation for several interrupts

2024-02-06 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Improve push and data reserve operation on the shadow stack for several sequencial interrupts. To push a ret_stack or data entry on the shadow stack, we need to prepare an index (offset) entry before updating the stack pointer (curr_ret_stack) so that unwinder

[PATCH v7 21/36] function_graph: Add selftest for passing local variables

2024-02-06 Thread Masami Hiramatsu (Google)
From: Steven Rostedt (VMware) Add boot up selftest that passes variables from a function entry to a function exit, and make sure that they do get passed around. Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - Add reserved size test

[PATCH v7 36/36] Documentation: probes: Update fprobe on function-graph tracer

2024-02-06 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Update fprobe documentation for the new fprobe on function-graph tracer. This includes some bahvior changes and pt_regs to ftrace_regs interface change. Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - Update @fregs parameter explanation

[PATCH v7 34/36] selftests: ftrace: Remove obsolate maxactive syntax check

2024-02-06 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Since the fprobe event does not support maxactive anymore, stop testing the maxactive syntax error checking. Signed-off-by: Masami Hiramatsu (Google) --- .../ftrace/test.d/dynevent/fprobe_syntax_errors.tc |4 +--- 1 file changed, 1 insertion(+), 3 deletions

[PATCH v7 33/36] tracing/fprobe: Remove nr_maxactive from fprobe

2024-02-06 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Remove depercated fprobe::nr_maxactive. This involves fprobe events to rejects the maxactive number. Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - Newly added. --- include/linux/fprobe.h |2 -- kernel/trace/trace_fprobe.c | 44

[PATCH v7 32/36] fprobe: Rewrite fprobe on function-graph tracer

2024-02-06 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Rewrite fprobe implementation on function-graph tracer. Major API changes are: - 'nr_maxactive' field is deprecated. - This depends on CONFIG_DYNAMIC_FTRACE_WITH_ARGS or !CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS, and CONFIG_HAVE_FUNCTION_GRAPH

[PATCH v7 13/36] function_graph: Have the instances use their own ftrace_ops for filtering

2024-02-06 Thread Masami Hiramatsu (Google)
function_graph_enter_ops() instead of function_graph_enter() so that it avoid pushing on shadow stack multiple times on the same function. Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v7: - Move FGRAPH_TYPE_BITMAP type implementation to earlier patch

[PATCH v7 31/36] bpf: Enable kprobe_multi feature if CONFIG_FPROBE is enabled

2024-02-06 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Enable kprobe_multi feature if CONFIG_FPROBE is enabled. The pt_regs is converted from ftrace_regs by ftrace_partial_regs(), thus some registers may always returns 0. But it should be enough for function entry (access arguments) and exit (access return value

[PATCH v7 30/36] tracing/fprobe: Enable fprobe events with CONFIG_DYNAMIC_FTRACE_WITH_ARGS

2024-02-06 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Allow fprobe events to be enabled with CONFIG_DYNAMIC_FTRACE_WITH_ARGS. With this change, fprobe events mostly use ftrace_regs instead of pt_regs. Note that if the arch doesn't enable HAVE_PT_REGS_COMPAT_FTRACE_REGS, fprobe events will not be able to be used

[PATCH v7 29/36] tracing: Add ftrace_fill_perf_regs() for perf event

2024-02-06 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Add ftrace_fill_perf_regs() which should be compatible with the perf_fetch_caller_regs(). In other words, the pt_regs returned from the ftrace_fill_perf_regs() must satisfy 'user_mode(regs) == false' and can be used for stack tracing. Signed-off-

[PATCH v7 28/36] tracing: Add ftrace_partial_regs() for converting ftrace_regs to pt_regs

2024-02-06 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Add ftrace_partial_regs() which converts the ftrace_regs to pt_regs. If the architecture defines its own ftrace_regs, this copies partial registers to pt_regs and returns it. If not, ftrace_regs is the same as pt_regs and ftrace_partial_regs() will return

[PATCH v7 27/36] fprobe: Use ftrace_regs in fprobe exit handler

2024-02-06 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Change the fprobe exit handler to use ftrace_regs structure instead of pt_regs. This also introduce HAVE_PT_REGS_TO_FTRACE_REGS_CAST which means the ftrace_regs's memory layout is equal to the pt_regs so that those are able to cast. Fprobe introduces

[PATCH v7 26/36] fprobe: Use ftrace_regs in fprobe entry handler

2024-02-06 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) 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. Signed-off-by: Masami Hiramatsu (Google) Acked-by: Florent Revest --- Changes in v6: - Keep using

[PATCH v7 25/36] arm64: ftrace: Enable HAVE_FUNCTION_GRAPH_FREGS

2024-02-06 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Enable CONFIG_HAVE_FUNCTION_GRAPH_FREGS on arm64. Note that this depends on HAVE_DYNAMIC_FTRACE_WITH_ARGS which is enabled if the compiler supports "-fpatchable-function-entry=2". If not, it continue to use ftrace_ret_regs. Signed-off-by: Masami Hiramat

[PATCH v7 24/36] x86/ftrace: Enable HAVE_FUNCTION_GRAPH_FREGS

2024-02-06 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Support HAVE_FUNCTION_GRAPH_FREGS on x86-64, which saves ftrace_regs on the stack in ftrace_graph return trampoline so that the callbacks can access registers via ftrace_regs APIs. Note that this only recovers 'rax' and 'rdx' registers because

[PATCH v7 23/36] function_graph: Add a new exit handler with parent_ip and ftrace_regs

2024-02-06 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Add a new return handler to fgraph_ops as 'retregfunc' which takes parent_ip and ftrace_regs instead of ftrace_graph_ret. This handler is available only if the arch support CONFIG_HAVE_FUNCTION_GRAPH_FREGS. Note that the 'retfunc' and &#

[PATCH v7 22/36] function_graph: Add a new entry handler with parent_ip and ftrace_regs

2024-02-06 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Add a new entry handler to fgraph_ops as 'entryregfunc' which takes parent_ip and ftrace_regs. Note that the 'entryfunc' and 'entryregfunc' are mutual exclusive. You can set only one of them. Signed-off-by: Masami Hiramats

[PATCH v7 19/36] function_graph: Implement fgraph_reserve_data() and fgraph_retrieve_data()

2024-02-06 Thread Masami Hiramatsu (Google)
x27;s shadow ret_stack and this then can be retrieved by fgraph_retrieve_data() called by the corresponding retfunc(). Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v3: - Store fgraph_array index to the data entry. - Both function req

[PATCH v7 18/36] function_graph: Move graph notrace bit to shadow stack global var

2024-02-06 Thread Masami Hiramatsu (Google)
are) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - Make description lines shorter than 76 chars. --- include/linux/trace_recursion.h |7 --- kernel/trace/trace.h |9 + kernel/trace/trace_functions_graph.c | 10 ++ 3 files chan

[PATCH v7 17/36] function_graph: Move graph depth stored data to shadow stack global var

2024-02-06 Thread Masami Hiramatsu (Google)
are) Signed-off-by: Masami Hiramatsu (Google) --- include/linux/trace_recursion.h | 29 - kernel/trace/trace.h| 34 -- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/include/linux/trace_recursion.h b/incl

[PATCH v7 16/36] function_graph: Move set_graph_function tests to shadow stack global var

2024-02-06 Thread Masami Hiramatsu (Google)
are) Signed-off-by: Masami Hiramatsu (Google) --- include/linux/trace_recursion.h |5 + kernel/trace/trace.h | 32 +--- kernel/trace/trace_functions_graph.c |6 +++--- kernel/trace/trace_irqsoff.c |4 ++-- kernel/tr

[PATCH v7 15/36] function_graph: Add "task variables" per task for fgraph_ops

2024-02-06 Thread Masami Hiramatsu (Google)
atures on a per task basis having a way to maintain state for each task. Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v3: - Move fgraph_ops::idx to previous patch in the series. Changes in v2: - Make description lines shorter than 76 char

[PATCH v7 14/36] function_graph: Use a simple LRU for fgraph_array index number

2024-02-06 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Since the fgraph_array index is used for the bitmap on the shadow stack, it may leave some entries after a function_graph instance is removed. Thus if another instance reuses the fgraph_array index soon after releasing it, the fgraph may confuse to call the newer

[PATCH v7 12/36] ftrace: Allow ftrace startup flags exist without dynamic ftrace

2024-02-06 Thread Masami Hiramatsu (Google)
compile because dynamic ftrace is disabled. This change is needed to move some of the logic of what is passed to ftrace_startup() out of the parameters of ftrace_startup(). Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- include/linux/ftrace.h | 18

[PATCH v7 10/36] ftrace/function_graph: Pass fgraph_ops to function graph callbacks

2024-02-06 Thread Masami Hiramatsu (Google)
to the function graph tracer. Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - cleanup to set argument name on function prototype. --- include/linux/ftrace.h | 10 +++--- kernel/trace/fgraph.c| 14

[PATCH v7 11/36] ftrace: Allow function_graph tracer to be enabled in instances

2024-02-06 Thread Masami Hiramatsu (Google)
: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - Fix to remove set_graph_array() completely. --- include/linux/ftrace.h |1 + kernel/trace/ftrace.c|1 + kernel/trace/trace.h | 13 ++- kernel

[PATCH v7 09/36] function_graph: Remove logic around ftrace_graph_entry and return

2024-02-06 Thread Masami Hiramatsu (Google)
function_graph tracer. Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - Fix typo and make lines shorter than 76 chars in the description. - Remove unneeded return from return_run() function. --- kernel/trace/fgraph.c | 67

[PATCH v7 08/36] function_graph: Allow multiple users to attach to function graph

2024-02-06 Thread Masami Hiramatsu (Google)
s when both are called is not completely handled yet, but that shouldn't be too hard to manage. Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v7: - Fix max limitation check in ftrace_graph_push_return(). - Rewrite the shadow stack impleme

[PATCH v7 07/36] function_graph: Add an array structure that will allow multiple callbacks

2024-02-06 Thread Masami Hiramatsu (Google)
n the shadow stack. We need to only save the index, because this will allow the fgraph_ops to be freed before the function returns (which may happen if the function call schedule for a long time). Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - R

[PATCH v7 06/36] fgraph: Use BUILD_BUG_ON() to make sure we have structures divisible by long

2024-02-06 Thread Masami Hiramatsu (Google)
dt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v7: - Use DIV_ROUND_UP() to calculate FGRAPH_RET_INDEX --- kernel/trace/fgraph.c |9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c index 30

[PATCH v7 05/36] function_graph: Convert ret_stack to a series of longs

2024-02-06 Thread Masami Hiramatsu (Google)
the return side of the functions. Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- include/linux/sched.h |2 - kernel/trace/fgraph.c | 124 - 2 files changed, 71 insertions(+), 55 deletions(-) diff --git a

[PATCH v7 04/36] x86: tracing: Add ftrace_regs definition in the header

2024-02-06 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Add ftrace_regs definition for x86_64 in the ftrace header to clarify what register will be accessible from ftrace_regs. Signed-off-by: Masami Hiramatsu (Google) --- Changes in v3: - Add rip to be saved. Changes in v2: - Newly added. --- arch/x86/include

[PATCH v7 03/36] tracing: Rename ftrace_regs_return_value to ftrace_regs_get_return_value

2024-02-06 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Rename ftrace_regs_return_value to ftrace_regs_get_return_value as same as other ftrace_regs_get/set_* APIs. Signed-off-by: Masami Hiramatsu (Google) Acked-by: Mark Rutland --- Changes in v6: - Moved to top of the series. Changes in v3: - Newly added

[PATCH v7 02/36] tracing: Add a comment about ftrace_regs definition

2024-02-06 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) To clarify what will be expected on ftrace_regs, add a comment to the architecture independent definition of the ftrace_regs. Signed-off-by: Masami Hiramatsu (Google) Acked-by: Mark Rutland --- Changes in v3: - Add instruction pointer Changes in v2

[PATCH v7 01/36] ftrace: Fix DIRECT_CALLS to use SAVE_REGS by default

2024-02-06 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) The commit 60c8971899f3 ("ftrace: Make DIRECT_CALLS work WITH_ARGS and !WITH_REGS") changed DIRECT_CALLS to use SAVE_ARGS when there are multiple ftrace_ops at the same function, but since the x86 only support to jump to direct_call from ftrace_regs_ca

[PATCH v7 00/36] tracing: fprobe: function_graph: Multi-function graph and fprobe on fgraph

2024-02-06 Thread Masami Hiramatsu (Google)
an be applied against the linux-trace/trace/urgent (based on v6.8-rc1) kernel. This series can also be found below branch. https://git.kernel.org/pub/scm/linux/kernel/git/mhiramat/linux.git/log/?h=topic/fprobe-on-fgraph Thank you, --- Masami Hiramatsu (Google) (21): ftrace: Fix DIRECT_CA

Re: [PATCH v2 1/3] x86/kprobes: Refactor can_{probe,boost} return type to bool

2024-02-04 Thread Google
asami Hiramatsu (Google) Let me pick those. > Signed-off-by: Jinghao Jia > --- > arch/x86/kernel/kprobes/common.h | 2 +- > arch/x86/kernel/kprobes/core.c | 33 +++- > 2 files changed, 16 insertions(+), 19 deletions(-) > > diff --git a/arch/x86/k

Re: [PATCH v2 3/3] x86/kprobes: Boost more instructions from grp2/3/4/5

2024-02-04 Thread Google
+ X86_MODRM_REG(insn->modrm.bytes[0]) == 0b001 || > +X86_MODRM_REG(insn->modrm.bytes[0]) == 0b100; > default: > return true; > } > -- > 2.43.0 > -- Masami Hiramatsu (Google)

Re: Boot-time dumping of ftrace fuctiongraph buffer

2024-02-01 Thread Google
eers, > Ahmad > > -- > Pengutronix e.K. | | > Steuerwalder Str. 21 | http://www.pengutronix.de/ | > 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| > Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | > -- Masami Hiramatsu (Google)

<    1   2   3   4   5   6   7   8   9   10   >