BUG or not? GFP_KERNEL with interrupts disabled.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



(kernel is ppc 2.4.21-pre4)

In bond_enslave() [drivers/net/bonding.c]:

	write_lock_irqsave(&bond->lock, flags);
	...
	err = netdev_set_master(slave_dev, master_dev);
	...
	write_unlock_irqrestore(&bond->lock, flags);

In netdev_set_master() [net/core/dev.c]:

	rtmsg_ifinfo(RTM_NEWLINK, slave, IFF_SLAVE);

In rtmsg_ifinfo() [net/core/rtnetlink.c]:

	skb = alloc_skb(size, GFP_KERNEL);
	...
	netlink_broadcast(rtnl, skb, 0, RTMGRP_LINK, GFP_KERNEL);

Doesn't this admit the possibility of sleeping with interrupts disabled?  
I found it because I'm working on a driver that uses a master-slave
relationship like the bonding driver, and decided I didn't really need to
disable interrupts, so I tried using write_lock_bh()  instead.  The result
was an "alloc_skb called nonatomically from interrupt" message because
write_lock_bh() increments the local BH count (which seems reasonable).

A bigger question: Why are the IRQ check and the BH check inconsistent?
That is, local_bh_count() says "yes" if you are currently running in BH
context OR have disabled BHs; however, local_irq_count() says "yes" if you
are currently running in interrupt context, but it says nothing (as far as
I have seen) about whether IRQs are enabled or disabled.  Is this (a) the
Right Way, (b) something that's more trouble to fix than to be burned-by
once and then avoid for the rest of your life, or (c) totally horked?

-- 
Dan Eble <dane@aiinet.com>  _____  .
                           |  _  |/|
Applied Innovation Inc.    | |_| | |
http://www.aiinet.com/     |__/|_|_|

-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux