Skip to content

Commit 90c275e

Browse files
Frankenweenopsiff
authored andcommitted
ftrace: Fix softlockup in ftrace_module_enable
[ Upstream commit 4099b98 ] 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 d0b24b4 ("ftrace: Prevent RCU stall on PREEMPT_VOLUNTARY kernels") and commit 42ea22e ("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 <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit e81e6d6d99b16dae11adbeda5c996317942a940c) Signed-off-by: Wentao Guan <[email protected]>
1 parent c430f81 commit 90c275e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

kernel/trace/ftrace.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6873,6 +6873,8 @@ void ftrace_module_enable(struct module *mod)
68736873
if (!within_module(rec->ip, mod))
68746874
break;
68756875

6876+
cond_resched();
6877+
68766878
/* Weak functions should still be ignored */
68776879
if (!test_for_valid_rec(rec)) {
68786880
/* Clear all other flags. Should not be enabled anyway */

0 commit comments

Comments
 (0)