From: Greg KH <gregkh@suse.de>
To: davem@davemloft.net, hch@lst.de
Cc: linux-kernel@vger.kernel.org, stable@kernel.org,
Justin Forbes <jmforbes@linuxtx.org>,
Zwane Mwaikambo <zwane@arm.linux.org.uk>,
"Theodore Ts'o" <tytso@mit.edu>,
"Randy.Dunlap" <rdunlap@xenotime.net>,
Chuck Wolber <chuckw@quantumlinux.com>,
torvalds@osdl.org, akpm@osdl.org, alan@lxorguk.ukuu.org.uk
Subject: [04/11] [SHAPER] fix Shaper driver lossage in 2.6.12
Date: Wed, 13 Jul 2005 11:43:23 -0700 [thread overview]
Message-ID: <20050713184323.GF9330@kroah.com> (raw)
In-Reply-To: <20050713184130.GA9330@kroah.com>
-stable review patch. If anyone has any objections, please let us know.
------------------
[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: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Chris Wright <chrisw@osdl.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/net/shaper.c | 42 ++++++++++++++++--------------------------
include/linux/if_shaper.h | 2 +-
2 files changed, 17 insertions(+), 27 deletions(-)
--- linux-2.6.12.2.orig/drivers/net/shaper.c 2005-06-17 12:48:29.000000000 -0700
+++ linux-2.6.12.2/drivers/net/shaper.c 2005-07-13 10:56:34.000000000 -0700
@@ -135,10 +135,8 @@
{
struct shaper *shaper = dev->priv;
struct sk_buff *ptr;
-
- if (down_trylock(&shaper->sem))
- return -1;
-
+
+ spin_lock(&shaper->lock);
ptr=shaper->sendq.prev;
/*
@@ -232,7 +230,7 @@
shaper->stats.collisions++;
}
shaper_kick(shaper);
- up(&shaper->sem);
+ spin_unlock(&shaper->lock);
return 0;
}
@@ -271,11 +269,9 @@
{
struct shaper *shaper = (struct shaper *)data;
- if (!down_trylock(&shaper->sem)) {
- shaper_kick(shaper);
- up(&shaper->sem);
- } else
- mod_timer(&shaper->timer, jiffies);
+ spin_lock(&shaper->lock);
+ shaper_kick(shaper);
+ spin_unlock(&shaper->lock);
}
/*
@@ -332,21 +328,6 @@
/*
- * 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
* bind.
*/
@@ -375,7 +356,15 @@
static int shaper_close(struct net_device *dev)
{
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);
return 0;
}
@@ -576,6 +565,7 @@
init_timer(&sh->timer);
sh->timer.function=shaper_timer;
sh->timer.data=(unsigned long)sh;
+ spin_lock_init(&sh->lock);
}
/*
--- linux-2.6.12.2.orig/include/linux/if_shaper.h 2005-06-17 12:48:29.000000000 -0700
+++ linux-2.6.12.2/include/linux/if_shaper.h 2005-07-13 10:56:34.000000000 -0700
@@ -23,7 +23,7 @@
__u32 shapeclock;
unsigned long recovery; /* Time we can next clock a packet out on
an empty queue */
- struct semaphore sem;
+ spinlock_t lock;
struct net_device_stats stats;
struct net_device *dev;
int (*hard_start_xmit) (struct sk_buff *skb,
next prev parent reply other threads:[~2005-07-13 21:54 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-13 18:41 [00/11] -stable review Greg KH
2005-07-13 18:42 ` [02/11] [NETFILTER]: revert nf_reset change Greg KH
2005-07-13 18:42 ` [03/11] ppc32: stop misusing ntps time_offset value Greg KH
2005-07-13 18:43 ` [01/11] If ACPI doesn't find an irq listed, don't accept 0 as a valid PCI irq Greg KH
2005-07-13 18:43 ` Greg KH [this message]
2005-07-13 18:43 ` [05/11] SMP fix for 6pack driver Greg KH
2005-07-13 22:01 ` Francois Romieu
2005-07-13 22:13 ` [stable] " Greg KH
2005-07-15 19:35 ` Adrian Bunk
2005-07-17 21:09 ` Ralf Baechle
2005-07-24 16:08 ` Adrian Bunk
2005-07-13 18:43 ` [06/11] tpm breaks 8139cp Greg KH
2005-07-13 19:09 ` John W. Linville
2005-07-13 18:43 ` [07/11] v4l cx88 hue offset fix Greg KH
2005-07-13 18:43 ` [08/11] coverity: tty_ldisc_ref return null check Greg KH
2005-07-13 18:44 ` [09/11] uml: fix TT mode by reverting "use fork instead of clone" Greg KH
2005-07-13 18:44 ` [10/11] fix semaphore handling in __unregister_chrdev_region Greg KH
2005-07-13 18:44 ` [11/11] x86_64: TASK_SIZE fixes for compatibility mode processes Greg KH
2005-07-13 18:49 ` Andi Kleen
2005-07-13 20:47 ` [stable] " Greg KH
2005-07-14 16:45 ` Siddha, Suresh B
2005-07-15 15:53 ` Justin M. Forbes
2005-07-16 2:17 ` Siddha, Suresh B
2005-07-16 4:25 ` Andi Kleen
2005-07-16 5:42 ` [stable] " Chris Wright
2005-07-13 22:05 ` Horst von Brand
2005-07-13 22:36 ` [stable] " Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050713184323.GF9330@kroah.com \
--to=gregkh@suse.de \
--cc=akpm@osdl.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=chuckw@quantumlinux.com \
--cc=davem@davemloft.net \
--cc=hch@lst.de \
--cc=jmforbes@linuxtx.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rdunlap@xenotime.net \
--cc=stable@kernel.org \
--cc=torvalds@osdl.org \
--cc=tytso@mit.edu \
--cc=zwane@arm.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox