Re: x86 rwsem: up_read() does not check active count in fast path

From: Michel Lespinasse
Date: Tue May 04 2010 - 18:39:11 EST


On Tue, May 4, 2010 at 5:41 AM, David Howells <dhowells@xxxxxxxxxx> wrote:
> Michel Lespinasse <walken@xxxxxxxxxx> wrote:
>
>> Looking at the x86 rwsem code, I have been wondering about the up_read()
>> path.  __rwsem_do_wake() comment mentions that one should check the active
>> count on the way there; however I could not find that check when coming from
>> up_read().
>
> Look in call_rwsem_wake(), which is implemented in assembly in two places in
> the x86 arch:
>
>        arch/x86/lib/rwsem_64.S
>        arch/x86/lib/semaphore_32.S

Gah thanks, I had totally missed that part (I knew about these files
but I had taken these as pure ABI wrappers; I did not notice the one
nugget of interesting logic hiding in there).

BTW, what's the reason for doing this check in call_rwsem_wake ? The
check is entirely redundant in the __up_write() case; and in
__up_read() things might be less confusing if edx was used locally
rather than in a separate function.

--
Michel "Walken" Lespinasse
A program is never fully debugged until the last user dies.
--
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/