From: zhoumin Date: Mon, 31 Mar 2025 17:00:34 +0000 (+0800) Subject: ftrace: Add cond_resched() to ftrace_graph_set_hash() X-Git-Tag: v5.4.293~107 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e5b4ae6f01d4a510d5725eca7254519a1093920d;p=thirdparty%2Fkernel%2Fstable.git ftrace: Add cond_resched() to ftrace_graph_set_hash() commit 42ea22e754ba4f2b86f8760ca27f6f71da2d982c upstream. When the kernel contains a large number of functions that can be traced, the loop in ftrace_graph_set_hash() may take a lot of time to execute. This may trigger the softlockup watchdog. Add cond_resched() within the loop to allow the kernel to remain responsive even when processing a large number of functions. This matches the cond_resched() that is used in other locations of the code that iterates over all functions that can be traced. Cc: stable@vger.kernel.org Fixes: b9b0c831bed26 ("ftrace: Convert graph filter to use hash tables") Link: https://lore.kernel.org/tencent_3E06CE338692017B5809534B9C5C03DA7705@qq.com Signed-off-by: zhoumin Signed-off-by: Steven Rostedt (Google) Signed-off-by: Greg Kroah-Hartman --- diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index fd393ae987067..50c266f70b542 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -5506,6 +5506,7 @@ ftrace_graph_set_hash(struct ftrace_hash *hash, char *buffer) } } } + cond_resched(); } while_for_each_ftrace_rec(); out: mutex_unlock(&ftrace_lock);