Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754747AbbK3V3b (ORCPT ); Mon, 30 Nov 2015 16:29:31 -0500 Received: from mail-wm0-f50.google.com ([74.125.82.50]:37343 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752076AbbK3V3a (ORCPT ); Mon, 30 Nov 2015 16:29:30 -0500 From: Rasmus Villemoes To: Arnd Bergmann Cc: Ralf Baechle , linux-mips@linux-mips.org, linux-kernel@vger.kernel.org, Richard Henderson , Geert Uytterhoeven , "Rafael J. Wysocki" Subject: Re: no-op delay loops Organization: D03 References: <87si3rbz6p.fsf@rasmusvillemoes.dk> <3228673.rOyW85ILiP@wuerfel> X-Hashcash: 1:20:151130:arnd@arndb.de::fsmk3dVuvg4JKscc:00002Fd6 X-Hashcash: 1:20:151130:ralf@linux-mips.org::VqlaVvjPrwVrQp4S:00000000000000000000000000000000000000000022Bd X-Hashcash: 1:20:151130:linux-kernel@vger.kernel.org::FOmyDZWl2kPl8Mt5:0000000000000000000000000000000005LtZ X-Hashcash: 1:20:151130:linux-mips@linux-mips.org::MpBK8/PK76BMW7Lb:0000000000000000000000000000000000005kvb Date: Mon, 30 Nov 2015 22:29:26 +0100 In-Reply-To: <3228673.rOyW85ILiP@wuerfel> (Arnd Bergmann's message of "Fri, 27 Nov 2015 12:17:54 +0100") Message-ID: <874mg3b2h5.fsf@rasmusvillemoes.dk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1897 Lines: 52 On Fri, Nov 27 2015, Arnd Bergmann wrote: > On Friday 27 November 2015 09:53:50 Rasmus Villemoes wrote: >> >> It seems that gcc happily compiles >> >> for (i = 0; i < 1000000000; ++i) ; >> >> into simply >> >> i = 1000000000; >> >> (which is then usually eliminated as a dead store). At least at -O2, and >> when i is not declared volatile. So it would seem that the loops at >> >> arch/mips/pci/pci-rt2880.c:235 >> arch/mips/pmcs-msp71xx/msp_setup.c:80 >> arch/mips/sni/reset.c:35 >> >> actually don't do anything. (In the middle one, i is 'register', but >> that doesn't change anything.) Is mips compiled with some special flags >> that would make gcc actually emit code for the above? >> > > I remember that gcc used to not optimize code that looked like a > delay loop such as the above, and my tests show that this was still > the case in gcc-4.0.3, but starting with gcc-4.1 it opimtized away > that loop. OK, thanks. That's a very very long time ago. FWIW, the remaining instances that my trivial coccinelle script found are ./arch/alpha/boot/main.c:187:1-4: no-op delay loop ./arch/m68k/68000/m68VZ328.c:86:10-13: no-op delay loop ./arch/m68k/bvme6000/config.c:338:2-5: no-op delay loop ./arch/m68k/coldfire/m53xx.c:533:1-4: no-op delay loop ./drivers/cpufreq/cris-artpec3-cpufreq.c:85:3-6: no-op delay loop ./drivers/cpufreq/cris-etraxfs-cpufreq.c:85:3-6: no-op delay loop ./drivers/tty/hvc/hvc_opal.c:313:3-6: no-op delay loop ./drivers/tty/hvc/hvc_vio.c:289:3-6: no-op delay loop (cc += a few people). The tty ones use volatile, so they probably work, though one might still want to use the *delay API. Rasmus -- 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/