public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Nicolas Pitre <nicolas.pitre@linaro.org>
Cc: Russell King - ARM Linux <linux@arm.linux.org.uk>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Marc Zyngier <marc.zyngier@arm.com>,
	kernel list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Revert 9fc2105aeaaf56b0cf75296a84702d0f9e64437b to fix pyaudio (and probably more)
Date: Thu, 8 Jan 2015 23:49:57 +0100	[thread overview]
Message-ID: <20150108224957.GA5449@amd> (raw)
In-Reply-To: <alpine.LFD.2.11.1501042343240.18844@knanqh.ubzr>

On Sun 2015-01-04 23:51:31, Nicolas Pitre wrote:
> 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 <nicolas.pitre@linaro.org> 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 <nicolas.pitre@linaro.org>
> 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 <nico@linaro.org>

Acked-by: Pavel Machek <pavel@ucw.cz>

(No, I did not test it, but going to "historical" value should not
hurt, and it actually makes code shorter).

> 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)

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

  parent reply	other threads:[~2015-01-08 22:50 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-04 19:01 [PATCH] Revert 9fc2105aeaaf56b0cf75296a84702d0f9e64437b to fix pyaudio (and probably more) Pavel Machek
2015-01-04 20:03 ` Nicolas Pitre
2015-01-04 20:10   ` Pavel Machek
2015-01-04 20:25     ` Nicolas Pitre
2015-01-04 20:37       ` Pavel Machek
2015-01-04 20:56         ` Nicolas Pitre
2015-01-04 21:02           ` Linus Torvalds
2015-01-04 21:20             ` Nicolas Pitre
2015-01-04 21:26               ` Russell King - ARM Linux
2015-01-04 21:40                 ` Pavel Machek
2015-01-04 22:27                   ` Aaro Koskinen
2015-01-05  1:34                 ` Theodore Ts'o
2015-01-05 12:32                   ` Will Deacon
2015-01-05  4:51                 ` Nicolas Pitre
2015-01-05 12:11                   ` Will Deacon
2015-01-05 15:34                     ` Pavel Machek
2015-01-05 16:24                     ` Nicolas Pitre
2015-01-07 18:11                   ` Catalin Marinas
2015-01-07 18:47                     ` Linus Torvalds
2015-01-07 19:00                       ` Nicolas Pitre
2015-01-07 19:36                         ` Linus Torvalds
2015-01-07 20:34                           ` Nicolas Pitre
2015-01-07 20:53                             ` Russell King - ARM Linux
2015-01-07 21:15                               ` Nicolas Pitre
2015-01-09 22:54                                 ` Steven Rostedt
2015-01-07 22:14                               ` Catalin Marinas
2015-01-08  0:05                                 ` Linus Torvalds
2015-01-08  0:45                                   ` Nicolas Pitre
2015-01-08  0:57                                     ` Linus Torvalds
2015-01-08  4:56                                       ` Nicolas Pitre
2015-01-08  5:04                                         ` Linus Torvalds
2015-01-08  5:54                                           ` Nicolas Pitre
2015-01-08 10:39                                 ` Russell King - ARM Linux
2015-01-08 15:44                                   ` Vince Weaver
2015-01-08 16:19                                     ` Catalin Marinas
2015-01-08 16:34                                       ` Russell King - ARM Linux
2015-01-08 16:41                                         ` Catalin Marinas
2015-01-08 16:57                                           ` Russell King - ARM Linux
2015-01-08 17:01                                             ` Catalin Marinas
2015-01-08 17:39                                               ` Vince Weaver
2015-01-08 17:22                                             ` Vince Weaver
2015-01-08 22:46                                             ` Pavel Machek
2015-01-09  9:49                                               ` Catalin Marinas
2015-01-08 16:32                                     ` Russell King - ARM Linux
     [not found]                             ` <CA+55aFwuO2g1S-bY96V28crMWj+dKXWANzbP28JQjBdTg0rV0w@mail.gmail.com>
2015-01-07 21:29                               ` Nicolas Pitre
     [not found]                                 ` <CA+55aFyrNE9qqBR9Khbj=TuAnjA+UzUhNxFz==SqKuiG5q3uMQ@mail.gmail.com>
2015-01-07 22:42                                   ` Nicolas Pitre
2015-01-08  0:25                                     ` Linus Torvalds
2015-01-08  0:49                                       ` Linus Torvalds
2015-01-07 22:24                           ` Catalin Marinas
2015-01-07 18:50                     ` Nicolas Pitre
2015-01-08 22:49                   ` Pavel Machek [this message]
2015-01-06 18:33         ` Will Deacon
2015-01-04 20:22   ` Linus Torvalds
2015-01-04 20:43     ` Russell King - ARM Linux
2015-01-04 20:52       ` Pavel Machek
2015-01-04 20:45     ` Nicolas Pitre
2015-01-04 20:57       ` Linus Torvalds
2015-01-04 21:15         ` Russell King - ARM Linux
2015-01-05 14:22           ` One Thousand Gnomes
2015-01-05 18:22             ` Catalin Marinas
2015-01-06 22:33               ` Linus Torvalds
2015-01-06 23:42                 ` Catalin Marinas
2015-01-07  1:20                   ` Linus Torvalds
2015-01-07 15:01                     ` Catalin Marinas
2015-01-08 13:29                       ` One Thousand Gnomes
2015-01-07  6:41                   ` Nicolas Pitre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150108224957.GA5449@amd \
    --to=pavel@ucw.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=marc.zyngier@arm.com \
    --cc=nicolas.pitre@linaro.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox