Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762065Ab0HFUdp (ORCPT ); Fri, 6 Aug 2010 16:33:45 -0400 Received: from claw.goop.org ([74.207.240.146]:41779 "EHLO claw.goop.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1762015Ab0HFUdn (ORCPT ); Fri, 6 Aug 2010 16:33:43 -0400 Message-ID: <4C5C71A5.3050500@goop.org> Date: Fri, 06 Aug 2010 13:33:41 -0700 From: Jeremy Fitzhardinge User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.7) Gecko/20100720 Fedora/3.1.1-1.fc13 Lightning/1.0b2pre Thunderbird/3.1.1 MIME-Version: 1.0 To: "H. Peter Anvin" CC: Jan Beulich , Peter Zijlstra , Xen-devel , Avi Kivity , Nick Piggin , Linux Kernel Mailing List Subject: Re: [PATCH RFC 02/12] x86/ticketlock: convert spin loop to C References: <1280761639.1923.213.camel@laptop> <4C56E1A1.6020005@goop.org> <4C5C1F80020000780000EA6D@vpn.id2.novell.com> <4C5C21E3.1020004@goop.org> <4C5C6DCE.4020206@zytor.com> In-Reply-To: <4C5C6DCE.4020206@zytor.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1126 Lines: 33 On 08/06/2010 01:17 PM, H. Peter Anvin wrote: > On 08/06/2010 07:53 AM, Jeremy Fitzhardinge wrote: >> On 08/06/2010 05:43 AM, Jan Beulich wrote: >>> You certainly mean "the compiler currently treats this as being:" - I >>> don't think there's a guarantee it'll always be doing so. >>> >>>> for (;;) { >>>> if (inc.tickets.head == inc.tickets.tail) >>>> goto out; >>>> ... >>>> } >>>> out: barrier(); >>>> } >>>> >>>> (Which would probably be a reasonable way to clarify the code.) >>> I therefore think it needs to be written this way. >> >> Agreed. >> > > A call/return to an actual out-of-line function is a barrier (and will > always be a barrier, as it is the fundamental ABI sequence points), > but to an inline function it is not. Yes. So the goto explicitly puts the barrier into the control flow which should stop the compiler from doing anything unexpected. J -- 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/