From mboxrd@z Thu Jan 1 00:00:00 1970 From: Linus Torvalds Subject: Re: [patch 2/2]: introduce fast_gup Date: Fri, 18 Apr 2008 07:40:14 -0700 (PDT) Message-ID: References: <20080328025455.GA8083@wotan.suse.de> <20080328030023.GC8083@wotan.suse.de> <1208444605.7115.2.camel@twins> <1208448768.7115.30.camel@twins> <1208450119.7115.36.camel@twins> <1208453014.7115.39.camel@twins> Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Return-path: In-Reply-To: Sender: linux-arch-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: To: Geert Uytterhoeven Cc: Peter Zijlstra , Nick Piggin , Andrew Morton , shaggy-V7BBcbaFuwjMbYB6QlFGEg@public.gmane.org, axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, linux-arch-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Clark Williams , Ingo Molnar , Jeremy Fitzhardinge On Fri, 18 Apr 2008, Geert Uytterhoeven wrote: > On Thu, 17 Apr 2008, Peter Zijlstra wrote: > > +retry: > > + pte.pte_low = ptep->pte_low; > > + smp_rmb(); > > + pte.pte_high = ptep->pte_high; > > + smp_rmb(); > > + if (unlikely(pte.pte_low != ptep->pte_low)) > > + goto retry; > > What about using `do { ... } while (...)' instead? Partly because it's not a loop. It's an error and retry event, and it generally happens zero times (and sometimes once). I don't think it should even _look_ like a loop. So personally, I just tend to think that it's just more readable when it's written as being obviously not a regular loop. I'm not in the "gotos are harmful" camp. And partly because I tend to distrust loops for these thigns is that historically gcc sometimes did stupid things for loops (it assumed that loops were hot and tried to align them etc, and the same didn't happen for branch targets). Of course, these days I suspect gcc can't even tell the difference any more (it probably turns it into the same internal representation), but old habits die hard. Linus From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp1.linux-foundation.org ([140.211.169.13]:44015 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753288AbYDROmH (ORCPT ); Fri, 18 Apr 2008 10:42:07 -0400 Date: Fri, 18 Apr 2008 07:40:14 -0700 (PDT) From: Linus Torvalds Subject: Re: [patch 2/2]: introduce fast_gup In-Reply-To: Message-ID: References: <20080328025455.GA8083@wotan.suse.de> <20080328030023.GC8083@wotan.suse.de> <1208444605.7115.2.camel@twins> <1208448768.7115.30.camel@twins> <1208450119.7115.36.camel@twins> <1208453014.7115.39.camel@twins> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-arch-owner@vger.kernel.org List-ID: To: Geert Uytterhoeven Cc: Peter Zijlstra , Nick Piggin , Andrew Morton , shaggy@austin.ibm.com, axboe@kernel.dk, linux-mm@kvack.org, linux-arch@vger.kernel.org, Clark Williams , Ingo Molnar , Jeremy Fitzhardinge Message-ID: <20080418144014.B1WO8cA_agrk0o9ICyc_WQYf87v2uiLsSNjSzgfk9_E@z> On Fri, 18 Apr 2008, Geert Uytterhoeven wrote: > On Thu, 17 Apr 2008, Peter Zijlstra wrote: > > +retry: > > + pte.pte_low = ptep->pte_low; > > + smp_rmb(); > > + pte.pte_high = ptep->pte_high; > > + smp_rmb(); > > + if (unlikely(pte.pte_low != ptep->pte_low)) > > + goto retry; > > What about using `do { ... } while (...)' instead? Partly because it's not a loop. It's an error and retry event, and it generally happens zero times (and sometimes once). I don't think it should even _look_ like a loop. So personally, I just tend to think that it's just more readable when it's written as being obviously not a regular loop. I'm not in the "gotos are harmful" camp. And partly because I tend to distrust loops for these thigns is that historically gcc sometimes did stupid things for loops (it assumed that loops were hot and tried to align them etc, and the same didn't happen for branch targets). Of course, these days I suspect gcc can't even tell the difference any more (it probably turns it into the same internal representation), but old habits die hard. Linus