summaryrefslogtreecommitdiff
path: root/kernel/trace/ftrace.c
diff options
context:
space:
mode:
authorVladimir Riabchun <ferr.lambarginio@gmail.com>2025-09-12 13:28:55 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-11-24 10:29:46 +0100
commite81e6d6d99b16dae11adbeda5c996317942a940c (patch)
treeaaae86480053503c0ac11ece4bbedb907d3a07d4 /kernel/trace/ftrace.c
parente09a096104fc65859422817fb2211f35855983fe (diff)
downloadlinux-e81e6d6d99b16dae11adbeda5c996317942a940c.tar.gz
linux-e81e6d6d99b16dae11adbeda5c996317942a940c.tar.bz2
linux-e81e6d6d99b16dae11adbeda5c996317942a940c.zip
ftrace: Fix softlockup in ftrace_module_enable
[ Upstream commit 4099b98203d6b33d990586542fa5beee408032a3 ] A soft lockup was observed when loading amdgpu module. If a module has a lot of tracable functions, multiple calls to kallsyms_lookup can spend too much time in RCU critical section and with disabled preemption, causing kernel panic. This is the same issue that was fixed in commit d0b24b4e91fc ("ftrace: Prevent RCU stall on PREEMPT_VOLUNTARY kernels") and commit 42ea22e754ba ("ftrace: Add cond_resched() to ftrace_graph_set_hash()"). Fix it the same way by adding cond_resched() in ftrace_module_enable. Link: https://lore.kernel.org/aMQD9_lxYmphT-up@vova-pc Signed-off-by: Vladimir Riabchun <ferr.lambarginio@gmail.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'kernel/trace/ftrace.c')
-rw-r--r--kernel/trace/ftrace.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 15785a729a0c..398992597685 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -6873,6 +6873,8 @@ void ftrace_module_enable(struct module *mod)
if (!within_module(rec->ip, mod))
break;
+ cond_resched();
+
/* Weak functions should still be ignored */
if (!test_for_valid_rec(rec)) {
/* Clear all other flags. Should not be enabled anyway */