- 论坛徽章:
- 1
|
截取printk的一段实现代码:- preempt_disable();
- /* This stops the holder of console_sem just where we want him */
- raw_local_irq_save(flags);
- this_cpu = smp_processor_id();
- /*
- * Ouch, printk recursed into itself!
- */
- if (unlikely(printk_cpu == this_cpu)) {
- /*
- * If a crash is occurring during printk() on this CPU,
- * then try to get the crash message out but make sure
- * we can't deadlock. Otherwise just return to avoid the
- * recursion and return - but flag the recursion so that
- * it can be printed at the next appropriate moment:
- */
- if (!oops_in_progress) {
- recursion_bug = 1;
- goto out_restore_irqs;
- }
- zap_locks();
- }
复制代码 里面有检测printk嵌套的判断。 但我比较疑惑这在什么情况下会发生? 因为一开始已经禁用了抢占和本地中断,printk如何嵌套?
我尝试了在printk中访问非法内存, 可惜串口直接挂死, 并未打印出 BUG: recent printk recursion! |
|