netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* re: bonding: sync netpoll code with bridge
@ 2012-07-25 13:47 Dan Carpenter
  2012-07-26  7:15 ` Cong Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2012-07-25 13:47 UTC (permalink / raw)
  To: amwang; +Cc: netdev

Hello Amerigo Wang,

The patch 8a8efa22f51b: "bonding: sync netpoll code with bridge" from 
Feb 17, 2011, leads to the following warning:
drivers/net/bonding/bond_main.c:1849 bond_enslave()
	 error: scheduling with locks held: 'read_lock:&bond->lock'

drivers/net/bonding/bond_main.c
  1301          read_lock(&bond->lock);
  1302          bond_for_each_slave(bond, slave, i) {
  1303                  err = slave_enable_netpoll(slave);
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
This can lead to a scheduling while atomic bug because it does a
GFP_KERNEL allocation and calls __netpoll_setup() which sleeps.

  1304                  if (err) {
  1305                          __bond_netpoll_cleanup(bond);
  1306                          break;
  1307                  }
  1308          }
  1309          read_unlock(&bond->lock);

Also later in the file:

  1848          if (slave_dev->npinfo) {
  1849                  if (slave_enable_netpoll(new_slave)) {
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
We are holding read_lock(&bond->lock);

  1850                          read_unlock(&bond->lock);
  1851                          pr_info("Error, %s: master_dev is using netpoll, "
  1852                                   "but new slave device does not support netpoll.\n",
  1853                                   bond_dev->name);
  1854                          res = -EBUSY;
  1855                          goto err_detach;
  1856                  }

The easy way to trigger this warning is to test with
CONFIG_DEBUG_ATOMIC_SLEEP=y.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 3+ messages in thread

* re: bonding: sync netpoll code with bridge
  2012-07-25 13:47 bonding: sync netpoll code with bridge Dan Carpenter
@ 2012-07-26  7:15 ` Cong Wang
  2012-07-26  8:17   ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Cong Wang @ 2012-07-26  7:15 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: netdev

On Wed, 2012-07-25 at 16:47 +0300, Dan Carpenter wrote:
> Hello Amerigo Wang,
> 
> The patch 8a8efa22f51b: "bonding: sync netpoll code with bridge" from 
> Feb 17, 2011, leads to the following warning:
> drivers/net/bonding/bond_main.c:1849 bond_enslave()
> 	 error: scheduling with locks held: 'read_lock:&bond->lock'

Yeah, makes sense. Just wondering why I didn't catch it when I tested
that patch. Anyway, could you try the following patch?

----------->

diff --git a/drivers/net/bonding/bond_main.c
b/drivers/net/bonding/bond_main.c
index 6fae5f3..ab773d4 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1235,7 +1235,7 @@ static inline int slave_enable_netpoll(struct
slave *slave)
 	struct netpoll *np;
 	int err = 0;
 
-	np = kzalloc(sizeof(*np), GFP_KERNEL);
+	np = kzalloc(sizeof(*np), GFP_ATOMIC);
 	err = -ENOMEM;
 	if (!np)
 		goto out;
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index b4c90e4..c78a966 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -734,7 +734,7 @@ int __netpoll_setup(struct netpoll *np, struct
net_device *ndev)
 	}
 
 	if (!ndev->npinfo) {
-		npinfo = kmalloc(sizeof(*npinfo), GFP_KERNEL);
+		npinfo = kmalloc(sizeof(*npinfo), GFP_ATOMIC);
 		if (!npinfo) {
 			err = -ENOMEM;
 			goto out;

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: bonding: sync netpoll code with bridge
  2012-07-26  7:15 ` Cong Wang
@ 2012-07-26  8:17   ` Dan Carpenter
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2012-07-26  8:17 UTC (permalink / raw)
  To: Cong Wang; +Cc: netdev

On Thu, Jul 26, 2012 at 03:15:05PM +0800, Cong Wang wrote:
> On Wed, 2012-07-25 at 16:47 +0300, Dan Carpenter wrote:
> > Hello Amerigo Wang,
> > 
> > The patch 8a8efa22f51b: "bonding: sync netpoll code with bridge" from 
> > Feb 17, 2011, leads to the following warning:
> > drivers/net/bonding/bond_main.c:1849 bond_enslave()
> > 	 error: scheduling with locks held: 'read_lock:&bond->lock'
> 
> Yeah, makes sense. Just wondering why I didn't catch it when I tested
> that patch. Anyway, could you try the following patch?
> 

The warnings were static checker warnings, not something I tested.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-07-26  8:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-25 13:47 bonding: sync netpoll code with bridge Dan Carpenter
2012-07-26  7:15 ` Cong Wang
2012-07-26  8:17   ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).