[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AANLkTikcUnSYuRkSJivhavsBa+9TdaaHTNNWX7hRdE-J@mail.gmail.com>
Date: Tue, 25 Jan 2011 12:58:33 +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 6/6] x86/ticketlock: make __ticket_spin_trylock common
On Tue, Jan 25, 2011 at 12:42 PM, Jeremy Fitzhardinge <jeremy@...p.org> wrote:
> On 01/24/2011 05:16 PM, Nick Piggin wrote:
>> On Tue, Jan 25, 2011 at 10:41 AM, Jeremy Fitzhardinge <jeremy@...p.org> wrote:
>>> From: Jeremy Fitzhardinge <jeremy.fitzhardinge@...rix.com>
>>>
>>> Make trylock code common regardless of ticket size.
>> What's the asm for this look like?
>
> Asm:
>
> movzwl (%rdi), %eax # lock_1(D)->slock, tmp
> cmpb %ah,%al # tmp
> leal 0x100(%rax), %edx # tmp, new
> jne 1f
> lock; cmpxchgw %dx,(%rdi) # new, lock_1(D)->slock
> 1: sete %dl # new
> movzbl %dl,%eax # new, tmp
>
>
>
> C:
>
> movw (%rdi), %dx # lock_2(D)->D.5949.tickets, old
> xorl %eax, %eax # D.13954
> movzbl %dh, %ecx # old, tmp70
> cmpb %dl, %cl # old, tmp70
> jne .L5 #,
> leal 256(%rdx), %ecx #, D.13956
> movl %edx, %eax # old, __ret
> lock; cmpxchgw %cx,(%rdi) # D.13956,* lock
> cmpw %dx, %ax # old, __ret
> sete %al #, D.13954
> movzbl %al, %eax # D.13954, D.13954
> .L5:
>
>
> The C version can't take advantage of the fact that the cmpxchg directly
> sets the flags, so it ends up re-comparing the old and swapped-out
> values to set the return. And it doesn't re-use the same sete to set
> the return value in the quick failed-to-acquire path.
Hm.
> It might be worth having a generic cmpxchg() variant which returns a
> succeed/fail flag rather than the fetched value, to avoid comparison in
> this case - since many (most?) cmpxchg() callers end up doing that
> comparison.
>
> How performance critical is trylock? I guess the ones in fs/dcache.c
> are the ones looming large in your mind.
Well they are on on the reclaim/free path rather than the _hottest_
paths, but yes they are performance critical.
--
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