Thread (53 messages) flat view 53 messages, 4 authors, 2024-10-02

Re: [PATCH v14 05/19] function_graph: Pass ftrace_regs to retfunc

From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Date: 2024-10-01 23:24:46
Also in: linux-arm-kernel, lkml

On Mon, 30 Sep 2024 15:03:02 -0400
Steven Rostedt [off-list ref] wrote:
On Tue, 17 Sep 2024 11:08:48 +0100
Will Deacon [off-list ref] wrote:
quoted
quoted
quoted
@@ -787,6 +789,9 @@ __ftrace_return_to_handler(struct ftrace_regs *fregs, unsigned long frame_pointe
 	}
 
 	trace.rettime = trace_clock_local();
+	if (fregs)
+		ftrace_regs_set_instruction_pointer(fregs, ret);  
Where does the instruction pointer get used after this? The arm64
'return_to_handler' function doesn't look at it when we return.
It's for the hooks to the return instruction. kretprobes will start using
not kretprobes, but fprobe. kretprobes continue using rethook.
function graph tracer to hook to a return of a function (via fprobes), and
the callbacks will need access to the return pointer. The callbacks get
passed the ftrace_regs, and this is how they can see what the function is
returning to. For example, BPF programs will need this.

So it's not needed for the infrastructure, only the callbacks that hook to
it.
Yes, it will be used for showing where to return in the fprobe exit event.
More specifically, in the fprobe_return()@kernel/trace/fprobe.c in PATCH 13/19,
it is extracted from fregs.

+static void fprobe_return(struct ftrace_graph_ret *trace,
+			  struct fgraph_ops *gops,
+			  struct ftrace_regs *fregs)
+{
+	unsigned long *fgraph_data = NULL;
+	unsigned long ret_ip;
+	unsigned long val;
+	struct fprobe *fp;
+	int size, curr;
+	int size_words;
+
+	fgraph_data = (unsigned long *)fgraph_retrieve_data(gops->idx, &size);
+	if (WARN_ON_ONCE(!fgraph_data))
 		return;
+	size_words = SIZE_IN_LONG(size);
+	ret_ip = ftrace_regs_get_instruction_pointer(fregs);
+

Thank you,
-- Steve

-- 
Masami Hiramatsu (Google) [off-list ref]
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help