printk的中断处理程序中,是不是真的那么糟吗? [英] printk inside an interrupt handler , is it really that bad?

查看:1726
本文介绍了printk的中断处理程序中,是不是真的那么糟吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家都知道,中断处理程序应该是越短越好。并加入像的printk 功能的中断处理程序中的调试是一件不应该做。
其实,我试了一下,当我的调试。我写中断驱动字符设备Linux内核之前,它破坏了司机的时间。

everybody knows that interrupt handler should be short as possible. and adding functions like printk for debugging inside an interrupt handler is something that shouldn't be done. Actually, I tried it before when I was debugging the linux kernel for an interrupt driven char device I written, and it wrecked the timing of the driver.

我的问题,是为什么发生这种情况?
的printk 函数缓冲!这意味着,据我了解,将数据插入到队列中,它被处理后,最有可能中断处理程序结束后。

The question I have, is why this is happening ? printk function is buffered ! it means, as far as I understand that the data is inserted in to a queue, and it's being handled later, most probably after the interrupt handler is finished.

那么,为什么不工作?

推荐答案

的printk 功能不只是插入到队列/缓冲 - 假设日志级别高够了,从的printk 输出将立即发出到控制台,作为呼叫的一部分的printk 。这是特别慢,如果控制台是,比如说,一个串行端口。但在任何情况下,的printk 并引入pretty巨大的开销,可能会影响时序。

The printk function is not just inserting into a queue/buffer -- assuming the log level is high enough, the output from printk will be emitted to the console immediately, as part of the call to printk. This is especially slow if the console is, say, on a serial port. But in any case, printk does introduce pretty substantial overhead and can affect timing.

如果你有,你想要得到一些调试输出时序关键的地方,你可以看看现代的内核使用 trace_printk 功能。这实际上也只是把输入到跟踪ringbuffer,并且以后可以读取它。看看的全部细节这篇文章

If you have a timing critical place where you want to get some debug output, you can look at using the trace_printk function in modern kernels. This actually does just put input into the trace ringbuffer, and you can read it later. Take a look at this article for full details.

这篇关于printk的中断处理程序中,是不是真的那么糟吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