From: Eric Dumazet <eric.dumazet@gmail.com>
To: Denis Kirjanov <dkirjanov@kernel.org>,
David Miller <davem@davemloft.net>
Cc: netdev <netdev@vger.kernel.org>
Subject: [PATCH net-next] sundance: get_stats proper locking
Date: Sat, 09 Oct 2010 14:17:01 +0200 [thread overview]
Message-ID: <1286626621.2692.18.camel@edumazet-laptop> (raw)
In-Reply-To: <20101009095346.GA12951@hera.kernel.org>
Le samedi 09 octobre 2010 à 09:53 +0000, Denis Kirjanov a écrit :
> Add initial ethtool statistics support
OK, I guess its time to add proper locking into sundance after all ;)
[PATCH net-next] sundance: get_stats proper locking
sundance get_stats() should not be run concurrently, add a lock to avoid
potential losses.
Note: Remove unused rx_lock field
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
drivers/net/sundance.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c
index 27d69aa..4283cc5 100644
--- a/drivers/net/sundance.c
+++ b/drivers/net/sundance.c
@@ -365,7 +365,6 @@ struct netdev_private {
struct timer_list timer; /* Media monitoring timer. */
/* Frequently used values: keep some adjacent for cache effect. */
spinlock_t lock;
- spinlock_t rx_lock; /* Group with Tx control cache line. */
int msg_enable;
int chip_id;
unsigned int cur_rx, dirty_rx; /* Producer/consumer ring indices */
@@ -390,6 +389,7 @@ struct netdev_private {
unsigned char phys[MII_CNT]; /* MII device addresses, only first one used. */
struct pci_dev *pci_dev;
void __iomem *base;
+ spinlock_t statlock;
};
/* The station address location in the EEPROM. */
@@ -514,6 +514,7 @@ static int __devinit sundance_probe1 (struct pci_dev *pdev,
np->chip_id = chip_idx;
np->msg_enable = (1 << debug) - 1;
spin_lock_init(&np->lock);
+ spin_lock_init(&np->statlock);
tasklet_init(&np->rx_tasklet, rx_poll, (unsigned long)dev);
tasklet_init(&np->tx_tasklet, tx_poll, (unsigned long)dev);
@@ -1486,10 +1487,9 @@ static struct net_device_stats *get_stats(struct net_device *dev)
struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->base;
int i;
+ unsigned long flags;
- /* We should lock this segment of code for SMP eventually, although
- the vulnerability window is very small and statistics are
- non-critical. */
+ spin_lock_irqsave(&np->statlock, flags);
/* The chip only need report frame silently dropped. */
dev->stats.rx_missed_errors += ioread8(ioaddr + RxMissed);
dev->stats.tx_packets += ioread16(ioaddr + TxFramesOK);
@@ -1506,6 +1506,8 @@ static struct net_device_stats *get_stats(struct net_device *dev)
dev->stats.rx_bytes += ioread16(ioaddr + RxOctetsLow);
dev->stats.rx_bytes += ioread16(ioaddr + RxOctetsHigh) << 16;
+ spin_unlock_irqrestore(&np->statlock, flags);
+
return &dev->stats;
}
next prev parent reply other threads:[~2010-10-09 12:17 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-09 9:53 [PATCH -next] sundance: Add initial ethtool stats support Denis Kirjanov
2010-10-09 12:17 ` Eric Dumazet [this message]
2010-10-09 16:24 ` [PATCH net-next] sundance: get_stats proper locking David Miller
2010-10-09 12:33 ` [PATCH -next] sundance: Add initial ethtool stats support Eric Dumazet
2010-10-09 13:27 ` Ben Hutchings
2010-10-09 14:40 ` Denis Kirjanov
2010-10-09 19:41 ` Denis Kirjanov
2010-10-09 21:48 ` Jeff Garzik
2010-10-12 18:51 ` David Miller
2010-10-12 20:36 ` Denis Kirjanov
2010-10-12 20:57 ` Joe Perches
2010-10-13 6:06 ` Denis Kirjanov
2010-10-13 6:33 ` Eric Dumazet
2010-10-13 7:02 ` Denis Kirjanov
2010-10-13 10:28 ` Denis Kirjanov
2010-10-13 10:36 ` Eric Dumazet
2010-10-13 10:56 ` Denis Kirjanov
2010-10-13 19:44 ` Eric Dumazet
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=1286626621.2692.18.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=dkirjanov@kernel.org \
--cc=netdev@vger.kernel.org \
/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