aboutsummaryrefslogtreecommitdiffstats
path: root/net/decnet
diff options
context:
space:
mode:
authorstephen hemminger <shemminger@vyatta.com>2009-11-11 02:40:36 -0500
committerDavid S. Miller <davem@davemloft.net>2009-11-11 22:22:18 -0500
commite5c140a340c4796054b0f6e9035e1faa7edfa6d6 (patch)
treeca150ab28a91eba36838ffc1519840fac705aa82 /net/decnet
parent41bdecf17e6dba92256c65972ec79a482d978be5 (diff)
decnet: convert dndev_lock to spinlock
There is no reason for this lock to be reader/writer since the reader only has lock held for a very brief period. The overhead of read_lock is more expensive than spinlock. Compile tested only, I am not a decnet user. Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/decnet')
-rw-r--r--net/decnet/dn_dev.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c
index 5790d660bc7d..6c916e2b8a84 100644
--- a/net/decnet/dn_dev.c
+++ b/net/decnet/dn_dev.c
@@ -68,7 +68,7 @@ extern struct neigh_table dn_neigh_table;
68 */ 68 */
69__le16 decnet_address = 0; 69__le16 decnet_address = 0;
70 70
71static DEFINE_RWLOCK(dndev_lock); 71static DEFINE_SPINLOCK(dndev_lock);
72static struct net_device *decnet_default_device; 72static struct net_device *decnet_default_device;
73static BLOCKING_NOTIFIER_HEAD(dnaddr_chain); 73static BLOCKING_NOTIFIER_HEAD(dnaddr_chain);
74 74
@@ -557,7 +557,8 @@ rarok:
557struct net_device *dn_dev_get_default(void) 557struct net_device *dn_dev_get_default(void)
558{ 558{
559 struct net_device *dev; 559 struct net_device *dev;
560 read_lock(&dndev_lock); 560
561 spin_lock(&dndev_lock);
561 dev = decnet_default_device; 562 dev = decnet_default_device;
562 if (dev) { 563 if (dev) {
563 if (dev->dn_ptr) 564 if (dev->dn_ptr)
@@ -565,7 +566,8 @@ struct net_device *dn_dev_get_default(void)
565 else 566 else
566 dev = NULL; 567 dev = NULL;
567 } 568 }
568 read_unlock(&dndev_lock); 569 spin_unlock(&dndev_lock);
570
569 return dev; 571 return dev;
570} 572}
571 573
@@ -575,13 +577,15 @@ int dn_dev_set_default(struct net_device *dev, int force)
575 int rv = -EBUSY; 577 int rv = -EBUSY;
576 if (!dev->dn_ptr) 578 if (!dev->dn_ptr)
577 return -ENODEV; 579 return -ENODEV;
578 write_lock(&dndev_lock); 580
581 spin_lock(&dndev_lock);
579 if (force || decnet_default_device == NULL) { 582 if (force || decnet_default_device == NULL) {
580 old = decnet_default_device; 583 old = decnet_default_device;
581 decnet_default_device = dev; 584 decnet_default_device = dev;
582 rv = 0; 585 rv = 0;
583 } 586 }
584 write_unlock(&dndev_lock); 587 spin_unlock(&dndev_lock);
588
585 if (old) 589 if (old)
586 dev_put(old); 590 dev_put(old);
587 return rv; 591 return rv;
@@ -589,13 +593,14 @@ int dn_dev_set_default(struct net_device *dev, int force)
589 593
590static void dn_dev_check_default(struct net_device *dev) 594static void dn_dev_check_default(struct net_device *dev)
591{ 595{
592 write_lock(&dndev_lock); 596 spin_lock(&dndev_lock);
593 if (dev == decnet_default_device) { 597 if (dev == decnet_default_device) {
594 decnet_default_device = NULL; 598 decnet_default_device = NULL;
595 } else { 599 } else {
596 dev = NULL; 600 dev = NULL;
597 } 601 }
598 write_unlock(&dndev_lock); 602 spin_unlock(&dndev_lock);
603
599 if (dev) 604 if (dev)
600 dev_put(dev); 605 dev_put(dev);
601} 606}