Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933094Ab3ICVj5 (ORCPT ); Tue, 3 Sep 2013 17:39:57 -0400 Received: from mail-vb0-f54.google.com ([209.85.212.54]:63878 "EHLO mail-vb0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759989Ab3ICVjn convert rfc822-to-8bit (ORCPT ); Tue, 3 Sep 2013 17:39:43 -0400 MIME-Version: 1.0 In-Reply-To: References: <20130901233005.GX13318@ZenIV.linux.org.uk> <20130902070538.GA31639@gmail.com> <20130903101522.GA22369@gmail.com> <20130903191950.GC30757@gmail.com> Date: Tue, 3 Sep 2013 14:39:42 -0700 X-Google-Sender-Auth: DuMlU5M0fLtGiQCfweZ0aSG8Dhg Message-ID: Subject: Re: [PATCH v7 1/4] spinlock: A new lockref structure for lockless update of refcount From: Linus Torvalds To: Ingo Molnar 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1177 Lines: 37 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: │ ffffffff81078e70 : 0.59 │ push %rbp 0.25 │ mov %rsp,%rbp 0.07 │ mov $0x100,%eax 97.55 │ lock xadd %ax,%gs:(%rdi) 0.01 │ movzbl %ah,%edx │ cmp %al,%dl 0.68 │ ↓ je 29 │ nop │20: pause │ mov %gs:(%rdi),%al │ cmp %dl,%al │ ↑ jne 20 │29: pop %rbp 0.84 │ ← 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/