RE: [PATCH -mm 5/6] cpu_relax(): use in ACPI lock

From: Brown, Len
Date: Fri Jun 30 2006 - 15:26:59 EST


>> I may be interpreting this incorrectly, but are you
>> busy-waiting on the ACPI Global Lock to become free?

No.

>Loop may be correctly waiting for the owner/pending bit to be
>set, just checking, I don't remember all the bit values.

Yes.

__acpi_acquire_global_lock is basically a lock-try
and set the pending bit on failure.

bit 0 is the PENDING bit
bit 1 is the OWNED bit

so the loop is doing this:

old = lock_value
try_again:
new = OWNED
if (old & OWNED)
new |= PENDING
cmpxchg(lock_value, old, new)
if (old != new) goto try_again;

return(!(new & PENDING)) /* ACQUIRED or not */


so we loop only if somebody else changed the lock_value
to be different from old at the same time this code did.

if the lock were held, we simply set the pending bit
and return that we failed to acquire the lock.

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