Re: SMP spin-locks

David S. Miller (davem@redhat.com)
Thu, 14 Jun 2001 10:32:13 -0700 (PDT)


Richard B. Johnson writes:
> Spin-locks now transfer control to the .text.lock segment.
> This is a separate segment that can be at an offset that
> is far away from the currently executing code. That may
> cause the cache to be reloaded. Further, each spin-lock
> invocation generates separate code within that segment.
>
> Question 1: Why?

Because this increases the code density of the common
case, getting the lock immediately.

> Question 2: What is the purpose of the code sequence, "repz nop"
> generated by the spin-lock code? Is this a processor BUG work-around?
> `as` doesn't "like" this sequence and, Intel doesn't seem to
> document it.

It is a hint to the processor that we are executing a spinlock loop
(it does something wrt. keeping the cacheline of the lock in shared
state when possible).

I believe it is documented in the Pentium 4 manuals, previous chips
ignore this sequence and treat it as a pure nop from what I understand.

Later,
David S. Miller
davem@redhat.com
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/