Commit 12009dbb authored by Andrew Jones's avatar Andrew Jones Committed by Radim Krčmář
Browse files

arm/arm64: smp: detect deadlock cycles


Signed-off-by: Andrew Jones's avatarAndrew Jones <drjones@redhat.com>
Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
parent 942d182b
......@@ -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();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment