lkml.org 
[lkml]   [1999]   [Sep]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectfast 64 bit "atomic" x86 counters
Alan Cox wrote:
> 64bit atomic increments are expensive. You can collect the same data via
> ipchains if you wish to take the hit, or sample very 15 minutes

Which reminds me.
Let me know if this "cheap 63bit atomic increment" works...

Increment:

lock
addl $1,counter
jo 0f
jc 0f
.section .fixup,"ax"
0: incl counter+4
jmp 1f
.previous
1:

Read:

movl counter+4,%edx
lock
addl $0,(%esp)
movl counter,%eax
cmpl $0x80000000,%eax
adcl $0,%edx
shrl $1,%edx

Based on the observation that carry events are rare.
We can safely assume two never happen during the processor race windows.

enjoy,
-- Jamie

-
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.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:54    [W:0.031 / U:1.500 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site