[PATCH v5 33/34] selftests/ftrace: Add a test case for repeating register/unregister fprobe

2023-12-18 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 v5 32/34] selftests: ftrace: Remove obsolate maxactive syntax check

2023-12-18 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 v5 31/34] bpf: Enable kprobe_multi feature if CONFIG_FPROBE is enabled

2023-12-18 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 v5 30/34] tracing/fprobe: Enable fprobe events with CONFIG_DYNAMIC_FTRACE_WITH_ARGS

2023-12-18 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 from

[PATCH v5 29/34] tracing/fprobe: Remove nr_maxactive from fprobe

2023-12-18 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 v5 28/34] fprobe: Rewrite fprobe on function-graph tracer

2023-12-18 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_FREGS. So

[PATCH v5 27/34] tracing: Add ftrace_fill_perf_regs() for perf event

2023-12-18 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-by: Masami

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

2023-12-18 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 v5 25/34] fprobe: Use ftrace_regs in fprobe exit handler

2023-12-18 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 a new

[PATCH v5 24/34] fprobe: Use ftrace_regs in fprobe entry handler

2023-12-18 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 from previous series: NOTHING

[PATCH v5 23/34] arm64: ftrace: Enable HAVE_FUNCTION_GRAPH_FREGS

2023-12-18 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 v5 22/34] tracing: Rename ftrace_regs_return_value to ftrace_regs_get_return_value

2023-12-18 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) --- Changes in v3: - Newly added. --- arch/loongarch/include/asm/ftrace.h |2 +- arch/powerpc/include

[PATCH v5 21/34] x86/ftrace: Enable HAVE_FUNCTION_GRAPH_FREGS

2023-12-18 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 other registers

[PATCH v5 20/34] function_graph: Add a new exit handler with parent_ip and ftrace_regs

2023-12-18 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 'reregfunc' are mutual

[PATCH v5 19/34] function_graph: Add a new entry handler with parent_ip and ftrace_regs

2023-12-18 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 Hiramatsu (Google) --- Changes in v3

[PATCH v5 18/34] function_graph: Add selftest for passing local variables

2023-12-18 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 v5 17/34] function_graph: Implement fgraph_reserve_data() and fgraph_retrieve_data()

2023-12-18 Thread Masami Hiramatsu (Google)
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 requires

[PATCH v5 16/34] function_graph: Move graph notrace bit to shadow stack global var

2023-12-18 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 v5 15/34] function_graph: Move graph depth stored data to shadow stack global var

2023-12-18 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 v5 14/34] function_graph: Move set_graph_function tests to shadow stack global var

2023-12-18 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 v5 13/34] function_graph: Add "task variables" per task for fgraph_ops

2023-12-18 Thread Masami Hiramatsu (Google)
s 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 chars. --

[PATCH v5 12/34] function_graph: Use a simple LRU for fgraph_array index number

2023-12-18 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 v5 11/34] function_graph: Have the instances use their own ftrace_ops for filtering

2023-12-18 Thread Masami Hiramatsu (Google)
unc. But that is not enough for the self- recursive tail-call case. Thus fgraph uses the bitmap entry to find it is already set (this means that entry is for previous tail call). Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v4: - Simplify get_ret_stack() sanity ch

[PATCH v5 10/34] ftrace: Allow ftrace startup flags exist without dynamic ftrace

2023-12-18 Thread Masami Hiramatsu (Google)
to 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 v5 09/34] ftrace: Allow function_graph tracer to be enabled in instances

2023-12-18 Thread Masami Hiramatsu (Google)
-by: 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 v5 08/34] ftrace/function_graph: Pass fgraph_ops to function graph callbacks

2023-12-18 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 v5 07/34] function_graph: Remove logic around ftrace_graph_entry and return

2023-12-18 Thread Masami Hiramatsu (Google)
into the 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 | 71

[PATCH v5 06/34] function_graph: Allow multiple users to attach to function graph

