Commit 7a0e3ce8 authored by Philippe Gerum's avatar Philippe Gerum Committed by Jan Kiszka
Browse files

dump_stack: ipipe: make dump_stack() domain-aware

When dumping a stack backtrace, we neither need nor want to disable
root stage IRQs over the head stage, where CPU migration can't
happen.

Conversely, we neither need nor want to disable hard IRQs from the
head stage, so that latency won't skyrocket either.
parent 374cff39
......@@ -8,6 +8,7 @@
#include <linux/export.h>
#include <linux/sched.h>
#include <linux/sched/debug.h>
#include <linux/ipipe.h>
#include <linux/smp.h>
#include <linux/atomic.h>
#include <linux/kexec.h>
......@@ -56,6 +57,9 @@ void dump_stack_print_info(const char *log_lvl)
printk("%sHardware name: %s\n",
log_lvl, dump_stack_arch_desc_str);
#ifdef CONFIG_IPIPE
printk("I-pipe domain: %s\n", ipipe_current_domain->name);
#endif
print_worker_info(log_lvl, current);
}
......@@ -85,6 +89,29 @@ static void __dump_stack(void)
#ifdef CONFIG_SMP
static atomic_t dump_lock = ATOMIC_INIT(-1);
static unsigned long disable_local_irqs(void)
{
unsigned long flags = 0; /* only to trick the UMR detection */
/*
* We neither need nor want to disable root stage IRQs over
* the head stage, where CPU migration can't
* happen. Conversely, we neither need nor want to disable
* hard IRQs from the head stage, so that latency won't
* skyrocket as a result of dumping the stack backtrace.
*/
if (ipipe_root_p)
local_irq_save(flags);
return flags;
}
static void restore_local_irqs(unsigned long flags)
{
if (ipipe_root_p)
local_irq_restore(flags);
}
asmlinkage __visible void dump_stack(void)
{
unsigned long flags;
......@@ -97,7 +124,7 @@ asmlinkage __visible void dump_stack(void)
* against other CPUs
*/
retry:
local_irq_save(flags);
flags = disable_local_irqs();
cpu = smp_processor_id();
old = atomic_cmpxchg(&dump_lock, -1, cpu);
if (old == -1) {
......@@ -105,7 +132,7 @@ asmlinkage __visible void dump_stack(void)
} else if (old == cpu) {
was_locked = 1;
} else {
local_irq_restore(flags);
restore_local_irqs(flags);
/*
* Wait for the lock to release before jumping to
* atomic_cmpxchg() in order to mitigate the thundering herd
......@@ -120,7 +147,7 @@ asmlinkage __visible void dump_stack(void)
if (!was_locked)
atomic_set(&dump_lock, -1);
local_irq_restore(flags);
restore_local_irqs(flags);
}
#else
asmlinkage __visible void dump_stack(void)
......
Markdown is supported
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