[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <tip-19dbdcb8039cff16669a05136a29180778d16d0a@git.kernel.org>
Date: Sat, 20 Jul 2019 02:31:57 -0700
From: tip-bot for Peter Zijlstra <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: peterz@...radead.org, linux-kernel@...r.kernel.org,
luferry@....com, hpa@...or.com, mingo@...nel.org,
tglx@...utronix.de
Subject: [tip:smp/urgent] smp: Warn on function calls from softirq context
Commit-ID: 19dbdcb8039cff16669a05136a29180778d16d0a
Gitweb: https://git.kernel.org/tip/19dbdcb8039cff16669a05136a29180778d16d0a
Author: Peter Zijlstra <peterz@...radead.org>
AuthorDate: Thu, 18 Jul 2019 11:20:09 +0200
Committer: Thomas Gleixner <tglx@...utronix.de>
CommitDate: Sat, 20 Jul 2019 11:27:16 +0200
smp: Warn on function calls from softirq context
It's clearly documented that smp function calls cannot be invoked from
softirq handling context. Unfortunately nothing enforces that or emits a
warning.
A single function call can be invoked from softirq context only via
smp_call_function_single_async().
The only legit context is task context, so add a warning to that effect.
Reported-by: luferry <luferry@....com>
Signed-off-by: Peter Zijlstra <peterz@...radead.org>
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
Link: https://lkml.kernel.org/r/20190718160601.GP3402@hirez.programming.kicks-ass.net
---
kernel/smp.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/kernel/smp.c b/kernel/smp.c
index 616d4d114847..7dbcb402c2fc 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -291,6 +291,14 @@ int smp_call_function_single(int cpu, smp_call_func_t func, void *info,
WARN_ON_ONCE(cpu_online(this_cpu) && irqs_disabled()
&& !oops_in_progress);
+ /*
+ * When @wait we can deadlock when we interrupt between llist_add() and
+ * arch_send_call_function_ipi*(); when !@...t we can deadlock due to
+ * csd_lock() on because the interrupt context uses the same csd
+ * storage.
+ */
+ WARN_ON_ONCE(!in_task());
+
csd = &csd_stack;
if (!wait) {
csd = this_cpu_ptr(&csd_data);
@@ -416,6 +424,14 @@ void smp_call_function_many(const struct cpumask *mask,
WARN_ON_ONCE(cpu_online(this_cpu) && irqs_disabled()
&& !oops_in_progress && !early_boot_irqs_disabled);
+ /*
+ * When @wait we can deadlock when we interrupt between llist_add() and
+ * arch_send_call_function_ipi*(); when !@...t we can deadlock due to
+ * csd_lock() on because the interrupt context uses the same csd
+ * storage.
+ */
+ WARN_ON_ONCE(!in_task());
+
/* Try to fastpath. So, what's a CPU they want? Ignoring this one. */
cpu = cpumask_first_and(mask, cpu_online_mask);
if (cpu == this_cpu)
Powered by blists - more mailing lists