Re: Semaphore assembly-code bug

From: linux-os
Date: Mon Nov 01 2004 - 18:35:19 EST


On Mon, 1 Nov 2004, dean gaudet wrote:

On Mon, 1 Nov 2004, linux-os wrote:

On Mon, 1 Nov 2004, dean gaudet wrote:

On Sun, 31 Oct 2004, linux-os wrote:

Timer overhead = 88 CPU clocks
push 3, pop 3 = 12 CPU clocks
push 3, pop 2 = 12 CPU clocks
push 3, pop 1 = 12 CPU clocks
push 3, pop none using ADD = 8 CPU clocks
push 3, pop none using LEA = 8 CPU clocks
push 3, pop into same register = 12 CPU clocks

your microbenchmark makes assumptions about rdtsc which haven't been valid
since the days of the 486. rdtsc has serializing aspects and overhead that
you can't just eliminate by running it in a tight loop and subtracting out
that "overhead".


Wrong.

if you were correct then i should be able to measure 1 cycle differences
in sequences such as the following:
[SNIPPED...]

Who said? The resolution isn't even specified. Experimental
results with several different processors seem to show that
the resolution is about 4 cycles.

Script started on Mon 01 Nov 2004 04:48:04 PM EST
# ./tester
Timer overhead = 88 CPU clocks


1 nop = 4 CPU clocks
2 nops = 4 CPU clocks
3 nops = 4 CPU clocks
4 nops = 8 CPU clocks
5 nops = 8 CPU clocks
6 nops = 8 CPU clocks
7 nops = 8 CPU clocks
8 nops = 12 CPU clocks
# exit
Script done on Mon 01 Nov 2004 04:48:34 PM EST

Assembly :


nop8: nop
nop7: nop
nop6: nop
nop5: nop
nop4: nop
nop3: nop
nop2: nop
nop1: nop
ret

.global nop1
.global nop2
.global nop3
.global nop4
.global nop5
.global nop6
.global nop7
.global nop8


Cheers,
Dick Johnson
Penguin : Linux version 2.6.9 on an i686 machine (5537.79 BogoMips).
Notice : All mail here is now cached for review by John Ashcroft.
98.36% of all statistics are fiction.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/