* [for-linus][PATCH 0/2] fgraph: Fixes for 6.12
@ 2024-10-25 10:19 Steven Rostedt
2024-10-25 10:19 ` [for-linus][PATCH 1/2] fgraph: Fix missing unlock in register_ftrace_graph() Steven Rostedt
2024-10-25 10:19 ` [for-linus][PATCH 2/2] fgraph: Change the name of cpuhp state to "fgraph:online" Steven Rostedt
0 siblings, 2 replies; 3+ messages in thread
From: Steven Rostedt @ 2024-10-25 10:19 UTC (permalink / raw)
To: linux-kernel
Cc: Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers, Andrew Morton
Fixes for function graph:
- Fix missing mutex unlock in error path of register_ftrace_graph()
A previous fix added a return on an error path and forgot to unlock the
mutex. Instead of dealing with error paths, use guard(mutex) as the mutex
is just released at the exit of the function anyway. Other functions
in this file should be updated with this, but that's a cleanup and not
a fix.
- Change cpuhp setup name to be consistent with other cpuhp states
The same fix that the above patch fixes added a cpuhp_setup_state() call
with the name of "fgraph_idle_init". I was informed that it should instead
be something like: "fgraph:online". Update that too.
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
ftrace/fixes
Head SHA1: a574e7f80e86c740e241c762923f50077b2c2a30
Li Huafei (1):
fgraph: Fix missing unlock in register_ftrace_graph()
Steven Rostedt (1):
fgraph: Change the name of cpuhp state to "fgraph:online"
----
kernel/trace/fgraph.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
^ permalink raw reply [flat|nested] 3+ messages in thread* [for-linus][PATCH 1/2] fgraph: Fix missing unlock in register_ftrace_graph()
2024-10-25 10:19 [for-linus][PATCH 0/2] fgraph: Fixes for 6.12 Steven Rostedt
@ 2024-10-25 10:19 ` Steven Rostedt
2024-10-25 10:19 ` [for-linus][PATCH 2/2] fgraph: Change the name of cpuhp state to "fgraph:online" Steven Rostedt
1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2024-10-25 10:19 UTC (permalink / raw)
To: linux-kernel
Cc: Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers, Andrew Morton,
kernel test robot, Dan Carpenter, Li Huafei
From: Li Huafei <lihuafei1@huawei.com>
Use guard(mutex)() to acquire and automatically release ftrace_lock,
fixing the issue of not unlocking when calling cpuhp_setup_state()
fails.
Fixes smatch warning:
kernel/trace/fgraph.c:1317 register_ftrace_graph() warn: inconsistent returns '&ftrace_lock'.
Link: https://lore.kernel.org/20241024155917.1019580-1-lihuafei1@huawei.com
Fixes: 2c02f7375e65 ("fgraph: Use CPU hotplug mechanism to initialize idle shadow stacks")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202410220121.wxg0olfd-lkp@intel.com/
Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Li Huafei <lihuafei1@huawei.com>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
kernel/trace/fgraph.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c
index 41e7a15dcb50..cd1c2946018c 100644
--- a/kernel/trace/fgraph.c
+++ b/kernel/trace/fgraph.c
@@ -1252,7 +1252,7 @@ int register_ftrace_graph(struct fgraph_ops *gops)
int ret = 0;
int i = -1;
- mutex_lock(&ftrace_lock);
+ guard(mutex)(&ftrace_lock);
if (!fgraph_initialized) {
ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "fgraph_idle_init",
@@ -1273,10 +1273,8 @@ int register_ftrace_graph(struct fgraph_ops *gops)
}
i = fgraph_lru_alloc_index();
- if (i < 0 || WARN_ON_ONCE(fgraph_array[i] != &fgraph_stub)) {
- ret = -ENOSPC;
- goto out;
- }
+ if (i < 0 || WARN_ON_ONCE(fgraph_array[i] != &fgraph_stub))
+ return -ENOSPC;
gops->idx = i;
ftrace_graph_active++;
@@ -1313,8 +1311,6 @@ int register_ftrace_graph(struct fgraph_ops *gops)
gops->saved_func = NULL;
fgraph_lru_release_index(i);
}
-out:
- mutex_unlock(&ftrace_lock);
return ret;
}
--
2.45.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* [for-linus][PATCH 2/2] fgraph: Change the name of cpuhp state to "fgraph:online"
2024-10-25 10:19 [for-linus][PATCH 0/2] fgraph: Fixes for 6.12 Steven Rostedt
2024-10-25 10:19 ` [for-linus][PATCH 1/2] fgraph: Fix missing unlock in register_ftrace_graph() Steven Rostedt
@ 2024-10-25 10:19 ` Steven Rostedt
1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2024-10-25 10:19 UTC (permalink / raw)
To: linux-kernel
Cc: Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers, Andrew Morton,
Thomas Gleixner
From: Steven Rostedt <rostedt@goodmis.org>
The cpuhp state name given to cpuhp_setup_state() is "fgraph_idle_init"
which doesn't really conform to the names that are used for cpu hotplug
setups. Instead rename it to "fgraph:online" to be in line with other
states.
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/20241024222944.473d88c5@rorschach.local.home
Suggested-by: Masami Hiramatsu <mhiramat@kernel.org>
Fixes: 2c02f7375e658 ("fgraph: Use CPU hotplug mechanism to initialize idle shadow stacks")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
kernel/trace/fgraph.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c
index cd1c2946018c..69e226a48daa 100644
--- a/kernel/trace/fgraph.c
+++ b/kernel/trace/fgraph.c
@@ -1255,7 +1255,7 @@ int register_ftrace_graph(struct fgraph_ops *gops)
guard(mutex)(&ftrace_lock);
if (!fgraph_initialized) {
- ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "fgraph_idle_init",
+ ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "fgraph:online",
fgraph_cpu_init, NULL);
if (ret < 0) {
pr_warn("fgraph: Error to init cpu hotplug support\n");
--
2.45.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-25 10:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-25 10:19 [for-linus][PATCH 0/2] fgraph: Fixes for 6.12 Steven Rostedt
2024-10-25 10:19 ` [for-linus][PATCH 1/2] fgraph: Fix missing unlock in register_ftrace_graph() Steven Rostedt
2024-10-25 10:19 ` [for-linus][PATCH 2/2] fgraph: Change the name of cpuhp state to "fgraph:online" Steven Rostedt
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.