Re: [patch] new spinlock variant, spinlock-2.3.30-A4

Davide Libenzi (davidel@maticad.it)
Tue, 30 Nov 1999 19:45:54 +0100


Tuesday, November 30, 1999 6:36 PM
Ingo Molnar <mingo@chiara.csoma.elte.hu> wrote :

> movb $1, 3(%%esi) # spin_lock
> movl 4(%%esi), %%edx
> addl (%%esi), %%edx
> cmpl $0x01000000, %%edx
> je slow_path

This can lead to some dead loops, due to the fact that an atomic ( locked )
test and set is not used.
The lock acquire is based on the assumption that only one CPU execute the
lock code.
In theory if there are more than one CPUs executing the code, they can spend
a lot of loops without
getting the N bytes at zero.
This probability is higher greater is the number of CPUs.
Using a test and set instruction, even if N CPUs execute the same code at
the same time, only one gets
the lock value.

IMVHO,
Davide.

--
Debian, the freedom in freedom.

- 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/