From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752768Ab1HXXT3 (ORCPT ); Wed, 24 Aug 2011 19:19:29 -0400 Received: from claw.goop.org ([74.207.240.146]:53973 "EHLO claw.goop.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751054Ab1HXXT2 (ORCPT ); Wed, 24 Aug 2011 19:19:28 -0400 Message-ID: <4E5586FD.7080103@goop.org> Date: Wed, 24 Aug 2011 16:19:25 -0700 From: Jeremy Fitzhardinge User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 MIME-Version: 1.0 To: Linus Torvalds CC: "H. Peter Anvin" , Christoph Lameter , Peter Zijlstra , Ingo Molnar , the arch/x86 maintainers , Linux Kernel Mailing List , Nick Piggin , Jeremy Fitzhardinge Subject: Re: [PATCH 13/15] x86: add cmpxchg_flag() variant References: <738d736ecffa3bd32df76ae41188aa39c2ace941.1314054734.git.jeremy.fitzhardinge@citrix.com> <4E540548.4080402@goop.org> <4E541154.6090805@zytor.com> <4E542681.2090703@goop.org> <4E5527C2.8000801@goop.org> <4E555FBB.3020906@zytor.com> <4E556150.8030100@goop.org> <4E558380.7060304@zytor.com> In-Reply-To: X-Enigmail-Version: 1.3.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/24/2011 04:11 PM, Linus Torvalds wrote: > On Wed, Aug 24, 2011 at 4:04 PM, H. Peter Anvin wrote: >>> I was also thinking that using it reduces register pressure, since you >>> don't need to keep the "old" value around, so it dies sooner. >> ... but you burn a register for the intermediate flag value, so you're >> just as bad off. > But that register has much shorter liveness - so I do agree that it *can* help. > > Whether it actually *does* help is unclear. I do agree that we might > be better off without introducing yet another (questionable) > interface. I think the interface is useful because it directly expresses what many cmpxchg users want to know: "Did that work?" There are very few users which actually care what the "old" value was if it wasn't what they were expecting. There's 3(ish) ways it could be implemented, but I don't have a strong opinion on them: 1. with a direct compare, as people are doing now 2. with sete to set a flag (clearly better for > wordsize arguments) 3. with asm goto 4. (with a hypothetical gcc extension which exposes condition codes) My experiments with asm goto were not very promising at first glance, but it *should* be the best of the lot for most users. A hybrid 1/2 implementation would also be possible. But the interface hides the implementation specifics, so its not all that important. J