2008.06.12.
printk可以在任何上下文中调用。如果拿不到console_sem,就写入buffer后返回。推迟输出。推迟可能导致log level的变化。见代码注释。
/*
* This is printk. It can be called from any context. We want it to work.
*
* We try to grab the console_sem. If we succeed, it's easy - we log the output and
* call the console drivers. If we fail to get the semaphore we place the output
* into the log buffer and return. The current holder of the console_sem will
* notice the new output in release_console_sem() and will send it to the
* consoles before releasing the semaphore.
*
* One effect of this deferred printing is that code which calls printk() and
* then changes console_loglevel may break. This is because console_loglevel
* is inspected when the actual printing occurs.
*/
2008.07.10.慎用printk...
写代码的时候在收到某种数据包的时候printk了一句话,结果发现故意触发这种情况会导致性能严重下降。所以,应该使用一些宏来打印debug信息,方便在性能测试时关闭打印。可怜的处理器不应该消耗在样的工作上。
阅读(1892) | 评论(0) | 转发(0) |