Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6756ae4b authored by Stephen Hemminger's avatar Stephen Hemminger Committed by David S. Miller
Browse files

[NET]: Convert RTNL to mutex.



This patch turns the RTNL from a semaphore to a new 2.6.16 mutex and
gets rid of some of the leftover legacy.

Signed-off-by: default avatarStephen Hemminger <shemminger@osdl.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 253aa115
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1605,7 +1605,7 @@ static void rtl8139_thread (void *_data)
	if (tp->watchdog_fired) {
		tp->watchdog_fired = 0;
		rtl8139_tx_timeout_task(_data);
	} else if (rtnl_shlock_nowait() == 0) {
	} else if (rtnl_trylock()) {
		rtl8139_thread_iter (dev, tp, tp->mmio_addr);
		rtnl_unlock ();
	} else {
+7 −13
Original line number Diff line number Diff line
@@ -907,6 +907,7 @@ struct tcamsg
#ifdef __KERNEL__

#include <linux/config.h>
#include <linux/mutex.h>

extern size_t rtattr_strlcpy(char *dest, const struct rtattr *rta, size_t size);
static __inline__ int rtattr_strcmp(const struct rtattr *rta, const char *str)
@@ -1038,24 +1039,17 @@ __rta_reserve(struct sk_buff *skb, int attrtype, int attrlen)

extern void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change);

extern struct semaphore rtnl_sem;

#define rtnl_shlock()		down(&rtnl_sem)
#define rtnl_shlock_nowait()	down_trylock(&rtnl_sem)

#define rtnl_shunlock()	do { up(&rtnl_sem); \
		             if (rtnl && rtnl->sk_receive_queue.qlen) \
				     rtnl->sk_data_ready(rtnl, 0); \
		        } while(0)

/* RTNL is used as a global lock for all changes to network configuration  */
extern void rtnl_lock(void);
extern int rtnl_lock_interruptible(void);
extern void rtnl_unlock(void);
extern int rtnl_trylock(void);

extern void rtnetlink_init(void);
extern void __rtnl_unlock(void);

#define ASSERT_RTNL() do { \
	if (unlikely(down_trylock(&rtnl_sem) == 0)) { \
		up(&rtnl_sem); \
	if (unlikely(rtnl_trylock())) { \
		rtnl_unlock(); \
		printk(KERN_ERR "RTNL: assertion failed at %s (%d)\n", \
		       __FILE__,  __LINE__); \
		dump_stack(); \
+4 −4
Original line number Diff line number Diff line
@@ -2466,9 +2466,9 @@ int dev_ioctl(unsigned int cmd, void __user *arg)
	 */

	if (cmd == SIOCGIFCONF) {
		rtnl_shlock();
		rtnl_lock();
		ret = dev_ifconf((char __user *) arg);
		rtnl_shunlock();
		rtnl_unlock();
		return ret;
	}
	if (cmd == SIOCGIFNAME)
@@ -2877,7 +2877,7 @@ static void netdev_wait_allrefs(struct net_device *dev)
	rebroadcast_time = warning_time = jiffies;
	while (atomic_read(&dev->refcnt) != 0) {
		if (time_after(jiffies, rebroadcast_time + 1 * HZ)) {
			rtnl_shlock();
			rtnl_lock();

			/* Rebroadcast unregister notification */
			notifier_call_chain(&netdev_chain,
@@ -2894,7 +2894,7 @@ static void netdev_wait_allrefs(struct net_device *dev)
				linkwatch_run_queue();
			}

			rtnl_shunlock();
			__rtnl_unlock();

			rebroadcast_time = jiffies;
		}
+2 −2
Original line number Diff line number Diff line
@@ -139,9 +139,9 @@ static void linkwatch_event(void *dummy)
	linkwatch_nextevent = jiffies + HZ;
	clear_bit(LW_RUNNING, &linkwatch_flags);

	rtnl_shlock();
	rtnl_lock();
	linkwatch_run_queue();
	rtnl_shunlock();
	rtnl_unlock();
}


+3 −3
Original line number Diff line number Diff line
@@ -669,14 +669,14 @@ int netpoll_setup(struct netpoll *np)
		printk(KERN_INFO "%s: device %s not up yet, forcing it\n",
		       np->name, np->dev_name);

		rtnl_shlock();
		rtnl_lock();
		if (dev_change_flags(ndev, ndev->flags | IFF_UP) < 0) {
			printk(KERN_ERR "%s: failed to open %s\n",
			       np->name, np->dev_name);
			rtnl_shunlock();
			rtnl_unlock();
			goto release;
		}
		rtnl_shunlock();
		rtnl_unlock();

		atleast = jiffies + HZ/10;
 		atmost = jiffies + 4*HZ;
Loading