public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeff Garzik <jgarzik@pobox.com>
To: Mark J Roberts <mjr@znex.org>
Cc: Chris Wedgwood <cw@f00f.org>, linux-kernel@vger.kernel.org
Subject: Re: Annoying /proc/net/dev rollovers.
Date: Sun, 16 Feb 2003 22:24:26 -0500	[thread overview]
Message-ID: <3E5055EA.7080507@pobox.com> (raw)
In-Reply-To: <20030217024605.GB246@znex>

Mark J Roberts wrote:
> Chris Wedgwood:
>>>total_rx_bytes += rx_bytes;
>>
>>if lval is 64-bit, then this cannot be done reliably on all
>>architectures
> 
> 
> I'm not sure why. I realize that x86 can't do atomic 64-bit
> operations, but what I propose is to leave the 32-bit rx_bytes code
> the way it is, and just have some heuristic for updating the 64-bit
> value every so often, which can be done under a lock, so there would
> be no opportunity for races to corrupt the counter. (This is also an
> optimization since there needn't be any locks in the actual packet
> handling code.)


I was one of the ones who was interested in making the statistics 
64-bit, and adding locking to do it right.  The solution finally 
appeared, many months ago:

The counters don't need to be 64-bit, because it is trivially possible 
for userspace to track the statistics, and to simply use the difference 
between two samples as the increment used in calculating whatever 
numbers you wish -- 64-bit SNMP MIB statistics were what I was 
interested in.  Wrapping is trivially handled by standard unsigned int 
arithmetic, among other methods.

If you really want the raw data, then use ethtool's NIC-specific stats 
facility, to retrieve raw statistics directly from the NIC.  [this of 
course requires driver modifications, but they are easy on modern NICs]

	Jeff



  reply	other threads:[~2003-02-17  3:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-16 22:16 Annoying /proc/net/dev rollovers Mark J Roberts
2003-02-17  1:41 ` Chris Wedgwood
2003-02-17  2:46   ` Mark J Roberts
2003-02-17  3:24     ` Jeff Garzik [this message]
2003-02-17  4:21     ` Chris Wedgwood
2003-02-17 10:35       ` Matti Aarnio
2003-02-18  4:58         ` David Lang
2003-02-18 13:28           ` Matti Aarnio

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=3E5055EA.7080507@pobox.com \
    --to=jgarzik@pobox.com \
    --cc=cw@f00f.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjr@znex.org \
    /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