2023-12-18 Thread Masami Hiramatsu (Google)
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 v2: - Check return value of the ftrace_pop_return_trace() instead of 'ret' since 'ret' is set to the address of panic

[PATCH v5 05/34] function_graph: Add an array structure that will allow multiple callbacks

2023-12-18 Thread Masami Hiramatsu (Google)
on 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: - Remove

[PATCH v5 04/34] fgraph: Use BUILD_BUG_ON() to make sure we have structures divisible by long

2023-12-18 Thread Masami Hiramatsu (Google)
dt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- 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 30edeb6d4aa9..837daf929d2a 100644 --- a/kernel/trace/fgraph.c +++ b/kernel/trac

[PATCH v5 03/34] function_graph: Convert ret_stack to a series of longs

2023-12-18 Thread Masami Hiramatsu (Google)
for 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

[PATCH v5 02/34] x86: tracing: Add ftrace_regs definition in the header

2023-12-18 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 v5 01/34] tracing: Add a comment about ftrace_regs definition

2023-12-18 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) --- Changes in v3: - Add instruction pointer Changes in v2: - newly added. --- include

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

2023-12-18 Thread Masami Hiramatsu (Google)
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) (19): tracing: Add a comment about ftrace_regs definition x86: tracing: Add ftrace_regs definition in the header

Re: [mhiramat:topic/fprobe-on-fgraph] [function_graph] b92a5e78c3: WARNING:at_kernel/trace/trace.c:#run_tracer_selftest

2023-12-18 Thread Google
) > [5.533126][T1] ---[ end trace ]--- > [5.534553][T1] prandom: seed boundary self test passed > [5.537152][T1] prandom: 100 self tests passed > [5.537152][T1] pinctrl core: initialized pinctrl subsystem > > > > The kernel config and materials to reproduce are available at: > https://download.01.org/0day-ci/archive/20231218/202312181100.508f8f48-oliver.s...@intel.com > > > > -- > 0-DAY CI Kernel Test Service > https://github.com/intel/lkp-tests/wiki > -- Masami Hiramatsu (Google)

Re: [PATCH] tracing: Add disable-filter-buf option

2023-12-17 Thread Google
r may be filled quickly than the user expected. Thus if user specifies the rare condition, most of the events on the ring buffer is filled with garbage. And user will know the buffer size *seems* smaller than the setting. I think copying overhead will be a secondary effect, the biggest noticable difference is how many events are recorded in the ring buffer. Thus, what about naming the option as "filter-on-buffer"? If we introduce filtering on input directly, at that point we will use it if "filter-on-buffer = no", because this is also not noticable from users. Thank you, -- Masami Hiramatsu (Google)

Re: [PATCH v4] trace/kprobe: Display the actual notrace function when rejecting a probe

2023-12-16 Thread Google
if (within_notrace_func(tk)) { > - pr_warn("Could not probe notrace function %s\n", > - trace_kprobe_symbol(tk)); > + pr_warn("Could not probe notrace function %ps\n", > + (void *)trace_kprobe_address(tk)); > return -EINVAL; > } > > > base-commit: 4758560fa268cecfa1144f015aa9f2525d164b7e > -- > 2.43.0 > -- Masami Hiramatsu (Google)

Re: [PATCH v3] trace/kprobe: Display the actual notrace function when rejecting a probe

2023-12-13 Thread Google
lookup_symbol_name(addr, symname) ? > trace_kprobe_symbol(tk) : symname); Can we just use %ps and (void *)trace_kprobe_address(tk) here? That will be simpler. Thank you, > return -EINVAL; > } > > > base-commit: 4758560fa268cecfa1144f015aa9f2525d164b7e > -- > 2.43.0 > -- Masami Hiramatsu (Google)

Re: [PATCH] ring-buffer: Do not update before stamp when switching sub-buffers

