From patchwork Tue Oct 5 14:18:33 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesper Dangaard Brouer X-Patchwork-Id: 66835 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 80E3CB70B8 for ; Wed, 6 Oct 2010 01:24:56 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753303Ab0JEOYw (ORCPT ); Tue, 5 Oct 2010 10:24:52 -0400 Received: from albpd42.cxnet.dk ([87.72.130.6]:46116 "EHLO albpd42.cxnet.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753553Ab0JEOYv (ORCPT ); Tue, 5 Oct 2010 10:24:51 -0400 X-Greylist: delayed 376 seconds by postgrey-1.27 at vger.kernel.org; Tue, 05 Oct 2010 10:24:51 EDT Received: from [127.0.0.1] (localhost [127.0.0.1]) by albpd42.cxnet.dk (Postfix) with ESMTP id 35A63BF92; Tue, 5 Oct 2010 16:18:33 +0200 (CEST) Subject: [net-next PATCH] igb: update adapter stats when reading /proc/net/dev. To: "David S. Miller" From: Jesper Dangaard Brouer Cc: netdev@vger.kernel.org, Jeff Kirsher Date: Tue, 05 Oct 2010 16:18:33 +0200 Message-ID: <20101005141833.20929.10943.stgit@localhost> User-Agent: StGit/0.15 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Network driver igb: Improve the accuracy of stats in /proc/net/dev, by updating the adapter stats when reading /proc/net/dev. Currently the stats are updated by the watchdog timer every 2 sec, or when getting stats via ethtool -S. A number of userspace apps read these /proc/net/dev stats every second, e.g. ifstat, which then gives a perceived very bursty traffic pattern, which is actually false. Signed-off-by: Jesper Dangaard Brouer --- drivers/net/igb/igb_main.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) -- 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 diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c index 55edcb7..6cec297 100644 --- a/drivers/net/igb/igb_main.c +++ b/drivers/net/igb/igb_main.c @@ -4218,11 +4218,17 @@ static void igb_reset_task(struct work_struct *work) * @netdev: network interface device structure * * Returns the address of the device statistics structure. - * The statistics are actually updated from the timer callback. + * The statistics are also updated from the timer callback + * igb_watchdog_task(). **/ static struct net_device_stats *igb_get_stats(struct net_device *netdev) { - /* only return the current stats */ + struct igb_adapter *adapter = netdev_priv(netdev); + + /* update stats */ + igb_update_stats(adapter); + + /* return the current stats */ return &netdev->stats; } @@ -4307,7 +4313,7 @@ static int igb_change_mtu(struct net_device *netdev, int new_mtu) void igb_update_stats(struct igb_adapter *adapter) { - struct net_device_stats *net_stats = igb_get_stats(adapter->netdev); + struct net_device_stats *net_stats = &adapter->netdev->stats; struct e1000_hw *hw = &adapter->hw; struct pci_dev *pdev = adapter->pdev; u32 reg, mpc;