Skip to contentSkip to conversation

function_graph: remove unnecessary initialization in ftrace_graph_ret_addr()

PATCH Superseded Oleg Nesterov 2 participants 3 messages Sep 16, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 function_graph: remove unnecessary initialization in ftrace_graph_ret_addr()

After the commit 29c1c24a2707 ("function_graph: Fix up ftrace_graph_ret_addr()") ftrace_graph_ret_addr() doesn't need to initialize "int i" at the start.

While at it, move the declaration of "ret_stack" into the main loop.

---
 kernel/trace/fgraph.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
kernel/trace/fgraph.c +2 -3
index d7d4fb403f6f..d45a8bc97997 100644
@@ -890,9 +890,8 @@ ftrace_graph_get_ret_stack(struct task_struct *task, int idx)
 unsigned long ftrace_graph_ret_addr(struct task_struct *task, int *idx,
 				    unsigned long ret, unsigned long *retp)
 {
-	struct ftrace_ret_stack *ret_stack;
 	unsigned long return_handler = (unsigned long)dereference_kernel_function_descriptor(return_to_handler);
-	int i = task->curr_ret_stack;
+	int i;
 
 	if (ret != return_handler)
 		return ret;
@@ -902,7 +901,7 @@ unsigned long ftrace_graph_ret_addr(struct task_struct *task, int *idx,
 
 	i = *idx ? : task->curr_ret_stack;
 	while (i > 0) {
-		ret_stack = get_ret_stack(task, i, &i);
+		struct ftrace_ret_stack *ret_stack = get_ret_stack(task, i, &i);
 		if (!ret_stack)
 			break;
 		/*
Signature · 1 line
2.25.1.362.g51ebf55
maintainer
#1 lore raw
Quoted 4 lines · On Mon, 16 Sep 2024 15:56:43 +0200 Oleg Nesterov <[email protected]> wrote:

After the commit 29c1c24a2707 ("function_graph: Fix up ftrace_graph_ret_addr()") ftrace_graph_ret_addr() doesn't need to initialize "int i" at the start.

While at it, move the declaration of "ret_stack" into the main loop.

Should not make two changes like this, because it risks the entire patch being denied.

Quoted 11 lines
---
 kernel/trace/fgraph.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
kernel/trace/fgraph.c +0 -0
index d7d4fb403f6f..d45a8bc97997 100644

kernel/trace/fgraph.c ftrace_graph_get_ret_stack(struct task_struct *task, int idx) · line 894

Quoted 7 lines
kernel/trace/fgraph.c +1 -2
@@ -890,9 +890,8 @@ ftrace_graph_get_ret_stack(struct task_struct *task, int idx)
 unsigned long ftrace_graph_ret_addr(struct task_struct *task, int *idx,
 				    unsigned long ret, unsigned long *retp)
 {
-	struct ftrace_ret_stack *ret_stack;
 	unsigned long return_handler = (unsigned long)dereference_kernel_function_descriptor(return_to_handler);
-	int i = task->curr_ret_stack;
+	int i;

I'm fine with removing the unneeded init of i.

kernel/trace/fgraph.c unsigned long ftrace_graph_ret_addr(struct task_struct *task, int *idx, · line 904

Quoted 9 lines
kernel/trace/fgraph.c +1 -1
 	if (ret != return_handler)
 		return ret;
@@ -902,7 +901,7 @@ unsigned long ftrace_graph_ret_addr(struct task_struct *task, int *idx,
 
 	i = *idx ? : task->curr_ret_stack;
 	while (i > 0) {
-		ret_stack = get_ret_stack(task, i, &i);
+		struct ftrace_ret_stack *ret_stack = get_ret_stack(task, i, &i);

This is just a preference. Sometimes I like the declaration up on top, sometimes in the block it used. But this case, I wont it at top.

Please make a v2 with just the change to i.

-- Steve

Quoted 3 lines
kernel/trace/fgraph.c +0 -0
 		if (!ret_stack)
 			break;
 		/*
#2 lore raw

PATCH v2 1/1 function_graph: remove unnecessary initialization in ftrace_graph_ret_addr()

After the commit 29c1c24a2707 ("function_graph: Fix up ftrace_graph_ret_addr()") ftrace_graph_ret_addr() doesn't need to initialize "int i" at the start.

---
 kernel/trace/fgraph.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/fgraph.c +1 -1
index d7d4fb403f6f..45c02bf18304 100644
@@ -892,7 +892,7 @@ unsigned long ftrace_graph_ret_addr(struct task_struct *task, int *idx,
 {
 	struct ftrace_ret_stack *ret_stack;
 	unsigned long return_handler = (unsigned long)dereference_kernel_function_descriptor(return_to_handler);
-	int i = task->curr_ret_stack;
+	int i;
 
 	if (ret != return_handler)
 		return ret;
Signature · 1 line
2.25.1.362.g51ebf55