Re: [Patch] Re: Nasty suprise with uptime

Richard B. Johnson
2001-10-31T14:32:30Z

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2079 bytes --]

On Wed, 31 Oct 2001, vda wrote:

[SNIPPED...]

> Hmm.... 64bit jiffies are attractive.
>
> I'd like to see less #defines in kernel
> Some parts of your patch fight with the fact that jiffies
> is converted to macro -> it is illegal now to have local vars
> called "jiffies". This is ugly. I know that there are tons of similarly
> (ab)used macros in the kernel now but let's stop adding more!
>
> This test prog shows how to make overlapping 32bit and 64bit vars.
> It works for me.
>
> #include <stdio.h>
> typedef unsigned long long u64;
>
> extern u64 jiffies_64;
> extern unsigned long jiffies;
> extern unsigned long jiffies_hi;
>
> asm(
> " .bss\n"
> " .align 8\n"
> ".globl jiffies_64\n"
> ".globl jiffies\n"
> ".globl jiffies_hi\n"
> "jiffies_64:\n"
> // <- a bunch of ifdefs needed here to sort out endianness stuff...
> "jiffies:\n"
> " .zero 4\n"
> "jiffies_hi:\n"
> " .zero 4\n"
>
> //not working!? how to return to prev .data/.text/whatever?
> //I don't know gas...
> //" .previous\n"
> );
>
> int main() {
> jiffies_64 = 0xFEDCBA9876543210UL;
> printf("lo: 0x%08x\n",jiffies);
> printf("hi: 0x%08x\n",jiffies_hi);
> return 0;
> }
>
> Is this better or not? If not, why?
> --
> vda

The problem is that a 64-bit jiffies on a 32-bit machine would
require a spin-lock every time the jiffies variable is changed!
This is because there are two (or more) memory accesses for
every 64 bit operation, plus two or more register accesses for
every 64 bit operation. If a context-switch or an interrupt
occurs between those operations, all bets are off about the
result.

The appended small tar.gz file contains some 64-bit assembly
plus some 64-bit C, Look at the assembly and it will become
obvious to you that you don't want to use a 64-bit timer
on a 32 bit machine.

Cheers,
Dick Johnson

Penguin : Linux version 2.4.1 on an i686 machine (799.53 BogoMips).

I was going to compile a list of innovations that could be
attributed to Microsoft. Once I realized that Ctrl-Alt-Del
was handled in the BIOS, I found that there aren't any.

[-- Attachment #2: Type: APPLICATION/octet-stream, Size: 3119 bytes --]