* [PATCH v2] x86/alternatives: Add cond_resched() to text_poke_bp_batch()
@ 2023-05-31 13:24 Steven Rostedt
2023-06-01 4:48 ` Masami Hiramatsu
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Steven Rostedt @ 2023-05-31 13:24 UTC (permalink / raw)
To: LKML, x86
Cc: Masami Hiramatsu, Thomas Gleixner, Ingo Molnar, Peter Zijlstra,
Borislav Petkov
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
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) <rostedt@goodmis.org>
---
Changes since v1: https://lkml.kernel.org/r/20230528084652.5f3b48f0@rorschach.local.home
- Just call cond_resched() once in text_poke_bp_batch() and not for
each phase, as it only needs to be called once every 256 entries.
arch/x86/kernel/alternative.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index f615e0cb6d93..412ad66cd240 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -1953,6 +1953,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.
--
2.39.2
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] x86/alternatives: Add cond_resched() to text_poke_bp_batch()
2023-05-31 13:24 [PATCH v2] x86/alternatives: Add cond_resched() to text_poke_bp_batch() Steven Rostedt
@ 2023-06-01 4:48 ` Masami Hiramatsu
2023-06-13 14:01 ` Steven Rostedt
2023-06-14 17:42 ` [tip: x86/alternatives] " tip-bot2 for Steven Rostedt (Google)
2 siblings, 0 replies; 4+ messages in thread
From: Masami Hiramatsu @ 2023-06-01 4:48 UTC (permalink / raw)
To: Steven Rostedt
Cc: LKML, x86, Masami Hiramatsu, Thomas Gleixner, Ingo Molnar,
Peter Zijlstra, Borislav Petkov
On Wed, 31 May 2023 09:24:19 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:
> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
>
> 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.
>
Looks good to me.
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Thank you!
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
> Changes since v1: https://lkml.kernel.org/r/20230528084652.5f3b48f0@rorschach.local.home
>
> - Just call cond_resched() once in text_poke_bp_batch() and not for
> each phase, as it only needs to be called once every 256 entries.
>
> arch/x86/kernel/alternative.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
> index f615e0cb6d93..412ad66cd240 100644
> --- a/arch/x86/kernel/alternative.c
> +++ b/arch/x86/kernel/alternative.c
> @@ -1953,6 +1953,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.
> --
> 2.39.2
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] x86/alternatives: Add cond_resched() to text_poke_bp_batch()
2023-05-31 13:24 [PATCH v2] x86/alternatives: Add cond_resched() to text_poke_bp_batch() Steven Rostedt
2023-06-01 4:48 ` Masami Hiramatsu
@ 2023-06-13 14:01 ` Steven Rostedt
2023-06-14 17:42 ` [tip: x86/alternatives] " tip-bot2 for Steven Rostedt (Google)
2 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2023-06-13 14:01 UTC (permalink / raw)
To: LKML, x86
Cc: Masami Hiramatsu, Thomas Gleixner, Ingo Molnar, Peter Zijlstra,
Borislav Petkov
Peter,
Can you ack this? And then I can push it through my tree.
Thanks!
-- Steve
On Wed, 31 May 2023 09:24:19 -0400
Steven Rostedt <rostedt@goodmis.org> (by way of Steven Rostedt <rostedt@goodmis.org>) wrote:
> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
>
> 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) <rostedt@goodmis.org>
> ---
> Changes since v1: https://lkml.kernel.org/r/20230528084652.5f3b48f0@rorschach.local.home
>
> - Just call cond_resched() once in text_poke_bp_batch() and not for
> each phase, as it only needs to be called once every 256 entries.
>
> arch/x86/kernel/alternative.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
> index f615e0cb6d93..412ad66cd240 100644
> --- a/arch/x86/kernel/alternative.c
> +++ b/arch/x86/kernel/alternative.c
> @@ -1953,6 +1953,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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [tip: x86/alternatives] x86/alternatives: Add cond_resched() to text_poke_bp_batch()
2023-05-31 13:24 [PATCH v2] x86/alternatives: Add cond_resched() to text_poke_bp_batch() Steven Rostedt
2023-06-01 4:48 ` Masami Hiramatsu
2023-06-13 14:01 ` Steven Rostedt
@ 2023-06-14 17:42 ` tip-bot2 for Steven Rostedt (Google)
2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Steven Rostedt (Google) @ 2023-06-14 17:42 UTC (permalink / raw)
To: linux-tip-commits
Cc: Steven Rostedt (Google), Borislav Petkov (AMD),
Masami Hiramatsu (Google), Peter Zijlstra (Intel),
x86, linux-kernel
The following commit has been merged into the x86/alternatives branch of tip:
Commit-ID: 9350a629e839ca1c2b529a83a916cf2370bd1c64
Gitweb: https://git.kernel.org/tip/9350a629e839ca1c2b529a83a916cf2370bd1c64
Author: Steven Rostedt (Google) <rostedt@goodmis.org>
AuthorDate: Wed, 31 May 2023 09:24:19 -04:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Wed, 14 Jun 2023 18:50:00 +02:00
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) <rostedt@goodmis.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20230531092419.4d051374@rorschach.local.home
---
arch/x86/kernel/alternative.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index 0747d29..bbfbf7a 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.
*/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-06-14 17:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-31 13:24 [PATCH v2] x86/alternatives: Add cond_resched() to text_poke_bp_batch() Steven Rostedt
2023-06-01 4:48 ` Masami Hiramatsu
2023-06-13 14:01 ` Steven Rostedt
2023-06-14 17:42 ` [tip: x86/alternatives] " tip-bot2 for Steven Rostedt (Google)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome