netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, Willy Tarreau <w@1wt.eu>,
	Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
	Gregory CLEMENT <gregory.clement@free-electrons.com>
Subject: [PATCH 1/5] net: mvneta: increase the 64-bit rx/tx stats out of the hot path
Date: Sun, 12 Jan 2014 10:31:05 +0100	[thread overview]
Message-ID: <1389519069-1619-2-git-send-email-w@1wt.eu> (raw)
In-Reply-To: <1389519069-1619-1-git-send-email-w@1wt.eu>

Better count packets and bytes in the stack and on 32 bit then
accumulate them at the end for once. This saves two memory writes
and two memory barriers per packet. The incoming packet rate was
increased by 4.7% on the Openblocks AX3 thanks to this.

Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
---
 drivers/net/ethernet/marvell/mvneta.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index d5f0d72..baa85af 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -1391,6 +1391,8 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
 {
 	struct net_device *dev = pp->dev;
 	int rx_done, rx_filled;
+	u32 rcvd_pkts = 0;
+	u32 rcvd_bytes = 0;
 
 	/* Get number of received packets */
 	rx_done = mvneta_rxq_busy_desc_num_get(pp, rxq);
@@ -1428,10 +1430,8 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
 
 		rx_bytes = rx_desc->data_size -
 			(ETH_FCS_LEN + MVNETA_MH_SIZE);
-		u64_stats_update_begin(&pp->rx_stats.syncp);
-		pp->rx_stats.packets++;
-		pp->rx_stats.bytes += rx_bytes;
-		u64_stats_update_end(&pp->rx_stats.syncp);
+		rcvd_pkts++;
+		rcvd_bytes += rx_bytes;
 
 		/* Linux processing */
 		skb_reserve(skb, MVNETA_MH_SIZE);
@@ -1452,6 +1452,13 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
 		}
 	}
 
+	if (rcvd_pkts) {
+		u64_stats_update_begin(&pp->rx_stats.syncp);
+		pp->rx_stats.packets += rcvd_pkts;
+		pp->rx_stats.bytes   += rcvd_bytes;
+		u64_stats_update_end(&pp->rx_stats.syncp);
+	}
+
 	/* Update rxq management counters */
 	mvneta_rxq_desc_num_update(pp, rxq, rx_done, rx_filled);
 
-- 
1.7.12.2.21.g234cd45.dirty

  reply	other threads:[~2014-01-12  9:31 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-12  9:31 [PATCH 0/5] Assorted mvneta fixes Willy Tarreau
2014-01-12  9:31 ` Willy Tarreau [this message]
2014-01-13  0:49   ` [PATCH 1/5] net: mvneta: increase the 64-bit rx/tx stats out of the hot path Eric Dumazet
2014-01-13  3:06     ` Willy Tarreau
2014-01-12  9:31 ` [PATCH 2/5] net: mvneta: use per_cpu stats to fix an SMP lock up Willy Tarreau
2014-01-12 18:07   ` Eric Dumazet
2014-01-12 22:09     ` Willy Tarreau
2014-01-13  0:45       ` Eric Dumazet
2014-01-13  3:02         ` Willy Tarreau
2014-01-13  0:48   ` Eric Dumazet
2014-01-12  9:31 ` [PATCH 3/5] net: mvneta: do not schedule in mvneta_tx_timeout Willy Tarreau
2014-01-12 16:49   ` Ben Hutchings
2014-01-12 16:55     ` Willy Tarreau
2014-01-12 17:38       ` Ben Hutchings
2014-01-12 22:14         ` Willy Tarreau
2014-01-14 15:33         ` Willy Tarreau
2014-01-12  9:31 ` [PATCH 4/5] net: mvneta: add missing bit descriptions for interrupt masks and causes Willy Tarreau
2014-01-12  9:31 ` [PATCH 5/5] net: mvneta: replace Tx timer with a real interrupt Willy Tarreau
2014-01-13 23:22   ` Arnaud Ebalard
2014-01-14  7:30     ` Willy Tarreau
2014-01-12 19:21 ` [PATCH 0/5] Assorted mvneta fixes Arnaud Ebalard
2014-01-12 22:22   ` Willy Tarreau
2014-01-13 22:36     ` Arnaud Ebalard
2014-01-14  7:24       ` Willy Tarreau
2014-01-15  0:58 ` David Miller

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=1389519069-1619-2-git-send-email-w@1wt.eu \
    --to=w@1wt.eu \
    --cc=davem@davemloft.net \
    --cc=gregory.clement@free-electrons.com \
    --cc=netdev@vger.kernel.org \
    --cc=thomas.petazzoni@free-electrons.com \
    /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;
as well as URLs for NNTP newsgroup(s).