Re: [PATCH 0/6] Clean up ticketlock implementation

From: Nick Piggin
Date: Mon Jan 24 2011 - 20:08:56 EST


On Tue, Jan 25, 2011 at 10:41 AM, Jeremy Fitzhardinge <jeremy@xxxxxxxx> wrote:
> From: Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>
>
> Hi all,
>
> This series cleans up the x86 ticketlock implementation by converting
> a large proportion of it to C.  This eliminates the need for having
> separate implementations for "large" (NR_CPUS >= 256) and "small"
> (NR_CPUS < 256) ticket locks.
>
> This also lays the groundwork for future changes to the ticketlock
> implementation.
>
> Of course, the big question when converting from assembler to C is
> what the compiler will do to the code.  In general, the results are
> very similar.
>
> For example, the original hand-coded small-ticket ticket_lock is:
>      movl   $256, %eax
>      lock xadd %ax,(%rdi)
>   1: cmp    %ah,%al
>      je     2f
>      pause
>      mov    (%rdi),%al
>      jmp    1b
>   2:
>
> The C version, compiled by gcc 4.5.1 is:
>        movl   $256, %eax
>        lock; xaddw %ax, (%rdi)
>        movzbl  %ah, %edx
> .L3:    cmpb    %dl, %al
>        je      .L2
>        rep; nop
>        movb    (%rdi), %al     # lock_1(D)->D.5949.tickets.head, inc$head
>        jmp     .L3     #
> .L2:
>
> So very similar, except the compiler misses directly comparing
> %ah to %al.

Oh :(

Have you filed a bug with gcc?
--
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/