From patchwork Tue Oct 21 19:09:35 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: stephen hemminger X-Patchwork-Id: 5259 X-Patchwork-Delegate: jgarzik@pobox.com 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.176.167]) by ozlabs.org (Postfix) with ESMTP id E1EFEDDDE7 for ; Wed, 22 Oct 2008 06:11:55 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751999AbYJUTLs (ORCPT ); Tue, 21 Oct 2008 15:11:48 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751969AbYJUTLs (ORCPT ); Tue, 21 Oct 2008 15:11:48 -0400 Received: from mail.vyatta.com ([76.74.103.46]:43469 "EHLO mail.vyatta.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751707AbYJUTLr (ORCPT ); Tue, 21 Oct 2008 15:11:47 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.vyatta.com (Postfix) with ESMTP id 71BFC4F461E; Tue, 21 Oct 2008 12:11:48 -0700 (PDT) X-Virus-Scanned: amavisd-new at Received: from mail.vyatta.com ([127.0.0.1]) by localhost (mail.vyatta.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id r96A1t-M47zH; Tue, 21 Oct 2008 12:11:48 -0700 (PDT) Received: from extreme (unknown [96.225.231.79]) by mail.vyatta.com (Postfix) with ESMTP id EC1404F4295; Tue, 21 Oct 2008 12:11:47 -0700 (PDT) Date: Tue, 21 Oct 2008 12:09:35 -0700 From: Stephen Hemminger To: jeffery.t.kirsher@intel.com, jesse.brandeburg@intel.com, bruce.w.allan@intel.com, peter.p.waskiewicz.jr@intel.com Cc: e1000-devel@lists.sourceforge.net, netdev@vger.kernel.org Subject: [RFC 1/2] igb: statistic optimization Message-ID: <20081021120935.1b3cea8d@extreme> Organization: Vyatta X-Mailer: Claws Mail 3.3.1 (GTK+ 2.12.9; x86_64-pc-linux-gnu) Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The network statistics were being updated by multiple CPU's causing cache line bounces. Since this driver already keeps statistics per ring, use those to compute the bytes/packet statistics. Signed-off-by: Stephen Hemminger --- Compile tested only, evaluation in progress -- 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 --- a/drivers/net/igb/igb_main.c 2008-10-21 08:57:11.000000000 -0700 +++ b/drivers/net/igb/igb_main.c 2008-10-21 09:05:43.000000000 -0700 @@ -3029,9 +3029,27 @@ static struct net_device_stats * igb_get_stats(struct net_device *netdev) { struct igb_adapter *adapter = netdev_priv(netdev); + struct net_device_stats *stats = &adapter->net_stats; + int i; + + stats->tx_bytes = 0; + stats->tx_packets = 0; + for (i = 0; i < adapter->num_tx_queues; i++) { + struct igb_ring *tx_ring = &adapter->tx_ring[i]; + stats->tx_bytes += tx_ring->tx_stats.bytes; + stats->tx_packets += tx_ring->tx_stats.packets; + } + stats->rx_bytes = 0; + stats->rx_packets = 0; + for (i = 0; i < adapter->num_rx_queues; i++) { + struct igb_ring *rx_ring = &adapter->rx_ring[i]; + stats->rx_bytes += rx_ring->rx_stats.bytes; + stats->rx_packets += rx_ring->rx_stats.packets; + } + + igb_update_stats(adapter); - /* only return the current stats */ - return &adapter->net_stats; + return stats; } /** @@ -3711,8 +3729,6 @@ done_cleaning: tx_ring->total_packets += total_packets; tx_ring->tx_stats.bytes += total_bytes; tx_ring->tx_stats.packets += total_packets; - adapter->net_stats.tx_bytes += total_bytes; - adapter->net_stats.tx_packets += total_packets; return retval; } @@ -3953,8 +3969,6 @@ next_desc: rx_ring->total_bytes += total_bytes; rx_ring->rx_stats.packets += total_packets; rx_ring->rx_stats.bytes += total_bytes; - adapter->net_stats.rx_bytes += total_bytes; - adapter->net_stats.rx_packets += total_packets; return cleaned; }