Commit bc971dee authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David S. Miller

[SHAPER]: Switch to spinlocks.

Dave, you were right and the sleeping locks in shaper were
broken. Markus Kanet noticed this and also tested the patch below that
switches locking to spinlocks.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2f36895a
...@@ -135,10 +135,8 @@ static int shaper_start_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -135,10 +135,8 @@ static int shaper_start_xmit(struct sk_buff *skb, struct net_device *dev)
{ {
struct shaper *shaper = dev->priv; struct shaper *shaper = dev->priv;
struct sk_buff *ptr; struct sk_buff *ptr;
if (down_trylock(&shaper->sem)) spin_lock(&shaper->lock);
return -1;
ptr=shaper->sendq.prev; ptr=shaper->sendq.prev;
/* /*
...@@ -232,7 +230,7 @@ static int shaper_start_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -232,7 +230,7 @@ static int shaper_start_xmit(struct sk_buff *skb, struct net_device *dev)
shaper->stats.collisions++; shaper->stats.collisions++;
} }
shaper_kick(shaper); shaper_kick(shaper);
up(&shaper->sem); spin_unlock(&shaper->lock);
return 0; return 0;
} }
...@@ -271,11 +269,9 @@ static void shaper_timer(unsigned long data) ...@@ -271,11 +269,9 @@ static void shaper_timer(unsigned long data)
{ {
struct shaper *shaper = (struct shaper *)data; struct shaper *shaper = (struct shaper *)data;
if (!down_trylock(&shaper->sem)) { spin_lock(&shaper->lock);
shaper_kick(shaper); shaper_kick(shaper);
up(&shaper->sem); spin_unlock(&shaper->lock);
} else
mod_timer(&shaper->timer, jiffies);
} }
/* /*
...@@ -331,21 +327,6 @@ static void shaper_kick(struct shaper *shaper) ...@@ -331,21 +327,6 @@ static void shaper_kick(struct shaper *shaper)
} }
/*
* Flush the shaper queues on a closedown
*/
static void shaper_flush(struct shaper *shaper)
{
struct sk_buff *skb;
down(&shaper->sem);
while((skb=skb_dequeue(&shaper->sendq))!=NULL)
dev_kfree_skb(skb);
shaper_kick(shaper);
up(&shaper->sem);
}
/* /*
* Bring the interface up. We just disallow this until a * Bring the interface up. We just disallow this until a
* bind. * bind.
...@@ -375,7 +356,15 @@ static int shaper_open(struct net_device *dev) ...@@ -375,7 +356,15 @@ static int shaper_open(struct net_device *dev)
static int shaper_close(struct net_device *dev) static int shaper_close(struct net_device *dev)
{ {
struct shaper *shaper=dev->priv; struct shaper *shaper=dev->priv;
shaper_flush(shaper); struct sk_buff *skb;
while ((skb = skb_dequeue(&shaper->sendq)) != NULL)
dev_kfree_skb(skb);
spin_lock_bh(&shaper->lock);
shaper_kick(shaper);
spin_unlock_bh(&shaper->lock);
del_timer_sync(&shaper->timer); del_timer_sync(&shaper->timer);
return 0; return 0;
} }
...@@ -576,6 +565,7 @@ static void shaper_init_priv(struct net_device *dev) ...@@ -576,6 +565,7 @@ static void shaper_init_priv(struct net_device *dev)
init_timer(&sh->timer); init_timer(&sh->timer);
sh->timer.function=shaper_timer; sh->timer.function=shaper_timer;
sh->timer.data=(unsigned long)sh; sh->timer.data=(unsigned long)sh;
spin_lock_init(&sh->lock);
} }
/* /*
......
...@@ -23,7 +23,7 @@ struct shaper ...@@ -23,7 +23,7 @@ struct shaper
__u32 shapeclock; __u32 shapeclock;
unsigned long recovery; /* Time we can next clock a packet out on unsigned long recovery; /* Time we can next clock a packet out on
an empty queue */ an empty queue */
struct semaphore sem; spinlock_t lock;
struct net_device_stats stats; struct net_device_stats stats;
struct net_device *dev; struct net_device *dev;
int (*hard_start_xmit) (struct sk_buff *skb, int (*hard_start_xmit) (struct sk_buff *skb,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment