On Wed, Dec 28, 2016 at 04:09:31PM +0800, Jason Wang wrote:> +static int tun_rx_batched(struct tun_file *tfile, struct sk_buff *skb, > + int more) > +{ > + struct sk_buff_head *queue = &tfile->sk.sk_write_queue; > + struct sk_buff_head process_queue; > + int qlen; > + bool rcv = false; > + > + spin_lock(&queue->lock);Should this be spin_lock_bh()? Below and in tun_get_user() there are explicit local_bh_disable() calls so I guess BHs can interrupt us here and this would deadlock. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 455 bytes Desc: not available URL: <http://lists.linuxfoundation.org/pipermail/virtualization/attachments/20170103/fd89da97/attachment.sig>
On 2017?01?03? 21:33, Stefan Hajnoczi wrote:> On Wed, Dec 28, 2016 at 04:09:31PM +0800, Jason Wang wrote: >> +static int tun_rx_batched(struct tun_file *tfile, struct sk_buff *skb, >> + int more) >> +{ >> + struct sk_buff_head *queue = &tfile->sk.sk_write_queue; >> + struct sk_buff_head process_queue; >> + int qlen; >> + bool rcv = false; >> + >> + spin_lock(&queue->lock); > Should this be spin_lock_bh()? Below and in tun_get_user() there are > explicit local_bh_disable() calls so I guess BHs can interrupt us here > and this would deadlock.sk_write_queue were accessed only in this function which runs under process context, so no need for spin_lock_bh() here.
On Wed, Jan 04, 2017 at 11:03:32AM +0800, Jason Wang wrote:> On 2017?01?03? 21:33, Stefan Hajnoczi wrote: > > On Wed, Dec 28, 2016 at 04:09:31PM +0800, Jason Wang wrote: > > > +static int tun_rx_batched(struct tun_file *tfile, struct sk_buff *skb, > > > + int more) > > > +{ > > > + struct sk_buff_head *queue = &tfile->sk.sk_write_queue; > > > + struct sk_buff_head process_queue; > > > + int qlen; > > > + bool rcv = false; > > > + > > > + spin_lock(&queue->lock); > > Should this be spin_lock_bh()? Below and in tun_get_user() there are > > explicit local_bh_disable() calls so I guess BHs can interrupt us here > > and this would deadlock. > > sk_write_queue were accessed only in this function which runs under process > context, so no need for spin_lock_bh() here.I see, thanks! Stefan -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 455 bytes Desc: not available URL: <http://lists.linuxfoundation.org/pipermail/virtualization/attachments/20170105/b7873ec3/attachment.sig>