public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Changli Gao <xiaosuo@gmail.com>
Cc: Jamal Hadi Salim <hadi@cyberus.ca>,
	"David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org
Subject: Re: [PATCH 4/5 v2] ifb: add multiqueue support
Date: Tue, 14 Dec 2010 16:59:18 +0100	[thread overview]
Message-ID: <1292342358.5934.10.camel@edumazet-laptop> (raw)
In-Reply-To: <1292340098-25537-1-git-send-email-xiaosuo@gmail.com>

Le mardi 14 décembre 2010 à 23:21 +0800, Changli Gao a écrit :


> +static struct rtnl_link_stats64 *ifb_get_stats64(struct net_device *dev,
> +		struct rtnl_link_stats64 *stats)
> +{
> +	struct ifb_q_private *q;
> +	struct netdev_queue *txq;
> +	int cpu;
> +	u64 rx_packets, rx_bytes, rx_dropped;
> +	u64 tx_packets, tx_bytes, tx_dropped;
> +	unsigned int start;
> +
> +	for_each_possible_cpu(cpu) {
> +		q = per_cpu_ptr(ifb_priv(dev), cpu);
> +		txq = q->txq;
> +		do {
> +			start = u64_stats_fetch_begin_bh(&q->syncp);
> +			rx_packets = q->rx_packets;
> +			rx_bytes = q->rx_bytes;
> +			rx_dropped = q->rx_dropped;
> +			tx_packets = txq->tx_packets;
> +			tx_bytes = txq->tx_bytes;
> +			tx_dropped = txq->tx_dropped;
> +		} while (u64_stats_fetch_retry_bh(&q->syncp, start));
> +		stats->rx_packets += rx_packets;
> +		stats->rx_bytes += rx_bytes;
> +		stats->rx_dropped += rx_dropped;
> +		stats->tx_packets += tx_packets;
> +		stats->tx_bytes += tx_bytes;
> +		stats->tx_dropped += tx_dropped;
> +	}
> +
> +	return stats;
> +}
> +


There is a problem here.

You should sum in the loop rx_counters only, (the counters syncp
protected), and use dev_txq_stats_fold() to get the tx_counters from
core network.

dev_txq_stats_fold(dev, stats);
for_each_possible_cpu(cpu) {
	q = per_cpu_ptr(ifb_priv(dev), cpu);
	txq = q->txq;
	do {
		start = u64_stats_fetch_begin_bh(&q->syncp);
		rx_packets = q->rx_packets;
		rx_bytes   = q->rx_bytes;
		rx_dropped = q->rx_dropped;
	} while (u64_stats_fetch_retry_bh(&q->syncp, start));
	stats->rx_packets += rx_packets;
	stats->rx_bytes   += rx_bytes;
	stats->rx_dropped += rx_dropped;
}
return stats;



  reply	other threads:[~2010-12-14 15:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-14 15:21 [PATCH 4/5 v2] ifb: add multiqueue support Changli Gao
2010-12-14 15:59 ` Eric Dumazet [this message]
2010-12-15  0:20   ` Changli Gao
2010-12-15  6:37     ` Eric Dumazet

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=1292342358.5934.10.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=hadi@cyberus.ca \
    --cc=netdev@vger.kernel.org \
    --cc=xiaosuo@gmail.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