我修改了一个 ramdisk 的块设备驱动程序(类似于这里的一个:http ://www.linuxforu.com/2012/02/device-drivers-disk-on-ram-block-drivers/ )以便驱动程序读取/从网络写入。我基本上将其删除memcpy
并替换为内核内网络套接字读/写。
这就是我得到的:irqs 被禁用的警告。WARN_ON_ONCE(in_irq() || irqs_disabled());
警告是从函数内的行引发的_local_bh_enable_ip
。
我的理解是我所做的应该可以工作,因为所有磁盘请求都在gendisk
. 并且作业处理程序(在blk_init_queue()
被调用时提供)将从典型的内核上下文中调用,其中应该启用 irqs。但我想我错了。
任何人都可以帮助解决问题吗?
以下是内核说明的堆栈跟踪的顶部:
[ 697.480153] [<ffffffff8105931f>] warn_slowpath_common+0x7f/0xc0
[ 697.480159] [<ffffffff8105937a>] warn_slowpath_null+0x1a/0x20
[ 697.480166] [<ffffffff8106172a>] local_bh_enable+0x7a/0xa0
[ 697.480175] [<ffffffff815974b3>] lock_sock_nested+0x53/0x60
[ 697.480183] [<ffffffff815eedfc>] tcp_sendmsg+0x2c/0xe60
[ 697.480197] [<ffffffff8134226c>] ? vsnprintf+0x35c/0x640
[ 697.480207] [<ffffffff81618331>] inet_sendmsg+0x61/0xb0
[ 697.480216] [<ffffffff81592912>] sock_sendmsg+0xd2/0xf0
[ 697.480226] [<ffffffff8133708e>] k_send+0x6e/0x80
[ 697.480236] [<ffffffffa02b34ee>] ramdevice_read+0x5e/0xd0 [dor]
[ 697.480244] [<ffffffffa02b31a3>] rb_request+0x133/0x1b0 [dor]
更新:正如彼得 L. 建议的那样。我对其进行了更改,以便套接字读/写在 tasklet 中完成。这就是我得到的:
[ 138.711263] [<ffffffff816dbedc>] __schedule_bug+0x4d/0x59
[ 138.711266] [<ffffffff816f27b8>] __schedule+0x628/0x6b0
[ 138.711269] [<ffffffff816f2b59>] schedule+0x29/0x70
[ 138.711273] [<ffffffff816f12d5>] schedule_timeout+0x1e5/0x250
[ 138.711276] [<ffffffff81045cd9>] ? default_spin_lock_flags+0x9/0x10
[ 138.711280] [<ffffffff815d1361>] sk_wait_data+0xd1/0xe0
[ 138.711284] [<ffffffff8107fd70>] ? add_wait_queue+0x60/0x60
[ 138.711286] [<ffffffff816277f2>] tcp_recvmsg+0x502/0xb60
[ 138.711289] [<ffffffff8164e7fb>] inet_recvmsg+0x6b/0x80
[ 138.711292] [<ffffffff8164e871>] ? inet_sendmsg+0x61/0xb0
[ 138.711294] [<ffffffff815ca180>] sock_recvmsg+0xe0/0x100
[ 138.711299] [<ffffffff8105b30a>] ? console_unlock+0x1a/0x30
[ 138.711302] [<ffffffffa027f42b>] k_recv+0x6b/0x80 [ksocket]
[ 138.711306] [<ffffffffa02a066d>] ramdevice_read+0x7d/0xd0 [dor]
[ 138.711309] [<ffffffffa02a0360>] my_tasklet_func+0x60/0x80 [dor]
[ 138.711312] [<ffffffff81062ae4>] tasklet_action+0x64/0xe0
[ 138.711315] [<ffffffff81062620>] __do_softirq+0xc0/0x240
[ 138.711318] [<ffffffff810627d8>] run_ksoftirqd+0x38/0x50
[ 138.711321] [<ffffffff8108804d>] smpboot_thread_fn+0xfd/0x180
[ 138.711325] [<ffffffff81087f50>] ? lg_global_lock+0x70/0x70
[ 138.711328] [<ffffffff8107f1b0>] kthread+0xc0/0xd0
[ 138.711332] [<ffffffff8107f0f0>] ? flush_kthread_worker+0xb0/0xb0
[ 138.711335] [<ffffffff816fc82c>] ret_from_fork+0x7c/0xb0
[ 138.711339] [<ffffffff8107f0f0>] ? flush_kthread_worker+0xb0/0xb0