From mboxrd@z Thu Jan 1 00:00:00 1970 From: Linus Torvalds Subject: Re: [PATCH v7 1/4] spinlock: A new lockref structure for lockless update of refcount Date: Tue, 3 Sep 2013 14:39:42 -0700 Message-ID: References: <20130901233005.GX13318@ZenIV.linux.org.uk> <20130902070538.GA31639@gmail.com> <20130903101522.GA22369@gmail.com> <20130903191950.GC30757@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Al Viro , Sedat Dilek , Waiman Long , Benjamin Herrenschmidt , Jeff Layton , Miklos Szeredi , Ingo Molnar , Thomas Gleixner , linux-fsdevel , Linux Kernel Mailing List , Peter Zijlstra , Steven Rostedt , Andi Kleen , "Chandramouleeswaran, Aswin" , "Norton, Scott J" , Peter Zijlstra , Arnaldo Carvalho de Melo To: Ingo Molnar Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Tue, Sep 3, 2013 at 2:34 PM, Linus Torvalds wrote: > > I'll try to hack that up too, but it's looking like it really is just > the "lock xadd", not the memory dependency chain.. Yeah, no difference: Better code generation with my quick hack for a percpu spinlock: =E2=94=82 ffffffff81078e70 : 0.59 =E2=94=82 push %rbp 0.25 =E2=94=82 mov %rsp,%rbp 0.07 =E2=94=82 mov $0x100,%eax 97.55 =E2=94=82 lock xadd %ax,%gs:(%rdi) 0.01 =E2=94=82 movzbl %ah,%edx =E2=94=82 cmp %al,%dl 0.68 =E2=94=82 =E2=86=93 je 29 =E2=94=82 nop =E2=94=8220: pause =E2=94=82 mov %gs:(%rdi),%al =E2=94=82 cmp %dl,%al =E2=94=82 =E2=86=91 jne 20 =E2=94=8229: pop %rbp 0.84 =E2=94=82 =E2=86=90 retq but the actual cost is pretty much the same: 6.81% lg_local_lock so it doesn't seem to be some odd weakness of the microarchitecture. Linus