* Re: [NET] 64 bit byte counter for 2.6.3
[not found] <1077123078.9223.7.camel@midux>
@ 2004-02-18 18:17 ` Stephen Hemminger
[not found] ` <Pine.LNX.4.53.0402181527000.7318@chaos>
2004-02-19 8:14 ` Meelis Roos
0 siblings, 2 replies; 7+ messages in thread
From: Stephen Hemminger @ 2004-02-18 18:17 UTC (permalink / raw)
To: Markus Hästbacka; +Cc: linux-kernel, netdev
On Wed, 18 Feb 2004 18:51:19 +0200
Markus Hästbacka <midian@ihme.org> wrote:
> Ok, Here's a patch for 64 bit byte counters for 2.6.3. For any intrested
> users to try.
>
> That means in english that the limit for RX bytes and TX bytes (in
> ifconfig for example) is much higher than the old 4GB limit on 32 bit
> systems.
>
> Orginal patch by Miika Pekkarinen, ported forward from 2.5 by me.
>
> Patch says 2.6.3-rc1, but patches cleanly on 2.6.3.
>
> Markus
Some quick comments:
* Network changes gets discussed on netdev@oss.sgi.com
* 64 bit values are not atomic on 32 bit architectures
* wider values in /proc output risks breaking apps like ifconfig and netstat
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [NET] 64 bit byte counter for 2.6.3
[not found] ` <Pine.LNX.4.53.0402181527000.7318@chaos>
@ 2004-02-18 20:43 ` Markus Hästbacka
2004-02-18 22:45 ` Richard B. Johnson
0 siblings, 1 reply; 7+ messages in thread
From: Markus Hästbacka @ 2004-02-18 20:43 UTC (permalink / raw)
To: root; +Cc: Kernel Mailinglist, netdev
On Wed, 2004-02-18 at 22:32, Richard B. Johnson wrote:
> Manipulation of a 'long long' is not atomic in 32 bit architectures.
> Please explain how we don't care, if we shouldn't care. Also some
> /proc entries might get read incorrectly with existing tools.
Please, tell me all the tools, I'll test them. ifconfig and netstat
works correctly atleast.
And about the caring, is rx/tx bytes so important that they can't use
long long? I would care to see more than 4GB, and maybe some error in
the counter at some point (Have you _ever_ seen that happen?) than only
4GB.
And no, I didn't post this to be merged into the mainline kernel, just
to let users know that there maybe is an option for seeing maximum 4GB.
This has been working for me since, umm.. let's say 2.4.20. All the
tools I've needed have worked.
Markus
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [NET] 64 bit byte counter for 2.6.3
2004-02-18 20:43 ` Markus Hästbacka
@ 2004-02-18 22:45 ` Richard B. Johnson
2004-02-18 22:57 ` Stephen Hemminger
0 siblings, 1 reply; 7+ messages in thread
From: Richard B. Johnson @ 2004-02-18 22:45 UTC (permalink / raw)
To: Markus Hästbacka; +Cc: Kernel Mailinglist, netdev
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: TEXT/PLAIN; charset=X-UNKNOWN, Size: 2755 bytes --]
On Wed, 18 Feb 2004, Markus [ISO-8859-1] Hästbacka wrote:
> On Wed, 2004-02-18 at 22:32, Richard B. Johnson wrote:
> > Manipulation of a 'long long' is not atomic in 32 bit architectures.
> > Please explain how we don't care, if we shouldn't care. Also some
> > /proc entries might get read incorrectly with existing tools.
> Please, tell me all the tools, I'll test them. ifconfig and netstat
> works correctly atleast.
>
Hum, they will work when they see 2^64 written in ASCII in /proc/net/dev ?
I doubt that. Have you ever even seen 64-bit ASCII?
The largest unsigned long long will be 18446744073709551615.
If it's read with 32-bit tools (sscanf), it will read 4294967295.
> And about the caring, is rx/tx bytes so important that they can't use
> long long? I would care to see more than 4GB, and maybe some error in
> the counter at some point (Have you _ever_ seen that happen?) than only
> 4GB.
>
The 32-bit wrap is a serious problem. It can't be ignored. The writing
of any multiple-part variable in the kernel can be interrupted at
any time. Interrupting half-written variables can have dire
consequences. Let's pretend that gcc knows how to write a long-long
with minimum overhead..... high word is in edx and the low word is
in eax. The memory variable is addressed by ebx....
addl %eax, (%ebx) # Sum low word
adcl %edx, 0x04(%ebx) # Sum CY and high
Now, get interrupted...
addl %eax, (%ebx) # Sum low word
->>> interrupt <<<--
Do some code that adds more stuff to
the variable....
Return to the interrupted code.
adcl %edx, 0x04(%ebx) # Sum CY and high
The memory variable is now wrong. If it's an event counter, maybe
it doesn't make any difference. That's what needs to be addressed.
You can't just dismiss it. Any time you write code that knowingly
results in the wrong results, its impact needs to be fully understood.
Changing a bunch of variables in a 32-bit machine to 64-bit ones
is a major change, regardless of how trivial it may seem.
You need to make a spin-locked thingy for every variable you
want to manipulate if the result needs to be correct.
> And no, I didn't post this to be merged into the mainline kernel, just
> to let users know that there maybe is an option for seeing maximum 4GB.
>
> This has been working for me since, umm.. let's say 2.4.20. All the
> tools I've needed have worked.
Just wait until your packet count is 4294967296. It will likely read 0.
When 4294967297, may read 1. That's off by quite a bit.
>
> Markus
>
Cheers,
Dick Johnson
Penguin : Linux version 2.4.24 on an Intel Pentium III machine (797.90 BogoMips).
Note 96.31% of all statistics are fiction.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [NET] 64 bit byte counter for 2.6.3
2004-02-18 22:45 ` Richard B. Johnson
@ 2004-02-18 22:57 ` Stephen Hemminger
2004-02-18 23:17 ` Jeff Garzik
0 siblings, 1 reply; 7+ messages in thread
From: Stephen Hemminger @ 2004-02-18 22:57 UTC (permalink / raw)
To: root; +Cc: Markus Hästbacka, Kernel Mailinglist, netdev
On Wed, 18 Feb 2004 17:45:16 -0500 (EST)
"Richard B. Johnson" <root@chaos.analogic.com> wrote:
> On Wed, 18 Feb 2004, Markus [ISO-8859-1] Hästbacka wrote:
>
> > On Wed, 2004-02-18 at 22:32, Richard B. Johnson wrote:
> > > Manipulation of a 'long long' is not atomic in 32 bit architectures.
> > > Please explain how we don't care, if we shouldn't care. Also some
> > > /proc entries might get read incorrectly with existing tools.
> > Please, tell me all the tools, I'll test them. ifconfig and netstat
> > works correctly atleast.
> >
>
> Hum, they will work when they see 2^64 written in ASCII in /proc/net/dev ?
> I doubt that. Have you ever even seen 64-bit ASCII?
>
> The largest unsigned long long will be 18446744073709551615.
> If it's read with 32-bit tools (sscanf), it will read 4294967295.
>
> > And about the caring, is rx/tx bytes so important that they can't use
> > long long? I would care to see more than 4GB, and maybe some error in
> > the counter at some point (Have you _ever_ seen that happen?) than only
> > 4GB.
> >
>
> The 32-bit wrap is a serious problem. It can't be ignored. The writing
> of any multiple-part variable in the kernel can be interrupted at
> any time. Interrupting half-written variables can have dire
> consequences. Let's pretend that gcc knows how to write a long-long
> with minimum overhead..... high word is in edx and the low word is
> in eax. The memory variable is addressed by ebx....
>
> addl %eax, (%ebx) # Sum low word
> adcl %edx, 0x04(%ebx) # Sum CY and high
>
> Now, get interrupted...
>
> addl %eax, (%ebx) # Sum low word
> ->>> interrupt <<<--
>
> Do some code that adds more stuff to
> the variable....
>
> Return to the interrupted code.
>
> adcl %edx, 0x04(%ebx) # Sum CY and high
>
> The memory variable is now wrong. If it's an event counter, maybe
> it doesn't make any difference. That's what needs to be addressed.
> You can't just dismiss it. Any time you write code that knowingly
> results in the wrong results, its impact needs to be fully understood.
>
> Changing a bunch of variables in a 32-bit machine to 64-bit ones
> is a major change, regardless of how trivial it may seem.
>
> You need to make a spin-locked thingy for every variable you
> want to manipulate if the result needs to be correct.
>
> > And no, I didn't post this to be merged into the mainline kernel, just
> > to let users know that there maybe is an option for seeing maximum 4GB.
> >
> > This has been working for me since, umm.. let's say 2.4.20. All the
> > tools I've needed have worked.
>
> Just wait until your packet count is 4294967296. It will likely read 0.
> When 4294967297, may read 1. That's off by quite a bit.
>
> >
> > Markus
> >
>
> Cheers,
> Dick Johnson
> Penguin : Linux version 2.4.24 on an Intel Pentium III machine (797.90 BogoMips).
> Note 96.31% of all statistics are fiction.
>
Do it right:
* use per-cpu long long for both bytes and packet counts
and change each driver ...
* expose both a new 64 bit and legacy 32 bit /proc interface
* no tools use /sys yet, so that needs to show long long
* have both a get_stats and get_stats64 hook in netdevice so not all drivers
have to be converted at once.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [NET] 64 bit byte counter for 2.6.3
2004-02-18 22:57 ` Stephen Hemminger
@ 2004-02-18 23:17 ` Jeff Garzik
0 siblings, 0 replies; 7+ messages in thread
From: Jeff Garzik @ 2004-02-18 23:17 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: root, Markus Hästbacka, Kernel Mailinglist, netdev
Stephen Hemminger wrote:
> Do it right:
> * use per-cpu long long for both bytes and packet counts
> and change each driver ...
> * expose both a new 64 bit and legacy 32 bit /proc interface
> * no tools use /sys yet, so that needs to show long long
> * have both a get_stats and get_stats64 hook in netdevice so not all drivers
> have to be converted at once.
Yep.
Jeff
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [NET] 64 bit byte counter for 2.6.3
2004-02-18 18:17 ` [NET] 64 bit byte counter for 2.6.3 Stephen Hemminger
[not found] ` <Pine.LNX.4.53.0402181527000.7318@chaos>
@ 2004-02-19 8:14 ` Meelis Roos
2004-02-19 17:27 ` Stephen Hemminger
1 sibling, 1 reply; 7+ messages in thread
From: Meelis Roos @ 2004-02-19 8:14 UTC (permalink / raw)
To: linux-kernel, netdev
SH> * Network changes gets discussed on netdev@oss.sgi.com
SH> * 64 bit values are not atomic on 32 bit architectures
Agree.
SH> * wider values in /proc output risks breaking apps like ifconfig and netstat
This is probably not a problem here, ifconfig etc have been working fine
with non-wrapping numbers on sparc64 and other 64-bit machines.
--
Meelis Roos
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [NET] 64 bit byte counter for 2.6.3
2004-02-19 8:14 ` Meelis Roos
@ 2004-02-19 17:27 ` Stephen Hemminger
0 siblings, 0 replies; 7+ messages in thread
From: Stephen Hemminger @ 2004-02-19 17:27 UTC (permalink / raw)
To: netdev; +Cc: mroos, linux-kernel
On Thu, 19 Feb 2004 10:14:55 +0200
Meelis Roos <mroos@linux.ee> wrote:
> SH> * Network changes gets discussed on netdev@oss.sgi.com
> SH> * 64 bit values are not atomic on 32 bit architectures
>
> Agree.
>
> SH> * wider values in /proc output risks breaking apps like ifconfig and netstat
>
> This is probably not a problem here, ifconfig etc have been working fine
> with non-wrapping numbers on sparc64 and other 64-bit machines.
Looking at current net-tools source, they are doing sscanf into a long-long-unsigned
value already.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-02-19 17:27 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1077123078.9223.7.camel@midux>
2004-02-18 18:17 ` [NET] 64 bit byte counter for 2.6.3 Stephen Hemminger
[not found] ` <Pine.LNX.4.53.0402181527000.7318@chaos>
2004-02-18 20:43 ` Markus Hästbacka
2004-02-18 22:45 ` Richard B. Johnson
2004-02-18 22:57 ` Stephen Hemminger
2004-02-18 23:17 ` Jeff Garzik
2004-02-19 8:14 ` Meelis Roos
2004-02-19 17:27 ` Stephen Hemminger
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).