From: Andrew Jones <drjones@redhat.com>
To: kvm@vger.kernel.org
Cc: pbonzini@redhat.com, rkrcmar@redhat.com
Subject: [PATCH kvm-unit-tests v2 3/2] arm/arm64: smp: detect deadlock cycles
Date: Sat, 3 Jun 2017 10:28:16 +0200 [thread overview]
Message-ID: <20170603082816.15348-1-drjones@redhat.com> (raw)
In-Reply-To: <20170602153109.2904-1-drjones@redhat.com>
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
lib/arm/smp.c | 33 +++++++++++++++++++++++++++++++--
1 file changed, 31 insertions(+), 2 deletions(-)
diff --git a/lib/arm/smp.c b/lib/arm/smp.c
index bb999243de63..5a6209ebcbfd 100644
--- a/lib/arm/smp.c
+++ b/lib/arm/smp.c
@@ -80,6 +80,35 @@ struct on_cpu_info {
};
static struct on_cpu_info on_cpu_info[NR_CPUS];
+static void __deadlock_check(int cpu, const cpumask_t *waiters, bool *found)
+{
+ int i;
+
+ for_each_cpu(i, waiters) {
+ if (i == cpu) {
+ printf("CPU%d", cpu);
+ *found = true;
+ return;
+ }
+ __deadlock_check(cpu, &on_cpu_info[i].waiters, found);
+ if (*found) {
+ printf(" <=> CPU%d", i);
+ return;
+ }
+ }
+}
+
+static void deadlock_check(int me, int cpu)
+{
+ bool found = false;
+
+ __deadlock_check(cpu, &on_cpu_info[me].waiters, &found);
+ if (found) {
+ printf(" <=> CPU%d deadlock detectd\n", me);
+ assert(0);
+ }
+}
+
static void cpu_wait(int cpu)
{
int me = smp_processor_id();
@@ -88,7 +117,7 @@ static void cpu_wait(int cpu)
return;
cpumask_set_cpu(me, &on_cpu_info[cpu].waiters);
- assert_msg(!cpumask_test_cpu(cpu, &on_cpu_info[me].waiters), "CPU%d <=> CPU%d deadlock detected", me, cpu);
+ deadlock_check(me, cpu);
while (!cpu_idle(cpu))
wfe();
cpumask_clear_cpu(me, &on_cpu_info[cpu].waiters);
@@ -166,7 +195,7 @@ void on_cpus(void (*func)(void))
if (cpu == me)
continue;
cpumask_set_cpu(me, &on_cpu_info[cpu].waiters);
- assert_msg(!cpumask_test_cpu(cpu, &on_cpu_info[me].waiters), "CPU%d <=> CPU%d deadlock detected", me, cpu);
+ deadlock_check(me, cpu);
}
while (cpumask_weight(&cpu_idle_mask) < nr_cpus - 1)
wfe();
--
2.9.4
next prev parent reply other threads:[~2017-06-03 8:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-02 15:31 [PATCH kvm-unit-tests v2 0/2] arm/arm64: smp: on_cpu improvements Andrew Jones
2017-06-02 15:31 ` [PATCH kvm-unit-tests v2 1/2] arm/arm64: smp: cpu0 is special Andrew Jones
2017-06-02 15:31 ` [PATCH kvm-unit-tests v2 2/2] arm/arm64: smp: add deadlock detection Andrew Jones
2017-06-03 8:28 ` Andrew Jones [this message]
2017-06-07 15:00 ` [PATCH kvm-unit-tests v2 0/2] arm/arm64: smp: on_cpu improvements Radim Krčmář
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170603082816.15348-1-drjones@redhat.com \
--to=drjones@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).