linux-kernel - linux 内核等待队列 - printk 未显示在消息日志中

标签 linux-kernel

我注意到内核模块中有一些奇怪的行为。当我运行以下代码(使用等待队列)时。在 finish_wait() 之后,printk() 不会出现在内核日志中。 第 5 行也只打印一次。知道发生了什么事吗?

DEFINE_WAIT(wait);
DECLARE_WAIT_QUEUE_HEAD(wait_q);
flags |= O_NONBLOCK;
while (( err = kthread->sock->ops->accept(kthread->sock, kthread->sock_send, flags) ) < 0){
    printk("%s: before prepare_to_wait err = -%d\n", __func__,err);
    prepare_to_wait(&wait_q, &wait, TASK_INTERRUPTIBLE);
    if(kthread_should_stop()){
        printk("%s: killing thread\n", __func__);
        msleep(1000);   
        finish_wait(&wait_q, &wait);
        goto close_and_out;
    }
    schedule();
}
finish_wait(&wait_q, &wait);
printk("after finish wait: This doesn't show up in kernel logs...\n");

最佳答案

将优先级添加到日志消息中:

喜欢:printk(KERN_ALERT 你的信息); 此外,KERN_ALERT 和您的消息之间不会有“逗号” 如果不是 KERN_ALERT,请尝试使用不同的级别。

Rgds, 软软的

关于linux-kernel - linux 内核等待队列 - printk 未显示在消息日志中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10687603/

相关文章:

linux - 带有 MSG_DONTWAIT 标志的接收 | TCP 套接字上的 MSG_PEEK

转换和 copy_to_user 宏

linux-kernel - spin_lock_irqsave和spin_lock_irq

linux - Linux ISR 的堆栈在哪里

linux - 如何避免在/proc 中重复创建目录?

c - tcp socket hungry 程序是否会干扰文件系统 I/O

c - 将 block_device 映射到设备结构

linux - kvm中hypercalls的入口在哪里?

c - 如何在内核 C 程序和用户级 C 程序之间共享数据?

linux - systemtap 脚本错误