2023-12-12 Thread Google
On Mon, 11 Dec 2023 11:44:20 -0500 Steven Rostedt wrote: > From: "Steven Rostedt (Google)" > > The ring buffer timestamps are synchronized by two timestamp placeholders. > One is the "before_stamp" and the other is the "write_stamp" (sometimes &

Re: [PATCH] tracing: Have trace_marker break up by lines by size of trace_seq

2023-12-12 Thread Google
On Tue, 12 Dec 2023 19:04:22 -0500 Steven Rostedt wrote: > From: "Steven Rostedt (Google)" > > If a trace_marker write is bigger than what trace_seq can hold, then it > will print "LINE TOO BIG" message and not what was written. > > Instead, if check if

Re: [PATCH v4] tracing: Allow for max buffer data size trace_marker writes

2023-12-12 Thread Google
On Tue, 12 Dec 2023 13:19:01 -0500 Steven Rostedt wrote: > From: "Steven Rostedt (Google)" > > Allow a trace write to be as big as the ring buffer tracing data will > allow. Currently, it only allows writes of 1KB in size, but there's no > reason that it cannot allow

Re: [PATCH v3] ring-buffer: Fix writing to the buffer with max_data_size

2023-12-12 Thread Google
On Tue, 12 Dec 2023 11:16:17 -0500 Steven Rostedt wrote: > From: "Steven Rostedt (Google)" > > The maximum ring buffer data size is the maximum size of data that can be > recorded on the ring buffer. Events must be smaller than the sub buffer > data size minus

Re: [PATCH] tracing: Add size check when printing trace_marker output

2023-12-12 Thread Google
On Tue, 12 Dec 2023 08:44:44 -0500 Steven Rostedt wrote: > From: "Steven Rostedt (Google)" > > If for some reason the trace_marker write does not have a nul byte for the > string, it will overflow the print: > > trace_seq_printf(s, ": %s", field->b

Re: [PATCH v2] ring-buffer: Never use absolute timestamp for first event

2023-12-12 Thread Google
On Tue, 12 Dec 2023 07:18:37 -0500 Steven Rostedt wrote: > From: "Steven Rostedt (Google)" > > On 32bit machines, the 64 bit timestamps are broken up into 32 bit words > to keep from using local64_cmpxchg(), as that is very expensive on 32 bit > architectures. >

Re: [PATCH] ring-buffer: Never use absolute timestamp for start event

2023-12-11 Thread Google
On Mon, 11 Dec 2023 11:59:49 -0500 Steven Rostedt wrote: > From: "Steven Rostedt (Google)" > > On 32bit machines, the 64 bit timestamps are broken up into 32 bit words > to keep from using local64_cmpxchg(), as that is very expensive on 32 bit > architectures. >

Re: [PATCH] tracing: Update snapshot buffer on resize if it is allocated

2023-12-11 Thread Google
On Mon, 11 Dec 2023 12:51:52 -0500 Steven Rostedt wrote: > On Mon, 11 Dec 2023 21:31:34 +0900 > Masami Hiramatsu (Google) wrote: > > > On Sun, 10 Dec 2023 22:54:47 -0500 > > Steven Rostedt wrote: > > > > > From: "Steven Rostedt (Google)" > &g

Re: [PATCH] trace_seq: Increase the buffer size to almost two pages

2023-12-11 Thread Google
On Mon, 11 Dec 2023 13:28:37 -0500 Steven Rostedt wrote: > On Mon, 11 Dec 2023 21:46:27 +0900 > Masami Hiramatsu (Google) wrote: > > > > > > > By increasing the trace_seq buffer to almost two pages, it can now print > > > out the first line. >

Re: [PATCH] trace_seq: Increase the buffer size to almost two pages

2023-12-11 Thread Google
On Sat, 9 Dec 2023 17:52:20 -0500 Steven Rostedt wrote: > From: "Steven Rostedt (Google)" > > Now that trace_marker can hold more than 1KB string, and can write as much > as the ring buffer can hold, the trace_seq is not big enough to hold > writes: > > ~

Re: [PATCH] tracing: Update snapshot buffer on resize if it is allocated

2023-12-11 Thread Google
On Sun, 10 Dec 2023 22:54:47 -0500 Steven Rostedt wrote: > From: "Steven Rostedt (Google)" > > The snapshot buffer is to mimic the main buffer so that when a snapshot is > needed, the snapshot and main buffer are swapped. When the snapshot buffer > is allocated, it i

Re: [PATCH] ring-buffer: Fix memory leak of free page

2023-12-11 Thread Google
On Sun, 10 Dec 2023 22:12:50 -0500 Steven Rostedt wrote: > From: "Steven Rostedt (Google)" > > Reading the ring buffer does a swap of a sub-buffer within the ring buffer > with a empty sub-buffer. This allows the reader to have full access to the > content of the su

Re: [PATCH] tracing: Increase size of trace_marker_raw to max ring buffer entry

2023-12-11 Thread Google
On Sat, 9 Dec 2023 17:57:16 -0500 Steven Rostedt wrote: > From: "Steven Rostedt (Google)" > > There's no reason to give an arbitrary limit to the size of a raw trace > marker. Just let it be as big as the size that is allowed by the ring > buffer itself. >

Re: [PATCH] tracing: Have large events show up as '[LINE TOO BIG]' instead of nothing

2023-12-11 Thread Google
output, I would perfer this output. > > > > > It would be better to print the partial line, and end the line with > > a tag. But how long the partial line length is good enough? I think that big (and long) user marker maybe not for human, so we don't need to care about readabili

Re: [PATCH] ring-buffer: Fix buffer max_data_size with max_event_size

2023-12-11 Thread Google
On Sat, 9 Dec 2023 17:09:25 -0500 Steven Rostedt wrote: > On Sat, 9 Dec 2023 17:01:39 -0500 > Steven Rostedt wrote: > > > From: "Steven Rostedt (Google)" > > > > The maximum ring buffer data size is the maximum size of data that can be > > recorded

Re: WARNING: kmalloc bug in bpf_uprobe_multi_link_attach

2023-12-11 Thread Google
ti (which uses fprobe instead of kprobe). The warning warns that the required size is bigger than INT_MAX. Maybe too many links or uprobes were going to be allocated? Thanks, > > kernel: net 28a7cb045ab700de5554193a1642917602787784 > Kernel config: > https://github.com/goo

Re: [PATCH 2/6] module: add CONFIG_BUILTIN_RANGES option

2023-12-08 Thread Google
odule(s) they belong to. > + It also records an anchor symbol to determine the load address of the > + section. > + > + It is fully compatible with CONFIG_RANDOMIZE_BASE and similar late- > + address-modification options. > + > endif # MODULES > -- > 2.42.0 > -- Masami Hiramatsu (Google)

Re: [PATCH v2] ring-buffer: Add offset of events in dump on mismatch

2023-12-08 Thread Google
On Thu, 7 Dec 2023 17:31:08 -0500 Steven Rostedt wrote: > From: "Steven Rostedt (Google)" > > On bugs that have the ring buffer timestamp get out of sync, the config > CONFIG_RING_BUFFER_VALIDATE_TIME_DELTAS, that checks for it and if it is > detected it causes a d

[PATCH v4 33/33] Documentation: probes: Update fprobe on function-graph tracer

2023-12-08 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 v4 32/33] selftests: ftrace: Remove obsolate maxactive syntax check

2023-12-08 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 v4 31/33] bpf: Enable kprobe_multi feature if CONFIG_FPROBE is enabled

