From: Eric Dumazet <eric.dumazet@gmail.com>
To: Junchang Wang <junchangwang@gmail.com>
Cc: Ben Hutchings <bhutchings@solarflare.com>,
David Miller <davem@davemloft.net>,
romieu@fr.zoreil.com, netdev@vger.kernel.org
Subject: Re: 64-bit net_device_stats
Date: Fri, 04 Jun 2010 05:59:03 +0200 [thread overview]
Message-ID: <1275623943.2533.116.camel@edumazet-laptop> (raw)
In-Reply-To: <20100604015956.GA10971@host-a-55.ustcsz.edu.cn>
Le vendredi 04 juin 2010 à 09:59 +0800, Junchang Wang a écrit :
> Hi Ben,
>
> On Wed, Jun 02, 2010 at 10:34:29PM +0100, Ben Hutchings wrote:
> >Changing the counter types to u64 for 32-bit architectures would remove
> >atomicity and expose half-updated counters to userland. Changing the
> >driver interface significantly so that atomicity is not needed would
> >require changes to hundreds of drivers.
> >
> >Assuming the above is all correct, I think we can only solve this with a
> >gradual change (as for net_device_ops). The following might work:
> >
> I realized the network team doesn't care about 64-bit counters (especially rx_*) on 32-bit systems. A similar disscussion can be found here:
> http://www.gossamer-threads.com/lists/linux/kernel/282631?search_string=64%20stats;#282631
>
Well, the outlined discussion is 8 years old. Some things changed so we
probably have more possibilities today. per_cpu infrastructure is pretty
cool now for example.
If stats are updated only by the NIC, we can have 64 bit stats with
nearly 0 cost.
Real problem is some stats are updated by software.
Upgrading them to 64 bits would need atomic64 to coordinate writers and
readers, or making sure reader use appropriate locks to serialize with
the writer.
> And Eric just gave a explanation why they stand by that point. Updating rx_* counters in core network will dirty a cache line.
Sorry, I realize I was a bit wrong in my last mail.
In txq_trans_update(txq) we only update the time (in jiffies) of last
transmission, using a txq field instead of dev->trans_start)
txq->tx_bytes, txq->tx_packets, txq->tx_dropped _might_ be used by
_drivers_ to update tx counters, instead of dev->stats{tx_bytes,
tx_packets, tx_dropped}, especially by multiqueue drivers.
txq->tx... updates are better because they are multiqueue compatable (no
need to use atomic ops), and they use a cache line already dirtied
because we hold txq lock at transmission time (unless for LLTX drivers)
(For an example, check drivers/net/macvlan.c, macvlan_start_xmit() and
commit 2c11455321f3)
prev parent reply other threads:[~2010-06-04 3:59 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-25 14:19 [PATCH] r8169: Add counters tx_bytes and rx_bytes for ethtool Junchang Wang
2010-05-25 19:56 ` Francois Romieu
2010-05-26 1:01 ` Junchang Wang
2010-05-25 23:15 ` David Miller
2010-05-26 0:51 ` Junchang Wang
2010-06-02 21:34 ` 64-bit net_device_stats Ben Hutchings
2010-06-02 21:59 ` Stephen Hemminger
2010-06-02 23:38 ` Arnd Bergmann
2010-06-03 14:51 ` Ben Hutchings
2010-06-03 17:39 ` [PATCH 1/2] net: Enable 64-bit net device statistics on 32-bit architectures Ben Hutchings
2010-06-03 18:47 ` Stephen Hemminger
2010-06-03 19:11 ` Ben Hutchings
2010-06-04 17:28 ` Stephen Hemminger
2010-06-04 18:15 ` Ben Hutchings
2010-06-04 20:39 ` Stephen Hemminger
2010-06-04 20:47 ` Ben Hutchings
2010-06-03 17:40 ` [PATCH 2/2] sfc: Implement 64-bit net device statistics on all architectures Ben Hutchings
2010-06-04 1:59 ` 64-bit net_device_stats Junchang Wang
2010-06-04 3:59 ` Eric Dumazet [this message]
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=1275623943.2533.116.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=bhutchings@solarflare.com \
--cc=davem@davemloft.net \
--cc=junchangwang@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=romieu@fr.zoreil.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