Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751560AbdCYSeg (ORCPT ); Sat, 25 Mar 2017 14:34:36 -0400 Received: from mail-it0-f44.google.com ([209.85.214.44]:35678 "EHLO mail-it0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751242AbdCYSef (ORCPT ); Sat, 25 Mar 2017 14:34:35 -0400 MIME-Version: 1.0 In-Reply-To: References: <20170324142140.vpyzl755oj6rb5qv@hirez.programming.kicks-ass.net> <20170324164108.ibcxxqbhvx6ao54r@hirez.programming.kicks-ass.net> <20170324172342.radlrhk2z6mwmdgk@hirez.programming.kicks-ass.net> <20170324212329.GC5680@worktop> <20170325075156.GF32474@worktop> <20170325182023.qfnj6vaixibbgbmd@hirez.programming.kicks-ass.net> From: Linus Torvalds Date: Sat, 25 Mar 2017 11:34:32 -0700 X-Google-Sender-Auth: 6DURa3KifZ3im2ygpX7Uxi9JX1E Message-ID: Subject: Re: locking/atomic: Introduce atomic_try_cmpxchg() To: Peter Zijlstra Cc: Andy Lutomirski , Dmitry Vyukov , Andrew Morton , Andy Lutomirski , Borislav Petkov , Brian Gerst , Denys Vlasenko , "H. Peter Anvin" , Josh Poimboeuf , Paul McKenney , Thomas Gleixner , Ingo Molnar , LKML Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 783 Lines: 20 On Sat, Mar 25, 2017 at 11:28 AM, Linus Torvalds wrote: > > Hmm. Sad. The label approach looked like it would match the semantics > of cmpxchg perfectly, but it's not as optimal as it superficially > would have seemed. Oh, I just noticed that at least your other one didn't mark "success" as being likely. That changed code generation a lot for me for the loops, where gcc would assume that the loop was likely to be taken, which in turn means that gcc lays out the loop with a backwards branch. Which is denser, but also likely slower, since most x86 chips predict backwards branches taken. So that might be one difference. Although the size differences in the last case are so small that it might also just be random noise. Linus