From patchwork Tue Jan 12 13:41:53 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: 42725 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 91192B7C66 for ; Wed, 13 Jan 2010 00:42:00 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753610Ab0ALNl4 (ORCPT ); Tue, 12 Jan 2010 08:41:56 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753071Ab0ALNlz (ORCPT ); Tue, 12 Jan 2010 08:41:55 -0500 Received: from lanfw001a.cxnet.dk ([87.72.215.196]:46574 "EHLO lanfw001a.cxnet.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751310Ab0ALNlz (ORCPT ); Tue, 12 Jan 2010 08:41:55 -0500 Received: from firesoul.comx.local (unknown [172.31.4.134]) by lanfw001a.cxnet.dk (Postfix) with ESMTP id AE2D416361D; Tue, 12 Jan 2010 14:41:53 +0100 (CET) Received: from firesoul.comx.local (localhost [127.0.0.1]) by firesoul.comx.local (Postfix) with ESMTP id 8B4A05A2D4; Tue, 12 Jan 2010 14:41:53 +0100 (CET) From: Jesper Dangaard Brouer Subject: [net-next PATCH] igb: update adapter stats when reading /proc/net/dev. To: Jeff Kirsher , Alexander Duyck Cc: Jesper Dangaard Brouer , netdev@vger.kernel.org Date: Tue, 12 Jan 2010 14:41:53 +0100 Message-ID: <20100112134153.27117.59960.stgit@firesoul.comx.local> User-Agent: StGIT/0.14.2 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 d967949..7207dd3 100644 --- a/drivers/net/igb/igb_main.c +++ b/drivers/net/igb/igb_main.c @@ -3862,11 +3862,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; } @@ -3940,7 +3946,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 rnbc;