* [PATCH] smp: prevent soft lockup in smp_call_function_many_cond
@ 2026-05-27 3:16 Mark Tomlinson
2026-06-02 21:18 ` Chris Packham
2026-06-03 1:37 ` Rik van Riel
0 siblings, 2 replies; 4+ messages in thread
From: Mark Tomlinson @ 2026-05-27 3:16 UTC (permalink / raw)
To: Madhavan Srinivasan, Thomas Gleixner
Cc: linux-kernel, linuxppc-dev, Mark Tomlinson
Using the PowerPC P2040 (e500mc) CPU, soft lockups can occasionally be
seen in smp_call_function_many_cond(). The conclusion is that this CPU
does not process the doorbell interrupt while in a data-storage (MMU)
exception. If more than one CPU in a multi core environment is calling
this function at the same time, it is possible for a deadlock to occur.
The fix for this is to call flush_smp_call_function_queue() before
waiting for responses from other CPUs. If there is something in the
queue, this is a good time to process it before busy-waiting on other
CPUs. On other architectures this call will quickly do nothing, as the
queue will be empty.
Signed-off-by: Mark Tomlinson <mark.tomlinson@alliedtelesis.co.nz>
---
kernel/smp.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/smp.c b/kernel/smp.c
index a0bb56bd8dda..3c4467654ab0 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -884,6 +884,8 @@ static void smp_call_function_many_cond(const struct cpumask *mask,
local_irq_restore(flags);
}
+ flush_smp_call_function_queue();
+
if (run_remote && wait) {
for_each_cpu(cpu, cfd->cpumask) {
call_single_data_t *csd;
--
2.54.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] smp: prevent soft lockup in smp_call_function_many_cond
2026-05-27 3:16 [PATCH] smp: prevent soft lockup in smp_call_function_many_cond Mark Tomlinson
@ 2026-06-02 21:18 ` Chris Packham
2026-06-04 17:52 ` Paul E. McKenney
2026-06-03 1:37 ` Rik van Riel
1 sibling, 1 reply; 4+ messages in thread
From: Chris Packham @ 2026-06-02 21:18 UTC (permalink / raw)
To: Mark Tomlinson, Madhavan Srinivasan, Thomas Gleixner, yury.norov,
paulmck, romank, rafael.j.wysocki, riel, joelagnelf
Cc: linux-kernel, linuxppc-dev
(adding others suggested by get_maintainer.pl)
On 27/05/2026 15:16, Mark Tomlinson wrote:
> Using the PowerPC P2040 (e500mc) CPU, soft lockups can occasionally be
> seen in smp_call_function_many_cond(). The conclusion is that this CPU
> does not process the doorbell interrupt while in a data-storage (MMU)
> exception. If more than one CPU in a multi core environment is calling
> this function at the same time, it is possible for a deadlock to occur.
>
> The fix for this is to call flush_smp_call_function_queue() before
> waiting for responses from other CPUs. If there is something in the
> queue, this is a good time to process it before busy-waiting on other
> CPUs. On other architectures this call will quickly do nothing, as the
> queue will be empty.
>
> Signed-off-by: Mark Tomlinson <mark.tomlinson@alliedtelesis.co.nz>
> ---
> kernel/smp.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/kernel/smp.c b/kernel/smp.c
> index a0bb56bd8dda..3c4467654ab0 100644
> --- a/kernel/smp.c
> +++ b/kernel/smp.c
> @@ -884,6 +884,8 @@ static void smp_call_function_many_cond(const struct cpumask *mask,
> local_irq_restore(flags);
> }
>
> + flush_smp_call_function_queue();
> +
> if (run_remote && wait) {
> for_each_cpu(cpu, cfd->cpumask) {
> call_single_data_t *csd;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] smp: prevent soft lockup in smp_call_function_many_cond
2026-05-27 3:16 [PATCH] smp: prevent soft lockup in smp_call_function_many_cond Mark Tomlinson
2026-06-02 21:18 ` Chris Packham
@ 2026-06-03 1:37 ` Rik van Riel
1 sibling, 0 replies; 4+ messages in thread
From: Rik van Riel @ 2026-06-03 1:37 UTC (permalink / raw)
To: Mark Tomlinson, Madhavan Srinivasan, Thomas Gleixner
Cc: linux-kernel, linuxppc-dev
On Wed, 2026-05-27 at 15:16 +1200, Mark Tomlinson wrote:
> Using the PowerPC P2040 (e500mc) CPU, soft lockups can occasionally
> be
> seen in smp_call_function_many_cond(). The conclusion is that this
> CPU
> does not process the doorbell interrupt while in a data-storage (MMU)
> exception. If more than one CPU in a multi core environment is
> calling
> this function at the same time, it is possible for a deadlock to
> occur.
Does that mean if the CPU in question does not call
smp_call_function_many_cond() while in a data-storage
exception, the system might still hang?
Not that there's anything wrong with reducing the
frequency of what is (presumably) an already pretty
rare hang.
>
> The fix for this is to call flush_smp_call_function_queue() before
> waiting for responses from other CPUs. If there is something in the
> queue, this is a good time to process it before busy-waiting on other
> CPUs. On other architectures this call will quickly do nothing, as
> the
> queue will be empty.
Agreed, this does look completely harmless at worst,
and does look like it would at the very least improve
that e500mc issue.
>
> Signed-off-by: Mark Tomlinson <mark.tomlinson@alliedtelesis.co.nz>
>
Reviewed-by: Rik van Riel <riel@surriel.com>
--
All Rights Reversed.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] smp: prevent soft lockup in smp_call_function_many_cond
2026-06-02 21:18 ` Chris Packham
@ 2026-06-04 17:52 ` Paul E. McKenney
0 siblings, 0 replies; 4+ messages in thread
From: Paul E. McKenney @ 2026-06-04 17:52 UTC (permalink / raw)
To: Chris Packham
Cc: Mark Tomlinson, Madhavan Srinivasan, Thomas Gleixner, yury.norov,
romank, rafael.j.wysocki, riel, joelagnelf, linux-kernel,
linuxppc-dev
On Tue, Jun 02, 2026 at 09:18:39PM +0000, Chris Packham wrote:
> (adding others suggested by get_maintainer.pl)
>
> On 27/05/2026 15:16, Mark Tomlinson wrote:
> > Using the PowerPC P2040 (e500mc) CPU, soft lockups can occasionally be
> > seen in smp_call_function_many_cond(). The conclusion is that this CPU
> > does not process the doorbell interrupt while in a data-storage (MMU)
> > exception. If more than one CPU in a multi core environment is calling
> > this function at the same time, it is possible for a deadlock to occur.
> >
> > The fix for this is to call flush_smp_call_function_queue() before
> > waiting for responses from other CPUs. If there is something in the
> > queue, this is a good time to process it before busy-waiting on other
> > CPUs. On other architectures this call will quickly do nothing, as the
> > queue will be empty.
OK, I will bite...
How do we know that another entry will not get added by some other CPU
just before this new call to flush_smp_call_function_queue()?
Thanx, Paul
> > Signed-off-by: Mark Tomlinson <mark.tomlinson@alliedtelesis.co.nz>
> > ---
> > kernel/smp.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/kernel/smp.c b/kernel/smp.c
> > index a0bb56bd8dda..3c4467654ab0 100644
> > --- a/kernel/smp.c
> > +++ b/kernel/smp.c
> > @@ -884,6 +884,8 @@ static void smp_call_function_many_cond(const struct cpumask *mask,
> > local_irq_restore(flags);
> > }
> >
> > + flush_smp_call_function_queue();
> > +
> > if (run_remote && wait) {
> > for_each_cpu(cpu, cfd->cpumask) {
> > call_single_data_t *csd;
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-04 17:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-27 3:16 [PATCH] smp: prevent soft lockup in smp_call_function_many_cond Mark Tomlinson
2026-06-02 21:18 ` Chris Packham
2026-06-04 17:52 ` Paul E. McKenney
2026-06-03 1:37 ` Rik van Riel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®