2023-12-08 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 v4 30/33] tracing/fprobe: Enable fprobe events with CONFIG_DYNAMIC_FTRACE_WITH_ARGS

2023-12-08 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 from

[PATCH v4 29/33] tracing/fprobe: Remove nr_maxactive from fprobe

2023-12-08 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 v4 28/33] fprobe: Rewrite fprobe on function-graph tracer

2023-12-08 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_FREGS. So

[PATCH v4 27/33] tracing: Add ftrace_fill_perf_regs() for perf event

2023-12-08 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-by: Masami

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

2023-12-08 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 v4 25/33] fprobe: Use ftrace_regs in fprobe exit handler

2023-12-08 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 a new

[PATCH v4 23/33] arm64: ftrace: Enable HAVE_FUNCTION_GRAPH_FREGS

2023-12-08 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 v4 24/33] fprobe: Use ftrace_regs in fprobe entry handler

2023-12-08 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 from previous series: NOTHING

[PATCH v4 22/33] tracing: Rename ftrace_regs_return_value to ftrace_regs_get_return_value

2023-12-08 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) --- Changes in v3: - Newly added. --- arch/loongarch/include/asm/ftrace.h |2 +- arch/powerpc/include

[PATCH v4 21/33] x86/ftrace: Enable HAVE_FUNCTION_GRAPH_FREGS

2023-12-08 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 other registers

[PATCH v4 20/33] function_graph: Add a new exit handler with parent_ip and ftrace_regs

2023-12-08 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 'reregfunc' are mutual

[PATCH v4 19/33] function_graph: Add a new entry handler with parent_ip and ftrace_regs

2023-12-08 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 Hiramatsu (Google) --- Changes in v3

[PATCH v4 18/33] function_graph: Add selftest for passing local variables

2023-12-08 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 v4 17/33] function_graph: Implement fgraph_reserve_data() and fgraph_retrieve_data()

2023-12-08 Thread Masami Hiramatsu (Google)
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 requires

[PATCH v4 16/33] function_graph: Move graph notrace bit to shadow stack global var

2023-12-08 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 v4 15/33] function_graph: Move graph depth stored data to shadow stack global var

2023-12-08 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 v4 14/33] function_graph: Move set_graph_function tests to shadow stack global var

2023-12-08 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 v4 13/33] function_graph: Add "task variables" per task for fgraph_ops

2023-12-08 Thread Masami Hiramatsu (Google)
s 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 chars. --

[PATCH v4 12/33] function_graph: Use a simple LRU for fgraph_array index number

2023-12-08 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 v4 11/33] function_graph: Have the instances use their own ftrace_ops for filtering

2023-12-08 Thread Masami Hiramatsu (Google)
unc. But that is not enough for the self- recursive tail-call case. Thus fgraph uses the bitmap entry to find it is already set (this means that entry is for previous tail call). Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- Changes in v4: - Simplify get_ret_stack() sanity ch

[PATCH v4 10/33] ftrace: Allow ftrace startup flags exist without dynamic ftrace

2023-12-08 Thread Masami Hiramatsu (Google)
to 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 v4 09/33] ftrace: Allow function_graph tracer to be enabled in instances

2023-12-08 Thread Masami Hiramatsu (Google)
-by: 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 v4 08/33] ftrace/function_graph: Pass fgraph_ops to function graph callbacks

2023-12-08 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 v4 07/33] function_graph: Remove logic around ftrace_graph_entry and return

2023-12-08 Thread Masami Hiramatsu (Google)
into the 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 | 71

[PATCH v4 06/33] function_graph: Allow multiple users to attach to function graph

2023-12-08 Thread Masami Hiramatsu (Google)
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 v2: - Check return value of the ftrace_pop_return_trace() instead of 'ret' since 'ret' is set to the address of panic

[PATCH v4 05/33] function_graph: Add an array structure that will allow multiple callbacks

2023-12-08 Thread Masami Hiramatsu (Google)
on 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: - Remove

[PATCH v4 04/33] fgraph: Use BUILD_BUG_ON() to make sure we have structures divisible by long

2023-12-08 Thread Masami Hiramatsu (Google)
dt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- 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 30edeb6d4aa9..837daf929d2a 100644 --- a/kernel/trace/fgraph.c +++ b/kernel/trac

