• N
    netpoll: convert mutex into a semaphore · bd7c4b60
    Neil Horman 提交于
    Bart Van Assche recently reported a warning to me:
    
    <IRQ>  [<ffffffff8103d79f>] warn_slowpath_common+0x7f/0xc0
    [<ffffffff8103d7fa>] warn_slowpath_null+0x1a/0x20
    [<ffffffff814761dd>] mutex_trylock+0x16d/0x180
    [<ffffffff813968c9>] netpoll_poll_dev+0x49/0xc30
    [<ffffffff8136a2d2>] ? __alloc_skb+0x82/0x2a0
    [<ffffffff81397715>] netpoll_send_skb_on_dev+0x265/0x410
    [<ffffffff81397c5a>] netpoll_send_udp+0x28a/0x3a0
    [<ffffffffa0541843>] ? write_msg+0x53/0x110 [netconsole]
    [<ffffffffa05418bf>] write_msg+0xcf/0x110 [netconsole]
    [<ffffffff8103eba1>] call_console_drivers.constprop.17+0xa1/0x1c0
    [<ffffffff8103fb76>] console_unlock+0x2d6/0x450
    [<ffffffff8104011e>] vprintk_emit+0x1ee/0x510
    [<ffffffff8146f9f6>] printk+0x4d/0x4f
    [<ffffffffa0004f1d>] scsi_print_command+0x7d/0xe0 [scsi_mod]
    
    This resulted from my commit ca99ca14 which introduced a mutex_trylock
    operation in a path that could execute in interrupt context.  When mutex
    debugging is enabled, the above warns the user when we are in fact
    exectuting in interrupt context
    interrupt context.
    
    After some discussion, It seems that a semaphore is the proper mechanism to use
    here.  While mutexes are defined to be unusable in interrupt context, no such
    condition exists for semaphores (save for the fact that the non blocking api
    calls, like up and down_trylock must be used when in irq context).
    Signed-off-by: NNeil Horman <nhorman@tuxdriver.com>
    Reported-by: NBart Van Assche <bvanassche@acm.org>
    CC: Bart Van Assche <bvanassche@acm.org>
    CC: David Miller <davem@davemloft.net>
    CC: netdev@vger.kernel.org
    Signed-off-by: NDavid S. Miller <davem@davemloft.net>
    bd7c4b60
netpoll.c 30.6 KB