From patchwork Thu Apr 16 12:23:56 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brice Goglin X-Patchwork-Id: 26067 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id 7BC17B6F35 for ; Thu, 16 Apr 2009 22:24:17 +1000 (EST) Received: by ozlabs.org (Postfix) id 6D7DFDE20B; Thu, 16 Apr 2009 22:24:17 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 13978DE1E5 for ; Thu, 16 Apr 2009 22:24:17 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752302AbZDPMXx (ORCPT ); Thu, 16 Apr 2009 08:23:53 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751710AbZDPMXx (ORCPT ); Thu, 16 Apr 2009 08:23:53 -0400 Received: from mailbox2.myri.com ([64.172.73.26]:1976 "EHLO myri.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751141AbZDPMXx (ORCPT ); Thu, 16 Apr 2009 08:23:53 -0400 Received: from [172.31.134.203] (brice-ovpn.sw.myri.com [172.31.134.203]) by myri.com (8.13.7+Sun/8.13.7) with ESMTP id n3GCNlNd010760; Thu, 16 Apr 2009 05:23:48 -0700 (PDT) Message-ID: <49E7235C.4080601@myri.com> Date: Thu, 16 Apr 2009 14:23:56 +0200 From: Brice Goglin User-Agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103) MIME-Version: 1.0 To: "David S. Miller" CC: Linux Network Development list Subject: [PATCH net-next] myri10ge: force stats update in ethtool gstats X-Enigmail-Version: 0.95.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Force a statistics update when our ethtool gstats routine is called. Otherwise, ethtool will continue to read stale stats until something forces an update by reading /proc/net/dev This requires putting a lock around the stats update to guard against 2 threads (one via ethtool, and one via procfs) updating the stats at once. Signed-off-by: Brice Goglin --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- linux-tmp.20090327.1716.42/drivers/net/myri10ge/myri10ge.c 2009-03-24 10:50:10.000000000 +0100 +++ linux-tmp/drivers/net/myri10ge/myri10ge.c 2009-03-27 17:16:43.000000000 +0100 @@ -361,6 +361,8 @@ static inline void put_be32(__be32 val, __raw_writel((__force __u32) val, (__force void __iomem *)p); } +static struct net_device_stats *myri10ge_get_stats(struct net_device *dev); + static int myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd, struct myri10ge_cmd *data, int atomic) @@ -1803,6 +1805,8 @@ myri10ge_get_ethtool_stats(struct net_de int slice; int i; + /* force stats update */ + (void)myri10ge_get_stats(netdev); for (i = 0; i < MYRI10GE_NET_STATS_LEN; i++) data[i] = ((unsigned long *)&mgp->stats)[i]; @@ -2968,6 +2972,7 @@ static struct net_device_stats *myri10ge struct net_device_stats *stats = &mgp->stats; int i; + spin_lock(&mgp->stats_lock); memset(stats, 0, sizeof(*stats)); for (i = 0; i < mgp->num_slices; i++) { slice_stats = &mgp->ss[i].stats; @@ -2978,6 +2983,7 @@ static struct net_device_stats *myri10ge stats->rx_dropped += slice_stats->rx_dropped; stats->tx_dropped += slice_stats->tx_dropped; } + spin_unlock(&mgp->stats_lock); return stats; } @@ -3901,6 +3907,7 @@ static int myri10ge_probe(struct pci_dev setup_timer(&mgp->watchdog_timer, myri10ge_watchdog_timer, (unsigned long)mgp); + spin_lock_init(&mgp->stats_lock); SET_ETHTOOL_OPS(netdev, &myri10ge_ethtool_ops); INIT_WORK(&mgp->watchdog_work, myri10ge_watchdog); status = register_netdev(netdev);