All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Vrabel <david.vrabel@citrix.com>
To: Sander Eikelenboom <linux@eikelenboom.it>,
	Wei Liu <wei.liu2@citrix.com>,
	Zoltan Kiss <zoltan.kiss@citrix.com>
Cc: xen-devel@lists.xenproject.org
Subject: Re: 3.16-rc3: PV guest INFO: possible recursive locking detected netback_changed+0xecb/0x1100
Date: Wed, 2 Jul 2014 14:32:19 +0100	[thread overview]
Message-ID: <53B409E3.7010101@citrix.com> (raw)
In-Reply-To: <688646538.20140701222906@eikelenboom.it>

On 01/07/14 21:29, Sander Eikelenboom wrote:
> Hi,
> 
> In one of my PV guest i got the lockdep warning below on boot.

Thanks. The locking in xennet_connect() is a bit "loopy".  I think it is
actually safe because these are locks for different queues but the lock
annotations are missing.

However, I don't think this lock nesting is necessary and the following
both eliminates the lockdep warning and makes the locking simpler.

8<--------------------
xen-netfront: don't nest queue locks in xennet_connect()

The nesting of the per-queue rx_lock and tx_lock in xennet_connect()
is confusing to both humans and lockdep.  The locking is safe because
this is the only place where the locks are nested in this way but
lockdep still warns.

Instead of adding the missing lockdep annotations, refactor the
locking to avoid the confusing nesting.  This is still safe, because
the xenbus connection state changes are all serialized by the xenwatch
thread.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Reported-by: Sander Eikelenboom <linux@eikelenboom.it>
---
 drivers/net/xen-netfront.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index 2ccb4a0..837c32dc 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -2076,6 +2076,9 @@ static int xennet_connect(struct net_device *dev)
 		}

 		queue->rx.req_prod_pvt = requeue_idx;
+
+		spin_unlock_irq(&queue->tx_lock);
+		spin_unlock_bh(&queue->rx_lock);
 	}

 	/*
@@ -2087,13 +2090,17 @@ static int xennet_connect(struct net_device *dev)
 	netif_carrier_on(np->netdev);
 	for (j = 0; j < num_queues; ++j) {
 		queue = &np->queues[j];
+
 		notify_remote_via_irq(queue->tx_irq);
 		if (queue->tx_irq != queue->rx_irq)
 			notify_remote_via_irq(queue->rx_irq);
-		xennet_tx_buf_gc(queue);
-		xennet_alloc_rx_buffers(queue);

+		spin_lock_irq(&queue->tx_lock);
+		xennet_tx_buf_gc(queue);
 		spin_unlock_irq(&queue->tx_lock);
+
+		spin_lock_bh(&queue->rx_lock);
+		xennet_alloc_rx_buffers(queue);
 		spin_unlock_bh(&queue->rx_lock);
 	}

-- 
1.7.10.4

      reply	other threads:[~2014-07-02 13:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-01 20:29 3.16-rc3: PV guest INFO: possible recursive locking detected netback_changed+0xecb/0x1100 Sander Eikelenboom
2014-07-02 13:32 ` David Vrabel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53B409E3.7010101@citrix.com \
    --to=david.vrabel@citrix.com \
    --cc=linux@eikelenboom.it \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    --cc=zoltan.kiss@citrix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.