[PATCH v4 03/33] function_graph: Convert ret_stack to a series of longs

2023-12-08 Thread Masami Hiramatsu (Google)
for 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

[PATCH v4 02/33] x86: tracing: Add ftrace_regs definition in the header

2023-12-08 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 v4 01/33] tracing: Add a comment about ftrace_regs definition

2023-12-08 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) --- Changes in v3: - Add instruction pointer Changes in v2: - newly added. --- include

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

2023-12-08 Thread Masami Hiramatsu (Google)
ed against the trace-v6.7-rc4 on linux-trace tree. 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) (18): tracing: Add a comment about ftrace_regs definition

Re: [PATCH v3 12/33] function_graph: Have the instances use their own ftrace_ops for filtering

2023-12-05 Thread Google
Hi, On Mon, 27 Nov 2023 22:55:22 +0900 "Masami Hiramatsu (Google)" wrote: > @@ -243,6 +254,27 @@ ftrace_push_return_trace(unsigned long ret, unsigned > long func, > if (!current->ret_stack) > return -EBUSY; > > +

Re: [PATCH v2] rethook: Use __rcu pointer for rethook::handler

2023-11-30 Thread Google
On Thu, 30 Nov 2023 13:44:55 -0800 JP Kobryn wrote: > On Wed, Nov 29, 2023 at 09:24:22PM +0900, Masami Hiramatsu (Google) wrote: > > From: Masami Hiramatsu (Google) > > > > Since the rethook::handler is an RCU-maganged pointer so that it will > > notice rea

Re: [PATCH] tracing: Allow creating instances with specified system events

2023-11-30 Thread Google
On Wed, 29 Nov 2023 10:25:45 -0500 Steven Rostedt wrote: > On Wed, 29 Nov 2023 23:58:21 +0900 > Masami Hiramatsu (Google) wrote: > > > > - Dynamic events had to be specified directly to still allow them to be > > > created. > > > > I have a qu

Re: [PATCH] tracing: Allow creating instances with specified system events

2023-11-29 Thread Google
On Tue, 28 Nov 2023 12:21:17 -0500 Steven Rostedt wrote: > From: "Steven Rostedt (Google)" > > A trace instance may only need to enable specific events. As the eventfs > directory of an instance currently creates all events which adds overhead, > allow interna

Re: [RFC][PATCH] tracing: Allow creating instances with specified system events

2023-11-28 Thread Google
Hi Steve, On Mon, 27 Nov 2023 17:41:08 -0500 Steven Rostedt wrote: > From: "Steven Rostedt (Google)" > > A trace instance may only need to enable specific events. As the eventfs > directory of an instance currently creates all events which adds overhead, >

Re: [PATCH v3 28/33] fprobe: Rewrite fprobe on function-graph tracer

2023-11-28 Thread Google
On Tue, 28 Nov 2023 11:53:19 +0100 Jiri Olsa wrote: > On Mon, Nov 27, 2023 at 10:58:40PM +0900, Masami Hiramatsu (Google) wrote: > > From: Masami Hiramatsu (Google) > > > > Rewrite fprobe implementation on function-graph tracer. > > Major API changes are: &

Re: [PATCH] rethook: Use __rcu pointer for rethook::handler

2023-11-27 Thread Google
rong git tree, kindly drop us a note. > And when submitting patch, we suggest to use '--base' as documented in > https://git-scm.com/docs/git-format-patch#_base_tree_information] > > url: > https://github.com/intel-lab-lkp/linux/commits/Masami-Hiramatsu-Google/rethook-Use-__rcu-

[PATCH v3 33/33] Documentation: probes: Update fprobe on function-graph tracer

2023-11-27 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 v3 32/33] selftests: ftrace: Remove obsolate maxactive syntax check

2023-11-27 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 v3 31/33] bpf: Enable kprobe_multi feature if CONFIG_FPROBE is enabled

2023-11-27 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

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