Re: [PATCH] 498+ days uptime

Oliver Xymoron (oxymoron@waste.org)
Tue, 25 Aug 1998 14:31:10 -0500 (CDT)


On Tue, 25 Aug 1998, Jamie Lokier wrote:

> > I think using 64-bit counters on i386 is unreasonable. These counters
> > are often incremented in extremely performance-critical areas. Using
> > a polled system where the kernel remembers when 32-bit counters overflowed
> > might be workable.
>
> Incrementing a 64-bit value on i386 is fast and simple. It's arithmetic
> done in GCC, especially with temporaries that you have to worry about.
>
> The instruction sequence is:
>
> incl counter
> adcl $0,counter+4

I played with making GCC spew some assembly for long long arithmetic this
morning, and this is almost what GCC gives you for the simple case of
counter++ (it actually uses addl $1 rather than incl). Unfortunately it
generates far uglier code if you want to do something like

unsigned long long total_bytes;
unsigned int packet_length;

total_bytes+=packet_length;

While this would hopefully turn into a simple

; Add %eax to %esi:%ebx
addl %eax,%ebx
adcl $0,%esi

even at -O6 it becomes something like

xorl %ecx,%ecx
movl %eax,-8(%ebp)
movl %ecx,-4(%ebp)
addl -8(%ebp),%ebx
adcl -4(%ebp),%esi

Using anything but the most basic long long math in the kernel either
means we have assembler macros -everywhere-, improve GCC's long long math,
or live with code like the above all over the place. The correct answer is
probably to fix GCC as we wil probably continue to have PIIs for several
years to come.

Interestingly, this may be the last time we have to worry about the word
size problem for storage/bandwidth/clock_t/etc.. If you assume for a
moment that we're now at the limit of 32 bit words, and requirements
double every year, we won't exhaust 64 bits for another 32 years. If you
then assume we double word sizes only every ten years, we'll all be
using 512-bit processors by then. The Linux source tree will also be
about 40 petabytes compressed.

--
 "Love the dolphins," she advised him. "Write by W.A.S.T.E.." 

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html