From: Steven Rostedt (Google) Date: Wed, 31 May 2023 13:24:19 +0000 (-0400) Subject: x86/alternatives: Add cond_resched() to text_poke_bp_batch() X-Git-Tag: v6.6.7~2598^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;ds=sidebyside;h=9350a629e839ca1c2b529a83a916cf2370bd1c64;p=platform%2Fkernel%2Flinux-starfive.git x86/alternatives: Add cond_resched() to text_poke_bp_batch() Debugging in the kernel has started slowing down the kernel by a noticeable amount. The ftrace start up tests are triggering the softlockup watchdog on some boxes. This is caused by the start up tests that enable function and function graph tracing several times. Sprinkling cond_resched() just in the start up test code was not enough to stop the softlockup from triggering. It would sometimes trigger in the text_poke_bp_batch() code. When function tracing enables all functions, it will call text_poke_queue() to queue the places that need to be patched. Every 256 entries will do a "flush" that calls text_poke_bp_batch() to do the update of the 256 locations. As this is in a scheduleable context, calling cond_resched() at the start of text_poke_bp_batch() will ensure that other tasks could get a chance to run while the patching is happening. This keeps the softlockup from triggering in the start up tests. Signed-off-by: Steven Rostedt (Google) Signed-off-by: Borislav Petkov (AMD) Acked-by: Masami Hiramatsu (Google) Acked-by: Peter Zijlstra (Intel) Link: https://lore.kernel.org/r/20230531092419.4d051374@rorschach.local.home --- diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index 0747d29..bbfbf7ad 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -2119,6 +2119,16 @@ static void text_poke_bp_batch(struct text_poke_loc *tp, unsigned int nr_entries atomic_set_release(&bp_desc.refs, 1); /* + * Function tracing can enable thousands of places that need to be + * updated. This can take quite some time, and with full kernel debugging + * enabled, this could cause the softlockup watchdog to trigger. + * This function gets called every 256 entries added to be patched. + * Call cond_resched() here to make sure that other tasks can get scheduled + * while processing all the functions being patched. + */ + cond_resched(); + + /* * Corresponding read barrier in int3 notifier for making sure the * nr_entries and handler are correctly ordered wrt. patching. */