On Tue, Nov 18, 2014 at 11:39:20PM -0500, Steven Rostedt wrote: > static int > arch_trigger_all_cpu_backtrace_handler(unsigned int cmd, struct pt_regs > *regs) > { > @@ -78,12 +157,14 @@ arch_trigger_all_cpu_backtrace_handler(unsigned int cmd, > struct pt_regs *regs) > cpu = smp_processor_id(); > > if (cpumask_test_cpu(cpu, to_cpumask(backtrace_mask))) { > - static arch_spinlock_t lock = __ARCH_SPIN_LOCK_UNLOCKED; > + printk_func_t printk_func_save = this_cpu_read(printk_func); > > - arch_spin_lock(&lock); > + /* Replace printk to write into the NMI seq */ > + this_cpu_write(printk_func, nmi_vprintk); > printk(KERN_WARNING "NMI backtrace for cpu %d\n", cpu); > show_regs(regs); > - arch_spin_unlock(&lock); > + this_cpu_write(printk_func, printk_func_save);
I'm wondering if this could be used in a generic manner throughout code where we could say "ok, I'm in an NMI context, so lemme switch printk's and do some printing" so that NMI and NMI-like atomic contexts could use printk. Lemme do an mce example: do_machine_check(..) { printk_func_t printk_func_save = this_cpu_read(printk_func); ... /* in #MC handler, switch printks */ this_cpu_write(printk_func, nmi_vprintk); printk("This is a hw error, details: ...\n"); /* more bla */ this_cpu_write(printk_func, printk_func_save); } or should we change that in entry.S, before we call the handler? Because, if we could do something like that, then we finally get to use printk in an NMI context which would be a good thing. :-) -- Regards/Gruss, Boris. Sent from a fat crate under my desk. Formatting is fine. -- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/