[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AANLkTikPfjzpQn4nYgoAyAJ6sDnZM-a0b3V794Q_Mpy+@mail.gmail.com>
Date: Tue, 25 Jan 2011 12:08:50 +1100
From: Nick Piggin <npiggin@...il.com>
To: Jeremy Fitzhardinge <jeremy@...p.org>
Cc: Peter Zijlstra <peterz@...radead.org>,
"H. Peter Anvin" <hpa@...or.com>, Ingo Molnar <mingo@...e.hu>,
"the arch/x86 maintainers" <x86@...nel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Nick Piggin <npiggin@...nel.dk>,
Jeremy Fitzhardinge <jeremy.fitzhardinge@...rix.com>
Subject: Re: [PATCH 0/6] Clean up ticketlock implementation
On Tue, Jan 25, 2011 at 10:41 AM, Jeremy Fitzhardinge <jeremy@...p.org> wrote:
> From: Jeremy Fitzhardinge <jeremy.fitzhardinge@...rix.com>
>
> 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@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists