2018-03-11

1. 问题

通常来说, bio->bi_end_io是软中断上下文中运行的, 在bio->bi_end_io中对in_irq(), in_softirq(), in_serving_softirq(),irqs_disabled()进行判断的话, 仅有in_softirq(), in_serving_softirq()会成立.

现有如下问题, spin_lock_bh()无法禁止软中断运行, why?

2. 解

测试发现, bio->bi_end_io()中有时in_irq(), in_softirq(), in_serving_softirq(),irqs_disabled()都成立, 有时 仅in_irq(), irqs_disabled()成立.

查看调用栈, 发现有virtio_blk模块, 也就是运行在虚拟机环境中. 仅in_irq(), irqs_disabled()成立时的调用栈:

Pid: 3660, comm: mount Not tainted 2.6.32-debug #2
Call Trace:
 <IRQ>  [<ffffffffa03e18f5>] ? your_bio_end_io+0x2b5/0x310 [your_kmod]
 [<ffffffff811e3a5d>] ? bio_endio+0x1d/0x40
 [<ffffffffa0003efc>] ? dec_pending+0x1cc/0x320 [dm_mod]
 [<ffffffffa0003d7d>] ? dec_pending+0x4d/0x320 [dm_mod]
 [<ffffffffa00040ef>] ? clone_endio+0x9f/0xd0 [dm_mod]
 [<ffffffff811e3a5d>] ? bio_endio+0x1d/0x40
 [<ffffffff8128ef7b>] ? req_bio_endio+0x9b/0xe0
 [<ffffffff812906dc>] ? blk_update_request+0x11c/0x520
 [<ffffffff81290999>] ? blk_update_request+0x3d9/0x520
 [<ffffffff81290b07>] ? blk_update_bidi_request+0x27/0xa0
 [<ffffffff81291aae>] ? __blk_end_request_all+0x2e/0x60
 [<ffffffffa006321a>] ? blk_done+0x4a/0x110 [virtio_blk]
 [<ffffffffa005638c>] ? vring_interrupt+0x3c/0xe0 [virtio_ring]
 [<ffffffff810fc970>] ? handle_IRQ_event+0x50/0x160
 [<ffffffff810ff2f0>] ? handle_edge_irq+0xe0/0x170
 [<ffffffff8100fdc9>] ? handle_irq+0x49/0xa0
 [<ffffffff81570e7c>] ? do_IRQ+0x6c/0xf0
 [<ffffffff8100ba93>] ? ret_from_intr+0x0/0x11
 <EOI>  [<ffffffff8118dd73>] ? __kmalloc+0x143/0x2c0
 [<ffffffffa00c4e87>] ? ext4_mb_add_groupinfo+0xd7/0x1e0 [ext4]
 [<ffffffffa00c4e87>] ? ext4_mb_add_groupinfo+0xd7/0x1e0 [ext4]
 [<ffffffffa00c5152>] ? ext4_mb_init+0x1c2/0x450 [ext4]
 [<ffffffffa00b7128>] ? ext4_fill_super+0x2358/0x2950 [ext4]
 [<ffffffff812b8684>] ? snprintf+0x34/0x40
 [<ffffffff811ac141>] ? get_sb_bdev+0x191/0x1d0
 [<ffffffffa00b4dd0>] ? ext4_fill_super+0x0/0x2950 [ext4]
 [<ffffffffa00b04f8>] ? ext4_get_sb+0x18/0x20 [ext4]
 [<ffffffff811ab51b>] ? vfs_kern_mount+0x7b/0x1b0
 [<ffffffff811ab6c2>] ? do_kern_mount+0x52/0x130
 [<ffffffff811cdc5b>] ? do_mount+0x2fb/0x920
 [<ffffffff8115a6d4>] ? strndup_user+0x64/0xc0
 [<ffffffff811ce310>] ? sys_mount+0x90/0xe0
 [<ffffffff8100b0d2>] ? system_call_fastpath+0x16/0x1b

本文地址: https://awakening-fong.github.io/posts/io/bi_end_io_occur_but_irqs_disabled

转载请注明出处: https://awakening-fong.github.io


若无法评论, 请打开JavaScript, 并通过proxy.


blog comments powered by Disqus