From patchwork Mon Jan 5 04:51:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 42728 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 85CA420A5F for ; Mon, 5 Jan 2015 04:51:42 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id f15sf11892070lbj.11 for ; Sun, 04 Jan 2015 20:51:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:date:from:to:cc:subject:in-reply-to :message-id:references:user-agent:mime-version:content-type:sender :precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=sUBM2B0Sz71K1LgnlAwhOvIgJjkuWKZ5apF4cUEA/cU=; b=GqaN8EQOXUI27Qem033OI8MqXIGvCMnO/oePFnk8ASvRfSAXCWfqC4bVeZKMCC442Z tYWcJ0/sMyWp/fBw+ilDgOY8RTJ+RLkb0ZSEYsAg7mst8+bJDfXqmFYmTmlH1Kt+8+7G GyyZHRLi/YMiRKIYwYgxBIih5anK6JmvAVeFp7sRXiFEj4TPKgkiPtrltOlZMTgf4PAT cAzVF+UTEhbnGnBU4uJtLJphh4J35ouLmcPzN0h1R6yK/lunms/GpTK0qbE12SAUenPn wkoq+1HEN108ISv4YBas2+eLnpj2J54zoxwfNWwY3JkIqCCPyVM8SJez/+knfjMwOShO E1hg== X-Gm-Message-State: ALoCoQmUmTIySApz3hWrbs26nyoryrA+1Pp6wpxIsKmZYXGOE0B50PLpNgDZ8IfyGE9e50nhlauL X-Received: by 10.112.9.199 with SMTP id c7mr414864lbb.7.1420433501329; Sun, 04 Jan 2015 20:51:41 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.165 with SMTP id x5ls2564011lal.34.gmail; Sun, 04 Jan 2015 20:51:41 -0800 (PST) X-Received: by 10.152.44.129 with SMTP id e1mr90411874lam.43.1420433501013; Sun, 04 Jan 2015 20:51:41 -0800 (PST) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id al1si60616412lbc.23.2015.01.04.20.51.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 04 Jan 2015 20:51:40 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by mail-lb0-f179.google.com with SMTP id z11so17021175lbi.38 for ; Sun, 04 Jan 2015 20:51:40 -0800 (PST) X-Received: by 10.152.87.100 with SMTP id w4mr90294031laz.71.1420433500814; Sun, 04 Jan 2015 20:51:40 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.9.200 with SMTP id c8csp779280lbb; Sun, 4 Jan 2015 20:51:39 -0800 (PST) X-Received: by 10.68.129.134 with SMTP id nw6mr126615928pbb.132.1420433498726; Sun, 04 Jan 2015 20:51:38 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wi10si81724674pab.136.2015.01.04.20.51.37; Sun, 04 Jan 2015 20:51:38 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753146AbbAEEvg (ORCPT + 27 others); Sun, 4 Jan 2015 23:51:36 -0500 Received: from mail-qg0-f41.google.com ([209.85.192.41]:62341 "EHLO mail-qg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752838AbbAEEvf (ORCPT ); Sun, 4 Jan 2015 23:51:35 -0500 Received: by mail-qg0-f41.google.com with SMTP id e89so13094612qgf.0 for ; Sun, 04 Jan 2015 20:51:34 -0800 (PST) X-Received: by 10.229.211.193 with SMTP id gp1mr67849423qcb.19.1420433494157; Sun, 04 Jan 2015 20:51:34 -0800 (PST) Received: from xanadu.home (modemcable142.180-131-66.mc.videotron.ca. [66.131.180.142]) by mx.google.com with ESMTPSA id y10sm49550280qad.23.2015.01.04.20.51.32 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 04 Jan 2015 20:51:33 -0800 (PST) Date: Sun, 4 Jan 2015 23:51:31 -0500 (EST) From: Nicolas Pitre To: Russell King - ARM Linux cc: Linus Torvalds , Pavel Machek , Marc Zyngier , kernel list Subject: Re: [PATCH] Revert 9fc2105aeaaf56b0cf75296a84702d0f9e64437b to fix pyaudio (and probably more) In-Reply-To: <20150104212659.GC12302@n2100.arm.linux.org.uk> Message-ID: References: <20150104190123.GA20153@amd> <20150104201026.GA23427@amd> <20150104203724.GA16372@amd> <20150104212659.GC12302@n2100.arm.linux.org.uk> User-Agent: Alpine 2.11 (LFD 23 2013-08-11) MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: nicolas.pitre@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , On Sun, 4 Jan 2015, Russell King - ARM Linux wrote: > On Sun, Jan 04, 2015 at 04:20:57PM -0500, Nicolas Pitre wrote: > > On Sun, 4 Jan 2015, Linus Torvalds wrote: > > > > > On Sun, Jan 4, 2015 at 12:56 PM, Nicolas Pitre wrote: > > > > > > > > It wasted a lot of people's time before by simply being there and wrong > > > > before it was removed. It's only a matter of whose time you want to > > > > waste. Really. > > > > > > Really. Shut up. > > > > > > The whole "no regressions" thing is very much about the fact that we > > > don't waste users time. > > > > I was talking about users time all along. > > > > Never mind. I'm sorry for the NAK and sorry for attempting to start a > > discussion to find a better replacement. > > Nico, > > I encourage you *not* to back down like this. Linus is right in so far > as the regressions issue, but he is *totally* wrong to do the revert, > which IMHO has been done out of nothing more than spite. > > Either *with or without* the revert, the issue still remains, and needs > to be addressed properly. > > With the revert in place, we now have insanely small bogomips values > reported via /proc/cpuinfo when hardware timers are used. That needs > fixing. Here's my take on it. Taking a step back, it was stupid to mix bogomips with timer based delays. ----- >8 From: Nicolas Pitre Date: Sun, 4 Jan 2015 22:28:58 -0500 Subject: [PATCH] ARM: disentangle timer based delays and bogomips calibration The bogomips value is a pseudo CPU speed value originally used to calibrate loop-based small delays. It is also exported to user space through the /proc filesystem and some user space apps started relying on it. Modern hardware can vary their CPU clock at run time making the bogomips value less reliable for delay purposes. With the advent of high resolution timers, small delays migrated to timer polling loops instead. Strangely enough, the bogomips value calibration became timer based too, making it way more bogus than it already was as a CPU speed representation and people using it via /proc/cpuinfo started complaining. Since it was wrong for user space to rely on a "bogus" mips value to start with, the initial responce from kernel people was to remove it. This broke user space even more as some applications then refused to run altogether. The bogomips export was therefore reinstated in commit 4bf9636c39 ("Revert 'ARM: 7830/1: delay: don't bother reporting bogomips in /proc/cpuinfo'"). Because the reported bogomips is orders of magnitude away from the traditionally expected value for a given CPU when timer based delays are in use, and because lumping bogomips and timer based delay loops is rather senseless anyway, let's calibrate bogomips using a CPU loop all the time even when timer based delays are available. Timer based delays don't need any calibration and /proc/cpuinfo will provide somewhat sensible values again. In practice, calls to __delay() will now always use the CPU based loop. Things remain unchanged for udelay() and its derivatives. Signed-off-by: Nicolas Pitre --- 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/ diff --git a/arch/arm/include/asm/delay.h b/arch/arm/include/asm/delay.h index dff714d886..7feeb163f5 100644 --- a/arch/arm/include/asm/delay.h +++ b/arch/arm/include/asm/delay.h @@ -21,13 +21,12 @@ struct delay_timer { }; extern struct arm_delay_ops { - void (*delay)(unsigned long); void (*const_udelay)(unsigned long); void (*udelay)(unsigned long); unsigned long ticks_per_jiffy; } arm_delay_ops; -#define __delay(n) arm_delay_ops.delay(n) +#define __delay(n) __loop_delay(n) /* * This function intentionally does not exist; if you see references to @@ -63,7 +62,6 @@ extern void __loop_udelay(unsigned long usecs); extern void __loop_const_udelay(unsigned long); /* Delay-loop timer registration. */ -#define ARCH_HAS_READ_CURRENT_TIMER extern void register_current_timer_delay(const struct delay_timer *timer); #endif /* __ASSEMBLY__ */ diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c index 312d43eb68..d958886874 100644 --- a/arch/arm/lib/delay.c +++ b/arch/arm/lib/delay.c @@ -30,7 +30,6 @@ * Default to the loop-based delay implementation. */ struct arm_delay_ops arm_delay_ops = { - .delay = __loop_delay, .const_udelay = __loop_const_udelay, .udelay = __loop_udelay, }; @@ -86,12 +85,8 @@ void __init register_current_timer_delay(const struct delay_timer *timer) if (!delay_calibrated && (!delay_res || (res < delay_res))) { pr_info("Switching to timer-based delay loop, resolution %lluns\n", res); delay_timer = timer; - lpj_fine = timer->freq / HZ; delay_res = res; - - /* cpufreq may scale loops_per_jiffy, so keep a private copy */ - arm_delay_ops.ticks_per_jiffy = lpj_fine; - arm_delay_ops.delay = __timer_delay; + arm_delay_ops.ticks_per_jiffy = timer->freq / HZ; arm_delay_ops.const_udelay = __timer_const_udelay; arm_delay_ops.udelay = __timer_udelay; } else { @@ -102,7 +97,9 @@ void __init register_current_timer_delay(const struct delay_timer *timer) unsigned long calibrate_delay_is_known(void) { delay_calibrated = true; - return lpj_fine; + + /* calibrate bogomips even when timer based delays are used */ + return 0; } void calibration_delay_done(void)